caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: rossberg@mpi-sws.org
To: "Alexey Rodriguez" <mrchebas@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Preventing values from escaping a context
Date: Thu, 11 Feb 2010 16:17:33 +0100 (CET)	[thread overview]
Message-ID: <1c9307ccfe18231af34a047d2a654daf.squirrel@mail.mpi-sws.org> (raw)
In-Reply-To: <4b39c80a1002110552w3d223293x5a2836bebcdf9e24@mail.gmail.com>

"Alexey Rodriguez" <mrchebas@gmail.com> wrote:
>
>>> But for this you need support from the type system (rank-2 universal
>>> quantification).
>>
>> FWIW, OCaml can express that, but it doesn't help the problem.
>
> Andreas, I'd be interested in seeing such encodings. Any pointers?

There are currently two ways to express that in OCaml, either through
polymorphic record fields or through polymorphic object methods. For the
former, consider:

  type f_arg = {it : 'a. 'a -> 'a}
  let f {it = g} = (g 5, g true)

  f {it = fun x -> x}

One caveat is that the value restriction can byte you, especially if you
try to encode s.th like monads, but that's a somewhat separate issue.

/Andreas


      reply	other threads:[~2010-02-11 15:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09  3:07 Rich Neswold
2010-02-09  3:38 ` [Caml-list] " Jacques Garrigue
2010-02-09  8:24   ` Miles Sabin
2010-02-09  8:43     ` Jacques Garrigue
2010-02-09 17:18     ` Rich Neswold
2010-02-09  8:31   ` Tiphaine Turpin
2010-02-09 18:09     ` Rich Neswold
2010-02-09 18:45       ` Tiphaine Turpin
2010-02-10  0:39         ` Rich Neswold
2010-02-10  8:55           ` Goswin von Brederlow
2010-02-10 18:00             ` Rich Neswold
2010-02-10 21:37               ` Goswin von Brederlow
2010-02-09 17:13   ` Rich Neswold
2010-02-09  3:59 ` Yaron Minsky
2010-02-09 17:16   ` Rich Neswold
2010-02-11 10:39   ` Alexey Rodriguez
2010-02-11 11:05     ` rossberg
2010-02-11 13:52       ` Alexey Rodriguez
2010-02-11 15:17         ` rossberg [this message]

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=1c9307ccfe18231af34a047d2a654daf.squirrel@mail.mpi-sws.org \
    --to=rossberg@mpi-sws.org \
    --cc=caml-list@inria.fr \
    --cc=mrchebas@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).