Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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?

with Oleg Kiselyov, we are working on a better version of the monadic do 
syntax for Ocaml (the original message 
did not come through on the arhive, see 
for the same email but with the attachment intact. 
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 

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?