They provide elegant solutions to a great many problems, some quite simple. Here's how I would compute subobjects (subseqs, subsets), partitions and permutations monadically:
(def true-or-false (constantly (either true false))) ;; computes subseqs in the seq monad and subsets in the set monad (defn subs [s] (m-filter true-or-false s))) (defn partitions [s] (m-partition-by true-or-false s)) (def permutations [s] (when (seq s) (>> (permutations (rest s)) [[left right] (m-split-with true-or-false %)] (concat left [(first s)] right)))) You could respond that most of the heavy lifting is done by the monadic transliterations of commonplace seq functions like filter, partition-by and split-with. You would be right; that is the whole point. Anyway, you certainly don't need to know any of this stuff to code Clojure, and I do agree that is a strength of the language compared to, say, Haskell. -Per On Thu, Mar 18, 2010 at 3:13 AM, David Nolen <dnolen.li...@gmail.com> wrote: > On Wed, Mar 17, 2010 at 4:09 PM, Konrad Hinsen <konrad.hin...@fastmail.net> > wrote: >> >> On 17 Mar 2010, at 20:54, David Nolen wrote: >> >>> But seriously, in my personal opinion Monads are relatively useless in >>> the context of Clojure. >> >> I'd say that in any impure functional language, monads are useful in the >> context of specific applications or algorithmic approaches. When working >> with continuations, or when writing complex parsers, monads are useful. It's >> just Haskell that has a language-specific relation to monads, because it >> needs them for fundamental tasks such as I/O. > > James, and Konrad sorry if I sounded overly dismissive of Monads ;) Yes for > parsers, continuations, other tricky problems they provide a very elegant > solution. > > David > > -- > 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 -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.