[Haskell-beginners] help with error

Tyler Hayes tgh at pdx.edu
Sat Feb 20 22:07:50 EST 2010

I'm getting an error and I do not know why...

This is what I have:

class Finite a where
  elements' :: [a]

instance (Finite a, Show a, Show b) => Show (a -> b) where
   show f = concat (map show [ a | a <- elements'::[a] ])

and this is what ghci gives me:

    Could not deduce (Finite a1) from the context ()
      arising from a use of `elements'' at Hw06.lhs:119:42-50
    Possible fix:
      add (Finite a1) to the context of an expression type signature
    In the expression: elements' :: [a]
    In a stmt of a list comprehension: a <- elements' :: [a]
    In the second argument of `map', namely
        `[a | a <- elements' :: [a]]'

What's going on here?

Thanks for the help!
- Tyler

More information about the Beginners mailing list