Paul Govereau <govereau@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).
Yes.
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 () -> () ? -kzm -- If I haven't seen further, it is by standing in the footprints of giants