[Haskell-cafe] Re: Fun with multi-parameter type classes

karczma karczma at info.unicaen.fr
Thu Aug 19 17:36:25 EDT 2004

Sam Mason writes: 

> Jon Cast wrote:
>>The intermediate type /is/ needed---it's a (hidden) parameter to your
>>`encode' and `decode' functions.  Why do you think it shouldn't be?
> Because I couldn't see the woods for the trees.  I think I had
> almost figured out what I was asking (the impossible) before your
> message appeared.

Don't forget that this is the toplevel business, not a universal
"disease". GHCi says 

Prelude> :t (show . read)
(show . read) :: String -> String 

and doesn't complain. But if you define 

bz = show . read 

the attempt to load this definition (file: ctest.hs) results in: 

   Ambiguous type variable `a' in these top-level constraints:
     `Read a' arising from use of `read' at ctest.hs:5
     `Show a' arising from use of `show' at ctest.hs:5
Failed, modules loaded: none.

So, as one of my friends used to say: it should be obvious for
everybody that what is obvious for one, need not be obvious for
the others... 

Jerzy Karczmarczuk 

More information about the Haskell-Cafe mailing list