[Haskell-cafe] Problem trying to get class Bounded to work

Brian Hulley brianh at metamilk.com
Mon May 22 20:05:45 EDT 2006

Cale Gibbard wrote:
> Hello,
> There's a prelude function called asTypeOf which might help here:
> asTypeOf :: a -> a -> a
> asTypeOf = const
> You can use maxBound `asTypeOf` (fst3 . head $ elements)
> Another option is GHC's scoped type variables, which you use by adding
> a type signature to your pattern. See:
> http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#scoped-type-variables

Hi Cale -
Thanks for the solutions. The GHC scoped typed variables seem to be the best 
solution since they would seem to be the only way to implement something 
where the type only occurs in the result eg (if the actual fonts were to be 
added later):

       :: forall i m . (MonadException m, Enum i, Bounded i)
       => m (MonoMultiFont i)


More information about the Haskell-Cafe mailing list