[Haskell-beginners] Typeclass question

Patrick LeBoutillier patrick.leboutillier at gmail.com
Tue Dec 1 10:48:50 EST 2009

Hi all,

I want to make all types that are instances of Integral instances of
another type class, i.e:

{-# LANGUAGE FlexibleInstances #-}

class Intable a where
  toInt :: a -> Int

instance (Integral a) => Intable a where
  toInt l = fromIntegral l

However this gives the following error that I don't understand:

    Constraint is no smaller than the instance head
      in the constraint: Integral a
    (Use -XUndecidableInstances to permit this)
    In the instance declaration for `Intable a'

Can anyone offer insight on thie error? Also, is there perhaps a
different way to do
what I want to do?


Patrick LeBoutillier
Rosemère, Québec, Canada

More information about the Beginners mailing list