Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David House <dhouse@janestreet.com>
To: Wojciech Meyer <wojciech.meyer@googlemail.com>
Cc: Chris Yocum <cyocum@gmail.com>, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Monad Library?
Date: Fri, 23 Nov 2012 12:09:09 +0000	[thread overview]
Message-ID: <CAK=fH+guU2z5TDedAU1AJJytcc2JjJN5tZrCMtF1VMCVn0msYw@mail.gmail.com> (raw)
In-Reply-To: <CAOg1smAyxJ4VnG2dBdsS8T3WRi70VoYirbjGLrf5q4pNbJb-1A@mail.gmail.com>

The Core library [1] has a good monad library that gets used in
basically every single Jane Street program (and notably inside async).
Among its features are:

* Module types for monads with one or two type parameters

* Functors to make modules satisfying those signatures given just bind + return

* "Infix" submodules which one can locally open ("let open
Option.Monad_infix in") in order to temporarily work inside another
monad -- very useful.

It notably does *not* feature a syntax extension to make monadic
computations look pretty. You must write out the binds and returns
yourself. To be honest, the reason for this is mostly history, but we
actually have some anecdotal evidence now that writing in the explicit
style makes things easier to understand for authors and readers of
code.

[1]: https://bitbucket.org/yminsky/ocaml-core/wiki/Home


On Fri, Nov 23, 2012 at 11:54 AM, Wojciech Meyer
<wojciech.meyer@googlemail.com> wrote:
> On Fri, Nov 23, 2012 at 11:43 AM, Chris Yocum <cyocum@gmail.com> wrote:
>> I was looking into using Monads in my programs but I am slightly at a
>> loss as to what library is in general use.  There is pa_monad but that
>
> pa_monad is really useful and nice, I think the updated library is
> available as pa_monad_custom OPAM package.
>
>> seems to be a ocamlp4 exention and not a library.  There is
>> http://lambda.jimpryor.net/monad_library/ but that doesn't seem to be
>> in opam or in godi so I am unsure as to its status.
>>
>> Does anyone have any suggestion for a well supported monad library for
>> Ocaml?
>
> First I would need to find an answer what do you mean by a monad library.
>
> Monads is a general abstraction with a very simple interface. so they
> don't require library as such.
>
> However I agree it would be good to have some library that provides a
> monadic interface to some common functionality found maybe in std
> libraries, also some way of composing monads would be good having
> monad transformers along. Batteries included offer monadic interface
> to some common data types like list, bool, option.
>
> You could look at Xavier Leroy's lectures here [1] to see the
> excellent examples of using monads in OCaml.
>
> For somewhat advanced type system trickery to use generic interface
> for monads you can look at this excellent post [2].
>
> -Wojciech
>
> [1] http://gallium.inria.fr/~xleroy/mpri/progfunc/monads.2up.pdf
> [2] http://alaska-kamtchatka.blogspot.co.uk/2011/09/higher-order-fun.html
> [3] http://batteries.forge.ocamlcore.org/
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

  parent reply	other threads:[~2012-11-23 12:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23 11:43 Chris Yocum
2012-11-23 11:54 ` Wojciech Meyer
2012-11-23 12:05   ` Chris Yocum
2012-11-23 12:09   ` David House [this message]
2012-11-23 12:09     ` David House
2012-11-23 20:59 ` Michał Kurcewicz
2012-11-24 16:34   ` Chris Yocum
2012-11-24 16:54     ` Malcolm Matalka
2012-11-24 17:04       ` Chris Yocum
2012-11-24 18:34     ` Gabriel Scherer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK=fH+guU2z5TDedAU1AJJytcc2JjJN5tZrCMtF1VMCVn0msYw@mail.gmail.com' \
    --to=dhouse@janestreet.com \
    --cc=caml-list@inria.fr \
    --cc=cyocum@gmail.com \
    --cc=wojciech.meyer@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox