Reputation: 115
I have the following instance:
instance Show ZZ where
show zz = toHexa (zzToInt zz)
I need another instance of Show
for the type ZZ
like
instance Show ZZ where
show zz = ...
How can I solve this problem? I need to declare the second Show
in another way.
Upvotes: 1
Views: 317
Reputation: 530823
You can only have one instance per type. If you need (or rather, want) another one, you need to define a new type.
newtype ZZOther = ZZOther ZZ
instance Show ZZOther where
show (ZZOther zz) = ... -- do something with zz :: ZZ
Upvotes: 7