On Feb 2, 2008, at 18:41 , I wrote: > No instance for (Bounded a) > arising from use of `maxBound' at Hbot.hs:6:34-41 > (...) > My (clearly flawed) understanding of the signature I've specified > for 'turn' means *exactly* that a is Bounded.
Brandon Allbery replied: > The problem is that the scope of a is the type signature; it does > *not* extend to the definition. > > You can try omitting the type on maxBound and minBound, or you > can enable the scoped type variables extension Thank you. This compiles fine with the Glasgow extensions turned on as long as the type in the function signature is universally quantified: turn :: forall a. (Enum a, Bounded a) => Int -> a -> a turn n e = toEnum (add (fromEnum (maxBound::a) + 1) (fromEnum e) n) where add mod x y = (x + y + mod) `rem` mod _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe