GHC, functional dependency, rank-2 type
John Tromp
John.Tromp at cwi.nl
Tue Jan 13 15:19:45 EST 2004
oleg at pobox.com wrote:
> There appears to be a problem with GHC's handling of multi-parameter
> constraints with functional dependencies in the context of rank-2
> types. The problem is not present in Hugs.
>
> Let us first consider a simple example:
>
>
>>module Test where
>>class Foo a
>>
>>class Bar a
>>
>>data Obj = Obj
>>
>>instance Bar Obj
>>
>>instance (Bar a) => Foo a
I have tried to write code myself like in the last line,
stating that any instance of one class should also be
an instance of another class. But Hugs would complain about
it and so it does about the above:
Prelude> :l Test
Reading file "Test.hs":
ERROR Test.hs:10 - syntax error in instance head (constructor expected)
This is the Feb2001 version of hugs running on RedHat9.
I seem to remember that the Haskell Report indeed states that the
right side of an instance declaration should contain a type constructor.
So I'm puzzled as to why the above works for you...
regards,
%!PS % -John Tromp (http://www.cwi.nl/~tromp/)
42 42 scale 7 9 translate .07 setlinewidth .5 setgray/c{arc clip fill
setgray}def 1 0 0 42 1 0 c 0 1 1{0 3 3 90 270 arc 0 0 6 0 -3 3 90 270
arcn 270 90 c -2 2 4{-6 moveto 0 12 rlineto}for -5 2 5{-3 exch moveto
9 0 rlineto}for stroke 0 0 3 1 1 0 c 180 rotate initclip}for showpage
More information about the Haskell
mailing list