diff options
Diffstat (limited to 'stdlib/source/lux/control/exception.lux')
-rw-r--r-- | stdlib/source/lux/control/exception.lux | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 85236b6fa..53b770bcd 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -73,7 +73,7 @@ (def: #export (throw exception message) {#.doc "Decorate an error message with an Exception and lift it into the error-handling context."} - (All [e] (-> (Exception e) e Try)) + (All [e a] (-> (Exception e) e (Try a))) (#//.Failure (construct exception message))) (def: #export (assert exception message test) @@ -114,7 +114,7 @@ (def: header-separator ": ") -(def: #export (report' entries) +(def: (report' entries) (-> (List [Text Text]) Text) (let [largest-header-size (|> entries (list@map (|>> product.left text.size)) @@ -136,15 +136,17 @@ (text.join-with text.new-line)))) (syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) - (wrap (list (` (report' (list (~+ (|> entries - (list@map (function (_ [header message]) - (` [(~ header) (~ message)]))))))))))) + (wrap (list (` ((~! report') (list (~+ (|> entries + (list@map (function (_ [header message]) + (` [(~ header) (~ message)]))))))))))) (def: separator - ($_ "lux text concat" - text.new-line text.new-line - (|> "-" (list.repeat 64) (text.join-with "")) - text.new-line text.new-line)) + (let [gap ($_ "lux text concat" text.new-line text.new-line) + horizontal-line (|> "-" (list.repeat 64) (text.join-with ""))] + ($_ "lux text concat" + gap + horizontal-line + gap))) (def: (decorate prelude error) (-> Text Text Text) @@ -167,11 +169,11 @@ success success)) -(def: #export (enumerate %entry) +(def: #export (enumerate format) (All [a] (-> (-> a Text) (-> (List a) Text))) (|>> list.enumerate (list@map (function (_ [index entry]) - ($_ text@compose (n@encode index) ": " (%entry entry)))) + ($_ text@compose (n@encode index) ": " (format entry)))) (text.join-with text.new-line))) |