On Friday, October 26, 2012 11:06:59 AM UTC-5, Brian Craft wrote:

> I've read about four tutorials on monads so far, but it still escapes me.
>
> In fact, I'm still not sure what problem it solves. I'm familiar with the 
> problem of having, say, three functions like f(a) -> b, g(c) -> d, h(e) -> 
> f, which you'd like to chain like f(g(h(x))), but you can't because b is a 
> different type from c and d is a different type from e. The monad tutorials 
> all start with a problem like this, but I still can't tell if they're 
> actually providing a solution, because it appears every monad is specific 
> to a particular type. E.g. a sequence monad. So, great, I have something 
> that takes a scalar and returns a sequence. That might solve g(h(x)) if f 
> is a scalar and c is a sequence by letting me write g(s(h(x))), but it 
> doesn't solve the whole problem, since I still have f() to worry about.
>
> <snip>
>


Brian, you may have looked at it already, but I found Konrad Hinsen's 
4-part tutorial linked from the README in Clojure's algo.monads repository 
to be quite helpful:

https://github.com/clojure/algo.monads

By the way, the links in that README to Jim Duey's tutorials are broken; 
here is the correct link to Part 1 of Jim's tutorials:

http://www.intensivesystems.net/tutorials/monads_101.html

I read Jim's tutorials first, and then tried Konrad's. I found the latter a 
bit more helpful. Also, Konrad's explanation of the state monad in Part 3 
really "clicked" with me, so I felt it was worth working through Parts 1 
and 2, even though I was still scratching my head a bit when I finished 
Part 2.

Jim also has a more recent set of blog posts dedicated to exploring monads:

http://www.clojure.net/archive.html

I worked from the bottom of that list to the top, after reading the other 
tutorials, and came away with a basic but sound understanding of the core 
concepts:  m-result, m-bind, the Monad Laws, etc.

Also note that Jim has developed a new monads library for Clojure, 
implemented with protocols:

https://github.com/jduey/protocol-monads

Working through that library's test suite seems like a good way improve 
one's understanding of monads; also, I'm going to try to "port" the 
examples from algo.monads over to protocol-monads. I haven't done that yet, 
but when I do you will be able to find them in my fork of protocol-monads 
(if things go well, I'll submit a pull request):

https://github.com/michaelsbradleyjr/protocol-monads/blob/examples/src/examples/monads.clj

The original examples for algo.monads:

https://github.com/clojure/algo.monads/blob/master/src/examples/clojure/examples/monads.clj

-- 
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