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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL 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 9986DBC6B for ; Sun, 24 Jun 2007 00:09:51 +0200 (CEST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.181]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5NM9olo019048 for ; Sun, 24 Jun 2007 00:09:51 +0200 Received: by py-out-1112.google.com with SMTP id a73so293932pye for ; Sat, 23 Jun 2007 15:09:49 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WoYaANsd5CRB5txTMI8N+14rI+EZM6F6IIZYRtzGdPIfgJyvA3JUn14EUZAPXKPE/E/u63B+nkDlSNcXQiZwWsEfOXyZeHrqEIf7lvU3NYlyxdBaRf6BL/rE0qwCnPasFXTj01odmKCAfSgjxGY9enMACG+P7vKs8OGNOLLIvhU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PmXFlW7Y93Fqw2Ck49AkX5dTEvtugBVHDntC77uAdyFZ3LlK5WS9FY6DHnhOG476SM4Cfu1orCZVxicIBdQU9GAjXTwkjdkAMmLBD7DBsquCmUSvtXrIjdDzRrFceRX+ZLbgWosRYnfM5X4PJP6YNI/jj/sNPxxSxG3yk0PB12M= Received: by 10.142.226.2 with SMTP id y2mr99369wfg.1182636587800; Sat, 23 Jun 2007 15:09:47 -0700 (PDT) Received: by 10.143.168.5 with HTTP; Sat, 23 Jun 2007 15:09:47 -0700 (PDT) Message-ID: <9d3ec8300706231509p373e494ci1b05987fb3723e69@mail.gmail.com> Date: Sun, 24 Jun 2007 00:09:47 +0200 From: "Till Varoquaux" To: "Lukasz Stafiniak" Subject: Re: [Caml-list] How do I get polymorphic partial application? Cc: caml-list In-Reply-To: <4a708d20706231449g38836405xc48f4eb6fa82d779@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9d3ec8300706231155p2429504ay6395ea0580756dc7@mail.gmail.com> <467D936C.5020501@philippewang.info> <4a708d20706231449g38836405xc48f4eb6fa82d779@mail.gmail.com> X-j-chkmail-Score: MSGID : 467D9A2E.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 467D9A2E.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; cheers:01 lukasz:01 expansions:01 expansions:01 beginner's:01 ocaml:01 bug:01 polymorphic:01 polymorphic:01 beginners:01 wrote:01 wrote:01 partial:01 partial:01 caml-list:01 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 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: > 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/