Browse thread
Preventing values from escaping a context
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2010-02-11 (15:17) |
From: | rossberg@m... |
Subject: | Re: [Caml-list] Preventing values from escaping a context |
"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