diff options
author | Eduardo Julian | 2017-05-19 23:52:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-19 23:52:38 -0400 |
commit | a73037f8ab46e31196b1257d7621ceeacb1cad38 (patch) | |
tree | 08c708c5605d39068691ca03857f88de318a9ff2 /stdlib/source | |
parent | 1ee8b9338fc61c916fecfae1bc30430d5e3c3fe6 (diff) |
- Some refactoring in lux/control/exception.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/control/exception.lux | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index fc5cf9c64..222d2e094 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -1,7 +1,7 @@ (;module: {#;doc "Exception-handling functionality built on top of the Result type."} lux (lux (control monad) - (data [result #- fail] + (data ["R" result #- fail] [text]) [macro] (macro [code] @@ -26,34 +26,34 @@ (-> Exception (-> Text a) (Result a) (Result a))) (case try - (#;Right output) - (#;Right output) + (#R;Success output) + (#R;Success output) - (#;Left error) + (#R;Error error) (if (text;starts-with? (exception "") error) - (#;Right (then error)) - (#;Left error)))) + (#R;Success (then error)) + (#R;Error error)))) (def: #export (otherwise to-do try) {#;doc "If no handler could be found to catch the exception, then run a function as a last-resort measure."} (All [a] (-> (-> Text a) (Result a) a)) (case try - (#;Right output) + (#R;Success output) output - (#;Left error) + (#R;Error error) (to-do error))) (def: #export (return value) {#;doc "A way to lift normal values into the result-handling context."} (All [a] (-> a (Result a))) - (#;Right value)) + (#R;Success value)) (def: #export (throw exception message) {#;doc "Decorate an error message with an Exception and lift it into the result-handling context."} (All [a] (-> Exception Text (Result a))) - (#;Left (exception message))) + (#R;Error (exception message))) (syntax: #export (exception: [_ex-lev common;export-level] [name s;local-symbol]) {#;doc (doc "Define a new exception type." |