From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 35F2DBC6D for ; Sun, 24 Jun 2007 00:11:22 +0200 (CEST) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5NMBLHj019436 for ; Sun, 24 Jun 2007 00:11:22 +0200 Received: from [192.168.1.222] (vil93-4-82-227-140-227.fbx.proxad.net [82.227.140.227]) by smtp5-g19.free.fr (Postfix) with ESMTP id A7F76449B7; Sun, 24 Jun 2007 00:11:21 +0200 (CEST) Message-ID: <467D9A86.301@philippewang.info> Date: Sun, 24 Jun 2007 00:11:18 +0200 From: Philippe Wang User-Agent: Thunderbird 1.5.0.12 (Macintosh/20070509) MIME-Version: 1.0 To: Lukasz Stafiniak , ocaml ml Subject: Re: [Caml-list] How do I get polymorphic partial application? References: <9d3ec8300706231155p2429504ay6395ea0580756dc7@mail.gmail.com> <467D936C.5020501@philippewang.info> <4a708d20706231449g38836405xc48f4eb6fa82d779@mail.gmail.com> In-Reply-To: <4a708d20706231449g38836405xc48f4eb6fa82d779@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 467D9A89.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lukasz:01 expansions:01 expansions:01 foo:01 val:01 foo:01 semantics:01 polymorphic:01 polymorphic:01 wrote:01 wrote:01 partial:01 partial:01 typing:01 caml-list:01 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. If I understand what you mean, this could explain it : let foo () = let container = ref [] in fun x -> container := x :: !container; !container val foo : unit -> 'a -> 'a list (* first : doesn't work *) let plop = foo () let l1 = plop 42 let l2 = plop "42" (* crash -- but wouldn't crash with most *dynamic* typing systems *) let plop2 = fun () -> foo () let l1' = plop2 () 42 let l2' = plop2 () "42" (* no crash *) but plop and plop2 don't share the same semantics... -- Philippe Wang mail[at]philippewang.info