diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/control/exception.lux | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 81e46e66d..f80419c98 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -31,11 +31,11 @@ [#label Text #constructor (-> a Text)])) -(def: .public (match? exception error) +(def .public (match? exception error) (All (_ e) (-> (Exception e) Text Bit)) (text.starts_with? (the #label exception) error)) -(def: .public (when exception then try) +(def .public (when exception then try) (All (_ e a) (-> (Exception e) (-> Text a) (Try a) (Try a))) @@ -52,7 +52,7 @@ then)} {//.#Failure error})))) -(def: .public (otherwise else try) +(def .public (otherwise else try) (All (_ a) (-> (-> Text a) (Try a) a)) (case try @@ -62,21 +62,21 @@ {//.#Failure error} (else error))) -(def: .public (error exception message) +(def .public (error exception message) (All (_ e) (-> (Exception e) e Text)) ((the ..#constructor exception) message)) -(def: .public (except exception message) +(def .public (except exception message) (All (_ e a) (-> (Exception e) e (Try a))) {//.#Failure (..error exception message)}) -(def: .public (assertion exception message test) +(def .public (assertion exception message test) (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test {//.#Success []} (..except exception message))) -(def: exception +(def exception (Parser [Code (List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (let [private (is (Parser [(List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (all <>.and @@ -90,14 +90,14 @@ (<>.and (<>#in (` .private)) private) ))) -(def: .public exception: +(def .public exception: (syntax (_ [[export_policy t_vars [name inputs] body] ..exception]) (macro.with_symbols [g!_ g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor (all text#composite "{" current_module "." name "}" text.new_line) g!self (code.local name)]] - (in (list (` (def: (~ export_policy) + (in (list (` (def (~ export_policy) (~ g!self) (All ((~ g!_) (~+ (list#each |type_variable|.format t_vars))) (..Exception [(~+ (list#each (the |input|.#type) inputs))])) @@ -107,7 +107,7 @@ ((~! text#composite) (~ g!descriptor) (~ (maybe.else (' "") body))))]))))))))) -(def: (report' entries) +(def (report' entries) (-> (List [Text Text]) Text) (let [header_separator ": " largest_header_size (list#mix (function (_ [header _] max) @@ -138,13 +138,13 @@ (on_entry head) tail)))) -(def: .public report +(def .public report (syntax (_ [entries (<>.many (<>.and <code>.any <code>.any))]) (in (list (` ((~! ..report') (list (~+ (|> entries (list#each (function (_ [header message]) (` [(~ header) (~ message)])))))))))))) -(def: .public (listing format entries) +(def .public (listing format entries) (All (_ a) (-> (-> a Text) (List a) Text)) (|> entries @@ -157,7 +157,7 @@ list.reversed ..report')) -(def: separator +(def separator (let [gap (all "lux text concat" text.new_line text.new_line) horizontal_line (|> "-" (list.repeated 64) text.together)] (all "lux text concat" @@ -165,14 +165,14 @@ horizontal_line gap))) -(def: (decorated prelude error) +(def (decorated prelude error) (-> Text Text Text) (all "lux text concat" prelude ..separator error)) -(def: .public (with exception message computation) +(def .public (with exception message computation) (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation {//.#Failure error} |