diff options
Diffstat (limited to 'stdlib/source/library/lux/type/check.lux')
-rw-r--r-- | stdlib/source/library/lux/type/check.lux | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 0b47df0ab..352c5f3df 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -23,42 +23,42 @@ ["." // ("#\." equivalence)]) (template: (!n\= reference subject) - ("lux i64 =" reference subject)) + [("lux i64 =" reference subject)]) (template: (!text\= reference subject) - ("lux text =" reference subject)) + [("lux text =" reference subject)]) -(exception: #export (unknown_type_var {id Nat}) +(exception: .public (unknown_type_var {id Nat}) (exception.report ["ID" (n\encode id)])) -(exception: #export (unbound_type_var {id Nat}) +(exception: .public (unbound_type_var {id Nat}) (exception.report ["ID" (n\encode id)])) -(exception: #export (invalid_type_application {funcT Type} {argT Type}) +(exception: .public (invalid_type_application {funcT Type} {argT Type}) (exception.report ["Type function" (//.format funcT)] ["Type argument" (//.format argT)])) -(exception: #export (cannot_rebind_var {id Nat} {type Type} {bound Type}) +(exception: .public (cannot_rebind_var {id Nat} {type Type} {bound Type}) (exception.report ["Var" (n\encode id)] ["Wanted Type" (//.format type)] ["Current Type" (//.format bound)])) -(exception: #export (type_check_failed {expected Type} {actual Type}) +(exception: .public (type_check_failed {expected Type} {actual Type}) (exception.report ["Expected" (//.format expected)] ["Actual" (//.format actual)])) -(type: #export Var +(type: .public Var Nat) (type: Assumption [Type Type]) -(type: #export (Check a) +(type: .public (Check a) (-> Type_Context (Try [Type_Context a]))) (type: (Checker a) @@ -67,7 +67,7 @@ (type: Type_Vars (List [Var (Maybe Type)])) -(implementation: #export functor +(implementation: .public functor (Functor Check) (def: (map f fa) @@ -79,7 +79,7 @@ (#try.Failure error) (#try.Failure error))))) -(implementation: #export apply +(implementation: .public apply (Apply Check) (def: &functor ..functor) @@ -100,7 +100,7 @@ ))) ) -(implementation: #export monad +(implementation: .public monad (Monad Check) (def: &functor ..functor) @@ -157,7 +157,7 @@ (#.Item [var_id var_type] (var::put id value plist'))))) -(def: #export (run context proc) +(def: .public (run context proc) (All [a] (-> Type_Context (Check a) (Try a))) (case (proc context) (#try.Success [context' output]) @@ -166,23 +166,23 @@ (#try.Failure error) (#try.Failure error))) -(def: #export (failure message) +(def: .public (failure message) (All [a] (-> Text (Check a))) (function (_ context) (#try.Failure message))) -(def: #export (assertion message test) +(def: .public (assertion message test) (-> Text Bit (Check Any)) (function (_ context) (if test (#try.Success [context []]) (#try.Failure message)))) -(def: #export (except exception message) +(def: .public (except exception message) (All [e a] (-> (Exception e) e (Check a))) (..failure (exception.error exception message))) -(def: #export existential +(def: .public existential {#.doc "A producer of existential types."} (Check [Nat Type]) (function (_ context) @@ -191,7 +191,7 @@ [id (#.Ex id)]])))) (template [<name> <outputT> <fail> <succeed>] - [(def: #export (<name> id) + [(def: .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) (case (|> context (get@ #.var_bindings) (var::get id)) @@ -209,7 +209,7 @@ [read (Maybe Type) #.None (#.Some bound)] ) -(def: #export (read! id) +(def: .public (read! id) (-> Var (Check Type)) (do ..monad [?type (read id)] @@ -233,7 +233,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: #export (bind type id) +(def: .public (bind type id) (-> Type Var (Check Any)) (function (_ context) (case (|> context (get@ #.var_bindings) (var::get id)) @@ -258,7 +258,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: #export var +(def: .public var (Check [Var Type]) (function (_ context) (let [id (get@ #.var_counter context)] @@ -323,7 +323,7 @@ #.None (exception.except ..unknown_type_var current))))) -(def: #export fresh_context +(def: .public fresh_context Type_Context {#.var_counter 0 #.ex_counter 0 @@ -664,12 +664,12 @@ _ ..silent_failure!)))) -(def: #export (check expected actual) +(def: .public (check expected actual) {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."} (-> Type Type (Check Any)) (check' (list) expected actual)) -(def: #export (checks? expected actual) +(def: .public (checks? expected actual) {#.doc "A simple type-checking function that just returns a yes/no answer."} (-> Type Type Bit) (case (..run ..fresh_context (..check' (list) expected actual)) @@ -679,12 +679,12 @@ (#try.Success _) true)) -(def: #export context +(def: .public context (Check Type_Context) (function (_ context) (#try.Success [context context]))) -(def: #export (clean inputT) +(def: .public (clean inputT) (-> Type (Check Type)) (case inputT (#.Primitive name paramsT+) |