Browse thread
How do I get polymorphic partial application?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Lukasz Stafiniak <lukstafi@g...> |
| Subject: | Re: [Caml-list] How do I get polymorphic partial application? |
On 6/24/07, Till Varoquaux <till.varoquaux@gmail.com> wrote: > As said previously, in a HM type ineference system type variables are > generalized only in "let", that is: > > let id x = x (*starting with an identity function*) > let id'= id id (*this is a partial application; it has type '_a ->'_a*) > let _= > print_string (id' "a"); > print_int (id' 4) > > won't work (since id' has type '_a->'_a). > > Replacing the definition of id' with the eta expanded version (let id' > x = (id id) x) will however work. It is not 100% equivalent since > every application of the new id' goes twice through id whilst the old > was a reference to id.... > > I hope this answers your question. > Cheers, > Till No, it is related to the so called "value restriction" made Caml-ish way, in a pure functional (no references) HM types can be generalized. And I restate my question: can someone give an example, where if the top-level let-definition types were generalized, this would lead to a crash?