[Haskell] MPTCs and type inference
Andreas Rossberg
rossberg at ps.uni-sb.de
Mon Apr 25 07:13:05 EDT 2005
This may well be stupidity on my side, but some experiments with multi
parameter type classes got me slightly confused. Can somebody explain
the following behaviour to me?
class D a b where fd :: a -> b -> ()
d1 x = let p = fd x in ()
d2 x = let p y = fd x y in ()
GHC derives the following types:
d1 :: D a b => a -> ()
d2 :: a -> ()
Hugs rejects d1 on the grounds that the type is ambiguous, but agrees on
the type of d2. I do not understand where the context disappears to in
this example - in particular, when I compare with the single parameter case:
class C a where fc :: a -> a -> ()
c1 x = let p = fc x in ()
c2 x = let p y = fc x y in ()
where
c1 :: C a => a -> ()
c2 :: C a => a -> ()
is inferred, as I would expect.
--
Andreas Rossberg, rossberg at ps.uni-sb.de
Let's get rid of those possible thingies! -- TB
More information about the Haskell
mailing list