[Haskell-cafe] A voyage of undiscovery
wren ng thornton
wren at freegeek.org
Sat Jul 18 19:52:48 EDT 2009
Andrew Coppin wrote:
> Robert Greayer wrote:
>> f0 _ = (foo True, foo 'x') where foo = id
>>
>> is well-typed.
>>
>
> Really? That actually works? How interesting... This suggests to me that
> where-clauses also do strange things to the type system.
Not too strange, in fact we need it to do that for local definitions to
be helpful at all. The short answer is that let-binding is still
polymorphic, whereas lambda-binding (passing in a parameter) is
monomorphic. If let-binding were not polymorphic, then we could remove
it entirely can just desugar everything into lambda-bindings.
You should read this classic paper which introduced Hindley--Milner type
inference,
Robin Milner. A theory of type polymorphism in programming.
Journal of Computer and System Sciences, 17:348-375, August
1978.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list