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

(documentation: (/.Region r ! it)
  (format "A region where resources may be be claimed and where a side-effecting computation may be performed."
          \n "Every resource is paired with a function that knows how to clean/reclaim it, to make sure there are no leaks."))

(documentation: /.run!
  "Executes a region-based computation, with a side-effect determined by the monad."
  [(run! monad computation)])

(documentation: /.acquire!
  "Acquire a resource while pairing it a function that knows how to reclaim it."
  [(acquire! monad cleaner value)])

(documentation: /.failure
  "Immediately fail with this 'message'."
  [(failure monad error)])

(documentation: /.except
  "Fail by throwing/raising an exception."
  [(except monad exception message)])

(documentation: /.lifted
  "Lift an effectful computation into a region-based computation."
  [(lifted monad operation)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Region
             ..run!
             ..acquire!
             ..failure
             ..except
             ..lifted
             ($.default /.clean_up_error)
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            []))
