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: | Till Varoquaux <till.varoquaux@g...> |
| Subject: | Re: [Caml-list] How do I get polymorphic partial application? |
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 On 6/23/07, Lukasz Stafiniak <lukstafi@gmail.com> wrote: > On 6/23/07, Philippe Wang <lists@philippewang.info> wrote: > > Till Varoquaux wrote: > > > Humm... I have a small issue here: I need to get the result of the > > > partial application of a polymorphic function. Since variable are > > > generalized in Let it is generally advised to use eta expansions, > > > (i.e transform to a total application). > > > sometimes eta expansions just won't do the trick, consider: > > > > I think you should not try to "hide" that ugly side effect... > > > Could someone give an example where this "eta-thing" forbids a crash? > I don't remember any example even in Xavier Leroy papers. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://till-varoquaux.blogspot.com/