[Haskell] A puzzle and an annoying feature

Ketil Malde ketil+haskell at ii.uib.no
Thu Nov 25 00:34:24 EST 2004

Paul Govereau <govereau at eecs.harvard.edu> writes:

> This is a great example, thanks for posting it. However, I feel like
> the real problem in this example is the lexically-scoped type
> variables declared with your function f. I am always surprised by the
> effects that lexically-scoped type variables can have on top-level
> declarations.

I remain unpuzzled by your examples, could I ask you to elaborate?

> Consider another example:
>   f :: a -> a
>   f = \x -> x
> Of course, f has type (forall a. a -> a).


> However, if we add another declaration g with lexically-scoped type
> variable a:
>   g :: a -> a = \x -> 1
> Then, suddenly, f has type Integer -> Integer

Well, you say that the parameter and return value have the same type
a, and I suppose Haskell monomorphs the constant 1 to Integer. Did you
perhaps mean: 

    g :: a -> a = \x -> x

which has type () -> () ?

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell mailing list