From: Malcolm Matalka <mmatalka@gmail.com>
To: Chris Yocum <cyocum@gmail.com>
Cc: "Michał Kurcewicz" <michal.kurcewicz@gmail.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Monad Library?
Date: Sat, 24 Nov 2012 11:54:48 -0500 [thread overview]
Message-ID: <87lidrym93.fsf@li195-236.members.linode.com> (raw)
In-Reply-To: <20121124163405.GA2158@gmail.com> (Chris Yocum's message of "Sat, 24 Nov 2012 16:34:06 +0000")
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 <cyocum@gmail.com> 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 <cyocum@gmail.com> 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
next prev parent reply other threads:[~2012-11-24 16:54 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
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 [this message]
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=87lidrym93.fsf@li195-236.members.linode.com \
--to=mmatalka@gmail.com \
--cc=caml-list@inria.fr \
--cc=cyocum@gmail.com \
--cc=michal.kurcewicz@gmail.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