1.2.0 permalink Arrow_down_16x16
  • (sequence-t m)
  • (sequence-t m which-m-plus)
Monad transformer that transforms a monad m into a monad in which
the base values are sequences. The argument which-m-plus chooses
if m-zero and m-plus are inherited from the base monad
(use :m-plus-from-base) or adopt sequence-like
behaviour (use :m-plus-from-transformer). The default is :m-plus-from-base
if the base monad m has a definition for m-plus, and
:m-plus-from-transformer otherwise.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/monads.clj:528 top

(defn sequence-t
  "Monad transformer that transforms a monad m into a monad in which
   the base values are sequences. The argument which-m-plus chooses
   if m-zero and m-plus are inherited from the base monad
   (use :m-plus-from-base) or adopt sequence-like
   behaviour (use :m-plus-from-transformer). The default is :m-plus-from-base
   if the base monad m has a definition for m-plus, and
   :m-plus-from-transformer otherwise."
  ([m] (sequence-t m :m-plus-default))
  ([m which-m-plus]
   (monad-transformer m which-m-plus
     [m-result (with-monad m
	         (fn m-result-sequence-t [v]
		   (m-result (list v))))
      m-bind   (with-monad m
		 (fn m-bind-sequence-t [mv f]
		   (m-bind mv
			   (fn [xs]
			     (m-fmap flatten*
				     (m-map f xs))))))
      m-zero   (with-monad m (m-result (list)))
      m-plus   (with-monad m
                 (fn m-plus-sequence-t [& mvs]
		   (m-reduce concat (list) mvs)))
      ])))
Vars in clojure.contrib.monads/sequence-t: defn
Used in 0 other vars

Comments top

No comments for sequence-t. Log in to add a comment.