haskell - 在 Record 类型上添加类型类约束
问题描述
在此声明在我的上下文中运行良好之前:
data PersistedCommand = PersistedCommand { offset :: Offset , command :: Command }
instance Show PersistedCommand where
show persistedCommand = "PersistedCommand { offset = " ++ ( show $ offset persistedCommand) ++ " , command = " ++ (show $ getCommandName $ command persistedCommand) ++ ":"
++ (show $ getAggregateId $ command persistedCommand) ++ " }"
但是我已经Command
从数据类型变成了类型类。我现在如何在之前的声明中表达这一点?
解决方案
推荐阅读
- postgresql - PostgreSQL:使用 LIKE 过滤掉以“K”开头的姓氏
- python - 如何从 Python 中的字符串中删除自定义空格
- r - 将许多列的内容放在一个新的单列中
- ruby - 创建了一个动态类和函数生成器,但 method_body 部分不起作用
- numpy - numpy.randomState 中使用了哪种 Mersenne Twister?
- javascript - 一次打印递归所有节点获取操作信息
- plot - 删除 Plotly 中图表之间的差距
- c# - 为什么 Math.Atan2(-0.0, x) 返回与 Math.Atan2(0.0, x) 不同的结果?
- pandas - 如何使用 np.where 将我的变量转换为另一个变量
- mongodb - 如何从 MongoDB 的集群中删除特定的分片?