(.using
  [library
   [lux {"-" local}
    ["$" documentation {"+" documentation:}]
    [data
     [text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]])

(documentation: (/.State state it)
  "Stateful computations.")

(documentation: /.get
  "Read the current state.")

(documentation: /.put
  "Set the new state."
  [(put new_state)])

(documentation: /.update
  "Compute the new state."
  [(update change)])

(documentation: /.use
  "Run a function on the current state."
  [(use user)])

(documentation: /.local
  "Run the computation with a locally-modified state."
  [(local change action)])

(documentation: /.result
  "Run a stateful computation."
  [(result state action)])

(documentation: /.while
  "A stateful while loop."
  [(while condition body)])

(documentation: /.do_while
  "A stateful do-while loop."
  [(do_while condition body)])

(documentation: /.+State
  "Stateful computations decorated by a monad.")

(documentation: /.result'
  "Execute a stateful computation decorated by a monad."
  [(result' state action)])

(documentation: /.with
  "A monad transformer to create composite stateful computations."
  [(with monad)])

(documentation: /.lifted
  "Lift monadic values to the +State wrapper."
  [(lifted monad ma)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..State
             ..get
             ..put
             ..update
             ..use
             ..local
             ..result
             ..while
             ..do_while
             ..+State
             ..result'
             ..with
             ..lifted
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            []))
