Version française
Home     About     Download     Resources     Contact us    
Browse thread
Which syntax is more ocaml-like?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Carette <carette@m...>
Subject: Which syntax is more ocaml-like?
Hello,

with Oleg Kiselyov, we are working on a better version of the monadic do 
syntax for Ocaml (the original message 
http://caml.inria.fr/pub/ml-archives/caml-list/2005/03/87cab0cdbbcfcf736b85d746ba610e78.en.html 
did not come through on the arhive, see 
https://mailman.rice.edu/pipermail/metaocaml-users-l/2005-March/000056.html 
for the same email but with the attachment intact.  
http://caml.inria.fr/pub/ml-archives/caml-list/2005/05/e85edd2308a0e58a7b0761962bc440c6.en.html 
is also relevant).  In particular, we want to handle multiple monads.  
Variations on two different themes have come up as possibilities:
1) doM Foo { ... }
2) doM with Foo in ...
   (where the 'with' could be dropped altogether).
For example if the ... above was a <- m; return a
then both of these would expand to
Foo.bind m (fun a -> return a)

The reason to use a module (with just one export) is for future 
extensibility, where we may want to require more functions of the Monad 
implementation; also, as has been demonstrated here and there, there are 
nice morphisms between ML-stype modules/functors and Haskell-stype type 
classes.

There could also be a special case with no Foo at all, which would then 
use the bind function in the current scope (if any).

Which of 1) or 2) above is more Ocaml-like?  Other comments?

Jacques