3 ms·
This release adds "binding operators," which make functors, applicatives, and monads more convenient to use. The "binding operators" are like OCaml's version of
by TheAsprngHacker 7y ago
This release adds "binding operators," which make functors, applicatives, and monads more convenient to use. The "binding operators" are like OCaml's version of Haskell's do-notation, but IMO even better. In Haskell's do-notation, each binding in the form of `pat <- expr; next` desugars to monadic bind, with an extension to use applicatives instead where possible, but with OCaml's binding operators, there are three separate operators for functors, applicatives, and monads.
The 4.08.0 release also adds the Fun, Option, and Result modules to the standard library.
- ilyagr 7y agoAre there any references for what these look like?
- mjn 7y agoThere's a new section of the manual covering them, here: http://caml.inria.fr/pub/docs/manual-ocaml/manual046.html http://caml.inria.fr/pub/docs/manual-ocaml/manual046.html A blog post with a more extensive set of examples: http://jobjo.github.io/2019/04/24/ocaml-has-some-new-shiny-syntax.html http://jobjo.github.io/2019/04/24/ocaml-has-some-new-shiny-s...
- ilyagr 7y agoPerfect, thanks!
- KirinDave 7y agoWhat's better? Is the idea that there are 3 separate operators better, or did the reason why not come through in the post?
- TheAsprngHacker 7y agoI meant that there being three separate operators makes OCaml's design better than Haskell's. (Of course, this is just my personal opinion.)
- KirinDave 7y agoWell, the reason I'm confused is that Haskell has different binding operators too. Applicatives can't use >>=.
- TheAsprngHacker 7y agoI meant Haskell's do-notation sugar - it only works for monads (or applicatives, assuming ApplicativeDo and absence of dependencies on intermediate results). OCaml's new "binding operators" let you define your own variations of `let` and `and`, which resemble do-notation and therefore have the same cognitive convenience. Then, you can define `let` for functors, etc. You can basically have `let` sugar for any operation that takes a function as the second argument.