data Direction a = North a | South
instance (Bounded tc) => Bounded (Direction tc) where
maxBound::(Direction tc) = North dc where dc = maxBound::tc
minBound::(Direction tc) = South
But I got the following error:
<interactive>:56:5: error:
Pattern bindings (except simple variables) not allowed in instance declaration:
maxBound :: (Direction tc)
= North dc
where
dc = maxBound :: vtc
<interactive>:57:5: error:
Pattern bindings (except simple variables) not allowed in instance declaration:
minBound :: (Direction tc) = South
instance (Bounded tc) => Bounded (Direction tc) where
maxBound = North maxBound
minBound = South
works with the same meaning as well, but I am not sure if op was producing a contrived example to illustrate the question. The class provides the definition so I think coercing the type like that cannot make sense?
Thank you, this does solved my problem. I search for what is
forall
in haskell, and realize the type variable tc within the instance declaration and type variable tc within the instance definition are not the same if forall not used.