Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been using Clojure for two years now and the only time I ever used monads was as an exercise to show that it could be done. I've never needed them for "real" code.</p> <p>Monads are much more common in Haskell because:</p> <ul> <li>They are the idiomatic way of handling stateful computations. In Clojure, you typically handle state with <a href="http://clojure.org/refs" rel="noreferrer">managed references</a>, so monads aren't needed nearly as much in Clojure. </li> <li>Likewise for IO: Clojure allows you to do IO directly without declaring it in your type, so you don't need the IO monad.</li> </ul> <p>My suggestion would be to focus on standard functional programming in Clojure. Unless you see that you really <em>need</em> monads then I wouldn't invest too much time in trying to bring them in.</p> <p>Macros are a slightly different issue: they are for compile-time code generation and extensions to the language syntax (which might include DSLs, although DSLs don't necessarily need macros). I use macros when both of the following are true:</p> <ol> <li>I want to extend the language syntax in a way that significantly improves my ability to address a particular problem domain. </li> <li>I <em>can't</em> get the same functionality with normal functions / function composition. Normal functions should be your first choice if possible: they are usually simpler to write and maintain.</li> </ol> <p>P.S. If you are genuinely interested in monads for Clojure, here are two videos I personally found quite good:</p> <ul> <li><a href="http://vimeo.com/20717301" rel="noreferrer">http://vimeo.com/20717301</a> (Brian Marick's excellent visual explanation of monads)</li> <li><a href="http://www.infoq.com/presentations/Monads-Made-Easy" rel="noreferrer">http://www.infoq.com/presentations/Monads-Made-Easy</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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