From: Jacques Carette <carette@mcmaster.ca>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Custom let bindings
Date: Sun, 22 Jan 2012 10:18:13 -0500 [thread overview]
Message-ID: <4F1C28B5.7020901@mcmaster.ca> (raw)
In-Reply-To: <4F1BE3B1.3040704@inria.fr>
That discussion was extremely enlightening. I read every single message
carefully, then thought about it for a while, THEN I composed this
message. Then thought some more before sending it.
There is one place where things seem to have gone off the rails: Lwt's
concurrency pattern is *not* a (generic) monadic pattern. What Lwt does
here is to overload Caml's "let .. and ..." to mean (essentially)
Classen's 'Fork' monad transformer [1]; one could probably interpret it
via MonadZip as well. It is also worthwhile remembering that, in
Haskell concurrency is not handled via monads at all, and that
parallelism is handled monadically is very recent [2]. It is Lwt which
is over-reaching here, and it is not a flaw in Nicolas's proposal, or
Alain's variant. There are sufficiently many use-cases for "sequential
bind" to have a special syntax for that; a special syntax for parallel
bind can be developed later, as a further extension [esp. as Jérémie
found a 23:1002 ratio of parallel bind to sequential bind amongst users
of Lwt!].
As one heavy user of monads, and a co-author of pa_monad, I can
definitely say that the original let! proposal would be extremely useful
to me. If it could be made to mesh nicely with a (generic) monadic
interface, that would be sufficient. As Xavier's extensive code shows,
monads work now in OCaml. The only question that remains is a nice bit
of syntactic sugar that 'fits' OCaml, like the 'do' notation fits Haskell.
To make a specific proposal: why not adopt the pa_monad syntax (or
variant thereof)? The implementation would have to be modernized to use
all the wonderful 3.12 features, but otherwise seems to fit the other
use cases rather well.
On 22/01/2012 5:23 AM, Xavier Leroy wrote:
> In the end, we decided that none of the proposals is something we can
> commit on and put (forever) in the core language. This is one of the
> cases that is currently best handled by Camlp4 syntax extensions,
> either specific to a monad (Lwt) or more general (pa_monad).
Note that pa_monad has not been certified to work properly with 3.12. I
have tried to do some further work with Camlp4 (which required changes
to Camlp4 itself), and was not successful - the bootstrapping steps are
simply too fragile. pa_monad is, unfortunately, likely to bit-rot over
time.
As a stop-gap, I think I will ask Oleg which patch he prefers (Nicolas'
or Alain's), and get that pushed onto ber-metaocaml, so that part of my
work can benefit from this. [I have some 'pure' OCaml code which will,
unfortunately, have to do without.]
Jacques C.
[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.8039
[2] http://research.microsoft.com/~simonpj/papers/parallel
prev parent reply other threads:[~2012-01-22 15:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 12:39 Mehdi Dogguy
2012-01-20 12:47 ` Yaron Minsky
2012-01-22 10:23 ` Xavier Leroy
2012-01-22 10:43 ` Jonathan Protzenko
2012-01-22 12:18 ` ivan chollet
2012-01-22 15:18 ` Jacques Carette [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=4F1C28B5.7020901@mcmaster.ca \
--to=carette@mcmaster.ca \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@inria.fr \
/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