Hi,
what would be the preferred/community blessed approach to write DSLs with OCaml?
Is something like F#s Computation Expressions possible?
Thanks
Robertj
Hi,
what would be the preferred/community blessed approach to write DSLs with OCaml?
Is something like F#s Computation Expressions possible?
Thanks
Robertj
Special syntax for monadic and applicative operations was recently added and will be part of the 4.08 release:
The latest version of Dune back-ports this syntax to earlier versions of OCaml:
https://dune.readthedocs.io/en/latest/dune-files.html#future-syntax
A popular approach that also works with existing versions of OCaml is a preprocessor called ppx_let
:
Apart from that, using plain (>>=)
and return
is popular and is a fine approach too.
Any of these are adequate, and library authors can use any of them, while the users can make a one-or-two line aliases to make it work for their preferred approach.
My guess is that over time the new syntax will be the preferred approach, while (>>=)
will still be used.