Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: How do I get polymorphic partial application?
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/