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

(documentation: (/.Try it)
  "A computation that can fail with an error message.")

(documentation: /.with
  "Enhances a monad with error-handling functionality."
  [(with monad)])

(documentation: /.lifted
  "Wraps a monadic value with error-handling machinery."
  [(lifted monad)])

(documentation: /.trusted
  (format "Assumes a Try value succeeded, and yields its value."
          \n "If it didn't, raises the error as a runtime error."
          \n "WARNING: Use with caution.")
  [(trusted try)])

(documentation: /.maybe
  ""
  [(maybe try)])

(documentation: /.of_maybe
  ""
  [(of_maybe maybe)])

(documentation: /.else
  (format "Allows you to provide a default value that will be used"
          \n "if a (Try x) value turns out to be #Failure."
          \n "Note: the expression for the default value will not be computed if the base computation succeeds.")
  [(= "bar"
      (else "foo" {/.#Success "bar"}))]
  [(= "foo"
      (else "foo" {/.#Failure "KABOOM!"}))])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Try
             ..with
             ..lifted
             ..trusted
             ..maybe
             ..of_maybe
             ..else
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)
             ($.default /.equivalence)]
            []))
