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
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs