[Haskell-beginners] typeclass error

Amitava Shee amitava.shee at gmail.com
Tue Apr 21 09:27:57 EDT 2009

I have the following code

-- foo.hs
module Foo where

class Foo a where
    bar :: a -> a

instance Foo Int where
    bar i = i + 10


It fails to compile withe following error
*Foo> bar 10

    Ambiguous type variable `t' in the constraints:
      `Num t' arising from the literal `10' at <interactive>:1:4-5
      `Foo t' arising from a use of `bar' at <interactive>:1:0-5
    Probable fix: add a type signature that fixes these type variable(s)

- Thanks
Amitava Shee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090421/e448181f/attachment.htm

More information about the Beginners mailing list