> My problem is about tagging haskell expressions with the types I want
> them to have. What is the compiler error "Can't for-all tye type
> variable(s) `wef' in the inferred type `CONS ei f7t34 wef'" about? I
> mean, when I get it, how can I get more information about what went
> wrong? (I am thinking of something like a compiler switch that makes
> ghc produce a file where every expression the input code is tagged
> with the inferred type.)

Here is a simpler version of your difficulty:

f (x:xs) y = g y
           where
             g :: a -> [a]
             g q = [x,q]

The type signature for g is wrong.  Why?  Because it is short
for
        g :: forall a. a -> [a]

[A Haskell's type signature *always* has a forall for all the
type variables it mentions.]

But g mentions "x", so it's just not true that g works for all
types a; it only works for those of x's type.  In fact
Haskell as it now stands makes it impossible for you to write
the type signature for g.  That's something that'll be fixed in 
Standard Haskell. The only question is what syntax to use.  Here's
the one I favour

f :: [a] -> [a]
f (x:xs) y = g y
           where
             g :: a -> [a]
             g q = [x,q]

The type signature for "f" brings the type variable "a" into
scope in the body of "f".  So now the type signature for "g" 
doesn't have a forall, as you'd expect.

Simon


Reply via email to