Yeah, I was thinking again after sending it that this isn't really needed when you have functional updates and other ways of managing state. Chris On Sat, Nov 24, 2012 at 11:54:48AM -0500, Malcolm Matalka wrote: > I haven't experienced a strong need for a state monad in Ocaml. I do > tend to use Core's Option and Return (>>=) functions for sequencing code > though. > > /M > > P.S. In general Ocamler's seem to prefer to write 'Store x' rather than > 'Store(x)' > > > Chris Yocum writes: > > > Thanks everyone, > > > > So basically from what I understand this is kind of like a StateMonad. > > It seems to me that the state monad (hiding state in the type system) > > would be a large boon. > > > > So, for instance, > > > > module type MONAD = > > sig > > type 'a t > > val return : 'a -> 'a t > > val bind : 'a t -> ('a -> 'b t) -> 'b t > > end > > > > module StateMonad : MONAD = > > struct > > type 'a t = Store of 'a > > let return x = Store(x) > > let bind s f = > > match s with > > | Store(x) -> f x > > let access = function Store(x) -> x > > end > > > > This is a very, very basic implementation of a state monad? > > > > Thanks again. > > > > Chris > > > > On Fri, Nov 23, 2012 at 09:59:30PM +0100, MichaƂ Kurcewicz wrote: > >> If Core is too complex for you then you may take a look at spotlib - a > >> small and elegant library written by Jun Furuse: > >> > >> https://bitbucket.org/camlspotter/spotlib > >> > >> I use it together with pa_monad_custom for all my monad needs. > >> > >> Best, > >> > >> --mk > >> > >> On Fri, Nov 23, 2012 at 12:43 PM, Chris Yocum wrote: > >> > Hi, > >> > > >> > 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 > >> > 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? > >> > > >> > All the best, > >> > Chris