(.using
  [library
   [lux {"-" and}
    ["$" documentation {"+" documentation:}]
    [control
     ["<>" parser
      ["<[0]>" code]]]
    [data
     ["[0]" text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]])

(documentation: /.Var
  "The ID for a type-variable in a type-checking context.")

(documentation: (/.Check it)
  "A type-checking computation which may fail or yield a value.")

(documentation: /.result
  ""
  [(result context proc)])

(documentation: /.failure
  ""
  [(failure message)])

(documentation: /.assertion
  ""
  [(assertion message test)])

(documentation: /.except
  ""
  [(except exception message)])

(documentation: /.existential
  "A brand-new existential type.")

(documentation: /.bind
  (format "Attemmpts to buy a type-variable."
          \n "Fails if the variable has been bound already.")
  [(bind type id)])

(documentation: /.var
  "A brand-new (unbound) type-variable.")

(documentation: /.fresh_context
  "An empty/un-used type-checking context.")

(documentation: /.check
  "Type-check to ensure that the 'expected' type subsumes the 'actual' type."
  [(check expected actual)])

(documentation: /.subsumes?
  "A simple type-checking function that just returns a yes/no answer."
  [(subsumes? expected actual)])

(documentation: /.context
  "The current state of the type-checking context.")

(documentation: /.clean
  "Resolves every bound type-variable to yield a new type that is as resolved as possible."
  [(clean inputT)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            "Type-checking functionality."
            [..Var
             ..Check
             ..result
             ..failure
             ..assertion
             ..except
             ..existential
             ..bind
             ..var
             ..fresh_context
             ..check
             ..subsumes?
             ..context
             ..clean
             ($.default /.unknown_type_var)
             ($.default /.unbound_type_var)
             ($.default /.invalid_type_application)
             ($.default /.cannot_rebind_var)
             ($.default /.type_check_failed)
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)
             ($.default /.bound?)
             ($.default /.peek)
             ($.default /.read)]
            []))
