问题是有两种数据类型,Transaction并且FormatModel都有formatId字段.为了防止添加类型签名formatId来自transaction或formatModel,我创建了类型类HasFormat:
class HasFormat a where
formatId_ :: a -> FormatId
instance HasFormat Transaction where
formatId_ x = formatId x -- gives error because ambiguous occurrence ‘formatId’
instance HasFormat FormatModel where
formatId_ = formatId -- this works
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么eta减少实现的实例正在工作而另一个没有?
haskell ×1