首页 > 解决方案 > 在 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从数据类型变成了类型类。我现在如何在之前的声明中表达这一点?

标签: haskell

解决方案


推荐阅读