Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found some really good monads resources:</p> <ul> <li><a href="http://www.clojure.net/tags.html#monads-ref" rel="nofollow">http://www.clojure.net/tags.html#monads-ref</a> (Jim Duey's Monads Guide, which really goes into the nitty gritty monad definitions)</li> <li><a href="http://homepages.inf.ed.ac.uk/wadler/topics/monads.html#marktoberdorf" rel="nofollow">http://homepages.inf.ed.ac.uk/wadler/topics/monads.html#marktoberdorf</a> (A whole load of papers on monads)</li> <li><a href="http://vimeo.com/17207564" rel="nofollow">http://vimeo.com/17207564</a> (A talk on category theory, which I half followed)</li> </ul> <p>So from Jim's Guide - <a href="http://www.clojure.net/2012/02/06/Legalities/" rel="nofollow">http://www.clojure.net/2012/02/06/Legalities/</a> - he gives three axioms for definition of 'bind-m' and 'reduce-m' functions:</p> <blockquote> <p><strong>Identity</strong> The first Monad Law can be written as</p> <p><em>(m-bind (m-result x) f) is equal to (f x)</em></p> <p>What this means is that whatever m-result does to x to make it into a monadic value, m-bind undoes before applying f to x. So with regards to m-bind, m-result is sort of like an identity function. Or in category theory terminology, its unit. Which is why sometimes you’ll see it named ‘unit’.</p> <p><strong>Reverse Identity</strong> The second Monad Law can be written as</p> <p><em>(m-bind mv m-result) is equal to mv where mv is a monadic value.</em> </p> <p>This law is something like a complement to the first law. It basically ensures that m-result is a monadic function and that whatever m-bind does to a monadic value to extract a value, m-result undoes to create a monadic value.</p> <p><strong>Associativity</strong> The third Monad Law can be written as</p> <p><em>(m-bind (m-bind mv f) g) is equal to (m-bind mv (fn [x] (m-bind (f x) g))) where f and g are monadic functions and mv is a monadic value.</em></p> <p>What this law is saying is that it doesnt matter whether the f is applied to mv and then g is applied to the result, or whether a new monadic function is created out of a composition of f and g which is then applied to mv. In either order, the resulting value is the same monadic value. Stated another way, m-bind is left and right associative.</p> </blockquote> <p>In <a href="http://www.clojure.net/2012/02/04/Sets-not-lists/" rel="nofollow">http://www.clojure.net/2012/02/04/Sets-not-lists/</a> he gives an monad that takes sets as inputs instead of taking lists. Will work through all the examples...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload