(.using
  [library
   [lux
    ["$" documentation {"+" documentation:}]
    [data
     [text {"+" \n}
      ["%" format {"+" format}]]]]]
  [\\library
   ["[0]" /]]
  ["[0]" / "_"
   ["[1][0]" free]])

(documentation: (/.Monad it)
  (format "A monad is a monoid in the category of endofunctors."
          \n "What's the problem?"))

(documentation: /.do
  "Macro for easy concatenation of monadic operations."
  [(do monad
     [y (f1 x)
      z (f2 z)]
     (in (f3 z)))])

(documentation: /.then
  "Apply a function with monadic effects to a monadic value and yield a new monadic value."
  [(then monad function)])

(documentation: /.all
  "Run all the monadic values in the list and produce a list of the base values."
  [(all monad)])

(documentation: /.each
  "Apply a monadic function to all values in a list."
  [(each monad function items)])

(documentation: /.only
  "Filter the values in a list with a monadic function."
  [(only monad predicate items)])

(documentation: /.mix
  "Mix a list with a monadic function."
  [(mix monad function initial_value items)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Monad
             ..do
             ..then
             ..all
             ..each
             ..only
             ..mix]
            [/free.documentation]))
