typechecking too eager?

Keean Schupke k.schupke at imperial.ac.uk
Sun Nov 7 14:02:43 EST 2004


The following code should compile (If the constructor
is valid, so is the function):

data Test = Test (forall a . a)
test a = Test a

However this fails to compile with the following error:

Test.hs:9:9:
    Inferred type is less polymorphic than expected
      Quantified type variable `a' escapes
      It is mentioned in the environment:
        test :: a -> Test (bound at Test.hs:9:0)
        a :: a (bound at Test.hs:9:5)
    In the first argument of `Test', namely `a'
    In the definition of `test': test a = Test a

I think this should only generate an error once the value of
'a' is known not to be undefined.

    Keean.



More information about the Glasgow-haskell-users mailing list