caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <lists@philippewang.info>
To: Lukasz Stafiniak <lukstafi@gmail.com>, ocaml ml <caml-list@inria.fr>
Subject: Re: [Caml-list] How do I get polymorphic partial application?
Date: Sun, 24 Jun 2007 00:11:18 +0200	[thread overview]
Message-ID: <467D9A86.301@philippewang.info> (raw)
In-Reply-To: <4a708d20706231449g38836405xc48f4eb6fa82d779@mail.gmail.com>

Lukasz Stafiniak wrote:
> On 6/23/07, Philippe Wang <lists@philippewang.info> 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


  parent reply	other threads:[~2007-06-23 22:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-23 18:55 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 [this message]
2007-06-23 22:28       ` Lukasz Stafiniak
2007-06-23 22:07 ` Zheng Li
2007-06-23 22:09 ` Zheng Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=467D9A86.301@philippewang.info \
    --to=lists@philippewang.info \
    --cc=caml-list@inria.fr \
    --cc=lukstafi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).