diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/control/exception.lux | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 53b770bcd..211976aa2 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -1,4 +1,4 @@ -(.module: {#.doc "Exception-handling functionality built on top of the Error type."} +(.module: {#.doc "Exception-handling functionality."} [lux #* [abstract [monad (#+ do)]] @@ -88,13 +88,13 @@ (s.form (p.and s.local-identifier (p.some scr.typed-input))))} {body (p.maybe s.any)}) {#.doc (doc "Define a new exception type." - "It moslty just serves as a way to tag error messages for later catching." + "It mostly just serves as a way to tag error messages for later catching." "" "Simple case:" (exception: #export some-exception) "" "Complex case:" - (exception: #export [optional type-vars] (some-exception [optional Text] {arguments Int}) + (exception: #export [optional type variables] (some-exception {optional Text} {arguments Int}) optional-body))} (macro.with-gensyms [g!descriptor] (do @ @@ -112,13 +112,13 @@ (~ (maybe.default (' "") body))))}))))) ))) -(def: header-separator ": ") - (def: (report' entries) (-> (List [Text Text]) Text) - (let [largest-header-size (|> entries - (list@map (|>> product.left text.size)) - (list@fold n.max 0)) + (let [header-separator ": " + largest-header-size (list@fold (function (_ [header _] max) + (n.max (text.size header) max)) + 0 + entries) on-new-line (|> " " (list.repeat (n.+ (text.size header-separator) largest-header-size)) @@ -132,7 +132,7 @@ (text.join-with ""))] (|> message (text.replace-all text.new-line on-new-line) - ($_ text@compose padding header ..header-separator))))) + ($_ text@compose padding header header-separator))))) (text.join-with text.new-line)))) (syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) @@ -140,6 +140,15 @@ (list@map (function (_ [header message]) (` [(~ header) (~ message)]))))))))))) +(def: #export (enumerate format entries) + (All [a] + (-> (-> a Text) (List a) Text)) + (|> entries + list.enumerate + (list@map (function (_ [index entry]) + [(n@encode index) (format entry)])) + report')) + (def: separator (let [gap ($_ "lux text concat" text.new-line text.new-line) horizontal-line (|> "-" (list.repeat 64) (text.join-with ""))] @@ -168,12 +177,3 @@ success success)) - -(def: #export (enumerate format) - (All [a] - (-> (-> a Text) - (-> (List a) Text))) - (|>> list.enumerate - (list@map (function (_ [index entry]) - ($_ text@compose (n@encode index) ": " (format entry)))) - (text.join-with text.new-line))) |