Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
How do I get polymorphic partial application?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-23 (22:09)
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.
On 6/23/07, Lukasz Stafiniak <> wrote:
> On 6/23/07, Philippe Wang <> 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:
> Archives:
> Beginner's list:
> Bug reports: