caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* How do I get polymorphic partial application?
@ 2007-06-23 18:55 Till Varoquaux
  2007-06-23 21:41 ` [Caml-list] " Philippe Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Till Varoquaux @ 2007-06-23 18:55 UTC (permalink / raw)
  To: OCaml

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:

let cntTag start=
 let cnt=ref start in
 fun v -> ((incr cnt;!cnt),v)

the partial application is not fully polymorphic

let tag1 = cntTag 1

has type

val tag1 : '_a -> int * '_a = <fun>

the eta expanded equivalent doesn't have the same semantic (it
actually seems even less useful):

let tag1 x= cntTag 1 x

Is there an elegant solution to that problem?
Cheers,
Till

-- 
http://till-varoquaux.blogspot.com/


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-06-23 22:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-23 18:55 How do I get polymorphic partial application? Till Varoquaux
2007-06-23 21:41 ` [Caml-list] " Philippe Wang
2007-06-23 21:49   ` Lukasz Stafiniak
2007-06-23 22:09     ` Till Varoquaux
2007-06-23 22:25       ` Lukasz Stafiniak
2007-06-23 22:11     ` Philippe Wang
2007-06-23 22:28       ` Lukasz Stafiniak
2007-06-23 22:07 ` Zheng Li
2007-06-23 22:09 ` Zheng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).