On Fri, Nov 23, 2012 at 11:54:40AM +0000, Wojciech Meyer wrote: > On Fri, Nov 23, 2012 at 11:43 AM, Chris Yocum 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. > Yeah, I saw that. I will install it and have a look. > > 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. > Ok, I had only seen the Monad module in batteries. Also, I tend not to like batteries as it bloats the executable size; I get something like a 5MB executable for a small amount of code. In general, what I would like in a "monad library" would be a collection of "standard monads". I am using scarequotes because I don't know what all of this means. Looking at the Haskell Wiki (http://www.haskell.org/haskellwiki/Monad#Common_monads) lists the common monads as "Maybe, List, State, Reader, and IO". I would assume that a monad library would have these and a method for building new ones. > 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]. Great. Thanks for the info! Chris > > -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/