The problem is that there are two data types: Transaction
and FormatModel
, which have a formatId
field. To prevent the addition of type signatures to get formatId
from Transaction
or FormatModel
, I created a class of type 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
Can someone explain why the eta reduced implementation instance works and the other doesn't?
source share