I've expanded the tutorial a little. You can skip to "Another example"
for the new stuff. I go through the same exercise using the
probability monad.

http://intensivesystems.net/tutorials/why_monads.html

There are some corresponding additions to the sample code as well.

Jim

On Dec 23, 2:18 pm, Sean Devlin <francoisdev...@gmail.com> wrote:
> +1 ataggart, Chouser
>
> On Dec 23, 3:02 pm, ataggart <alex.tagg...@gmail.com> wrote:
>
> > I'd appreciate any added detail, since I had a similar reaction to
> > Chouser, thus wasn't really grokking the monad (wikipedia's
> > description is no more helpful).
>
> > On Dec 22, 2:10 pm, jim <jim.d...@gmail.com> wrote:
>
> > > Chouser,
>
> > > You're right that maybe-comp is simpler. Once you realize that the
> > > functions you want to compose are monadic functions under the maybe-m
> > > monad, you get that composition for 'free', with no further mental
> > > effort. With such a simple example, it's hard to see the benefit, but
> > > with more complicated monads the difference between the monad
> > > composition and ad-hoc style becomes greater. Where the ad-hoc version
> > > would have to be debugged, the monad version would already be proven
> > > to be correct.
>
> > > Beyond that, there are other things that you get 'for free' by using
> > > the monad functions. Don't have time to enumerate them now but might
> > > later.
>
> > > Jim
>
> > > On Dec 22, 3:14 pm, Chouser <chou...@gmail.com> wrote:
>
> > > > It's interesting to me that the definition of maybe-comp above is
> > > > arguably simpler that the definition of maybe-m, even without
> > > > counting the machinery of 'defmonad'.  Presumably this is a hint
> > > > to how much more powerful maybe-m is than maybe-comp, and simply
> > > > shows I don't yet understand the power of monads.
>
> > > > --Chouser
> > > > --
> > > > -- I funded Clojure 2010, did you?  http://clojure.org/funding

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to