[Haskell] ghc question
Simon PeytonJones
simonpj at microsoft.com
Wed Mar 17 16:08:51 EST 2004
GHC does context reduction as late as possible, so that when overlapping
instances are involved the commitment is made where maximum information
is available.
Simon
 Original Message
 From: haskellbounces at haskell.org [mailto:haskellbounces at haskell.org]
On Behalf Of Jurriaan Hage
 Sent: 17 March 2004 15:35
 To: haskell at haskell.org
 Subject: [Haskell] ghc question

 Hello,

 Given the fact that Haskell 98 demands that class constraints in an
 explicit type are
 in a normal form (either a variable, or a type variable applied to a
 list of types), it struck me
 that in the following (not very useful) program ghci yields a type
 which is not of that form.

 class X a where
 (><) :: a > a > Bool

 class Y a where
 (<>) :: a > a > Bool
 _ <> _ = True

 instance Y a => X [a] where
 x >< y = not(head x <> head y)

 f :: Y a => a > a > Bool
 f g h = [g] >< [h]

 Now, in ghci
 :t f yields f :: forall t. (X [t]) => t > t > Bool

 Hugs does reduce the type of f to the explicit type in comments.

 My question is: is there any special reason for this behaviour?

 Jur
 
 http://www.cs.uu.nl/people/jur/progrock.html  jur at cs.uu.nl
 If email does not work try jurriaanhage at hotmail.com

 _______________________________________________
 Haskell mailing list
 Haskell at haskell.org
 http://www.haskell.org/mailman/listinfo/haskell
More information about the Haskell
mailing list