Hi,

I am having trouble getting a small program to compile. The helpful folks at
#haskell created a version of the program that does compile -
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=28406#a28408 but it is not
very clear to them (and to me) why the original program wouldn't type
compile in the first place.

Here's the program that refuses to compile -

module Delme () wheredata DecisionState = A | B | C | Dd_test :: Eq b
=> b -> b -> DecisionState -> DecisionState -> ()d_test test testVal
trueState falseState =    if (test == testVal)     then d trueState
 else d falseStated :: DecisionState -> ()d A = d_test True True B Cd
B = d_test 1 2 C Dd C = d_test True False A Bd D = ()

I get an error like -

Delme.hs:13:0:
    Contexts differ in length
      (Use -XRelaxedPolyRec to allow this)
    When matching the contexts of the signatures for
      d_test :: forall b.
                (Eq b) =>
                b -> b -> DecisionState -> DecisionState -> ()
      d :: DecisionState -> ()
    The signature contexts in a mutually recursive group should all be
identical
    When generalising the type(s) for d_test, d

Putting in the extension does get the program to type check but the original
program should have type compiled in the first place.

The ironic thing we discovered is that if we remove the type declaration for
'd', the program type checks, and GHC then derives the exact same type which
we removed!

Can some of the smarter people in the room please shed more light on this?

-- Anupam
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to