diff options
author | Eduardo Julian | 2017-10-16 19:28:04 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-16 19:28:04 -0400 |
commit | fecfb6c1dd653e491e541233395ea4a7d8ae7409 (patch) | |
tree | 1083a8cbe6f8277a75fc7813f9a403a4db9e5732 /stdlib/source/lux/macro | |
parent | b2b8a0ffda0661511d8aec5634aad314b1e6c710 (diff) |
- Re-named "Result" type back to "Error".
Diffstat (limited to 'stdlib/source/lux/macro')
-rw-r--r-- | stdlib/source/lux/macro/poly.lux | 54 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly/json.lux | 6 | ||||
-rw-r--r-- | stdlib/source/lux/macro/syntax.lux | 74 |
3 files changed, 67 insertions, 67 deletions
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index d744a28f7..fc6c7120f 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -12,7 +12,7 @@ [bool] [maybe] [ident "ident/" Eq<Ident> Codec<Text,Ident>] - ["R" result]) + ["E" error]) [macro #+ with-gensyms] (macro [code] ["s" syntax #+ syntax: Syntax] @@ -31,70 +31,70 @@ (def: #export fresh Env (dict;new number;Hash<Nat>)) (def: (run' env types poly) - (All [a] (-> Env (List Type) (Poly a) (R;Result a))) + (All [a] (-> Env (List Type) (Poly a) (E;Error a))) (case (p;run [env types] poly) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success [[env' remaining] output]) + (#E;Success [[env' remaining] output]) (case remaining #;Nil - (#R;Success output) + (#E;Success output) _ - (#R;Error (|> remaining + (#E;Error (|> remaining (list/map type;to-text) (text;join-with ", ") (text/compose "Unconsumed types: ")))))) (def: #export (run type poly) - (All [a] (-> Type (Poly a) (R;Result a))) + (All [a] (-> Type (Poly a) (E;Error a))) (run' fresh (list type) poly)) (def: #export env (Poly Env) (;function [[env inputs]] - (#R;Success [[env inputs] env]))) + (#E;Success [[env inputs] env]))) (def: (with-env temp poly) (All [a] (-> Env (Poly a) (Poly a))) (;function [[env inputs]] (case (p;run [temp inputs] poly) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success [[_ remaining] output]) - (#R;Success [[env remaining] output])))) + (#E;Success [[_ remaining] output]) + (#E;Success [[env remaining] output])))) (def: #export peek (Poly Type) (;function [[env inputs]] (case inputs #;Nil - (#R;Error "Empty stream of types.") + (#E;Error "Empty stream of types.") (#;Cons headT tail) - (#R;Success [[env inputs] headT])))) + (#E;Success [[env inputs] headT])))) (def: #export any (Poly Type) (;function [[env inputs]] (case inputs #;Nil - (#R;Error "Empty stream of types.") + (#E;Error "Empty stream of types.") (#;Cons headT tail) - (#R;Success [[env tail] headT])))) + (#E;Success [[env tail] headT])))) (def: #export (local types poly) (All [a] (-> (List Type) (Poly a) (Poly a))) (;function [[env pass-through]] (case (run' env types poly) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success output) - (#R;Success [[env pass-through] output])))) + (#E;Success output) + (#E;Success [[env pass-through] output])))) (def: (label idx) (-> Nat Code) @@ -108,11 +108,11 @@ (case (p;run [(dict;put current-id [type g!var] env) inputs] poly) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success [[_ inputs'] output]) - (#R;Success [[env inputs'] [g!var output]]))))) + (#E;Success [[_ inputs'] output]) + (#E;Success [[env inputs'] [g!var output]]))))) (do-template [<combinator> <name> <type>] [(def: #export <combinator> @@ -149,10 +149,10 @@ deg frac text)) - (#R;Error error) + (#E;Error error) (p;fail error) - (#R;Success _) + (#E;Success _) (wrap headT)))) (do-template [<name> <flattener> <tag>] diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index 1c3510b85..1b66e39f5 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -10,7 +10,7 @@ (text ["l" lexer]) [number "frac/" Codec<Text,Frac> "nat/" Codec<Text,Nat>] maybe - ["R" result] + ["E" error] [sum] [product] (coll [list "list/" Fold<List> Monad<List>] @@ -63,7 +63,7 @@ (struct: #hidden _ (Codec JSON Int) (def: encode (|>. int-to-nat (:: Codec<JSON,Nat> encode))) (def: decode - (|>. (:: Codec<JSON,Nat> decode) (:: R;Functor<Result> map nat-to-int)))) + (|>. (:: Codec<JSON,Nat> decode) (:: E;Functor<Error> map nat-to-int)))) (def: #hidden (nullable writer) {#;doc "Builds a JSON generator for potentially inexistent values."} @@ -78,7 +78,7 @@ (def: encode (|>. unit;out (:: Codec<JSON,Int> encode))) (def: decode - (|>. (:: Codec<JSON,Int> decode) (:: R;Functor<Result> map (unit;in carrier))))) + (|>. (:: Codec<JSON,Int> decode) (:: E;Functor<Error> map (unit;in carrier))))) (poly: #hidden Codec<JSON,?>//encode (with-expansions diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 4e431de82..a31eb8c6e 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -11,7 +11,7 @@ (coll [list "list/" Functor<List>]) [product] [maybe] - ["R" result])) + ["E" error])) (.. [code "code/" Eq<Code>])) ## [Utils] @@ -38,8 +38,8 @@ (Syntax Code) (function [tokens] (case tokens - #;Nil (#R;Error "There are no tokens to parse!") - (#;Cons [t tokens']) (#R;Success [tokens' t])))) + #;Nil (#E;Error "There are no tokens to parse!") + (#;Cons [t tokens']) (#E;Success [tokens' t])))) (do-template [<get-name> <type> <tag> <eq> <desc>] [(def: #export <get-name> @@ -48,10 +48,10 @@ (function [tokens] (case tokens (#;Cons [[_ (<tag> x)] tokens']) - (#R;Success [tokens' x]) + (#E;Success [tokens' x]) _ - (#R;Error ($_ text/compose "Cannot parse " <desc> (remaining-inputs tokens))))))] + (#E;Error ($_ text/compose "Cannot parse " <desc> (remaining-inputs tokens))))))] [ bool Bool #;Bool bool;Eq<Bool> "bool"] [ nat Nat #;Nat number;Eq<Nat> "nat"] @@ -73,10 +73,10 @@ remaining (if is-it? tokens' tokens)] - (#R;Success [remaining is-it?])) + (#E;Success [remaining is-it?])) _ - (#R;Success [tokens false])))) + (#E;Success [tokens false])))) (def: #export (this ast) {#;doc "Ensures the given Code is the next input."} @@ -85,12 +85,12 @@ (case tokens (#;Cons [token tokens']) (if (code/= ast token) - (#R;Success [tokens' []]) - (#R;Error ($_ text/compose "Expected a " (code;to-text ast) " but instead got " (code;to-text token) + (#E;Success [tokens' []]) + (#E;Error ($_ text/compose "Expected a " (code;to-text ast) " but instead got " (code;to-text token) (remaining-inputs tokens)))) _ - (#R;Error "There are no tokens to parse!")))) + (#E;Error "There are no tokens to parse!")))) (do-template [<name> <comp> <error>] [(def: #export <name> @@ -111,10 +111,10 @@ (function [tokens] (case tokens (#;Cons [[_ (<tag> ["" x])] tokens']) - (#R;Success [tokens' x]) + (#E;Success [tokens' x]) _ - (#R;Error ($_ text/compose "Cannot parse local " <desc> (remaining-inputs tokens))))))] + (#E;Error ($_ text/compose "Cannot parse local " <desc> (remaining-inputs tokens))))))] [local-symbol #;Symbol "symbol"] [ local-tag #;Tag "tag"] @@ -129,11 +129,11 @@ (case tokens (#;Cons [[_ (<tag> members)] tokens']) (case (p members) - (#R;Success [#;Nil x]) (#R;Success [tokens' x]) - _ (#R;Error ($_ text/compose "Syntax was expected to fully consume " <desc> (remaining-inputs tokens)))) + (#E;Success [#;Nil x]) (#E;Success [tokens' x]) + _ (#E;Error ($_ text/compose "Syntax was expected to fully consume " <desc> (remaining-inputs tokens)))) _ - (#R;Error ($_ text/compose "Cannot parse " <desc> (remaining-inputs tokens))))))] + (#E;Error ($_ text/compose "Cannot parse " <desc> (remaining-inputs tokens))))))] [ form #;Form "form"] [tuple #;Tuple "tuple"] @@ -147,38 +147,38 @@ (case tokens (#;Cons [[_ (#;Record pairs)] tokens']) (case (p (join-pairs pairs)) - (#R;Success [#;Nil x]) (#R;Success [tokens' x]) - _ (#R;Error ($_ text/compose "Syntax was expected to fully consume record" (remaining-inputs tokens)))) + (#E;Success [#;Nil x]) (#E;Success [tokens' x]) + _ (#E;Error ($_ text/compose "Syntax was expected to fully consume record" (remaining-inputs tokens)))) _ - (#R;Error ($_ text/compose "Cannot parse record" (remaining-inputs tokens)))))) + (#E;Error ($_ text/compose "Cannot parse record" (remaining-inputs tokens)))))) (def: #export end! {#;doc "Ensures there are no more inputs."} (Syntax Unit) (function [tokens] (case tokens - #;Nil (#R;Success [tokens []]) - _ (#R;Error ($_ text/compose "Expected list of tokens to be empty!" (remaining-inputs tokens)))))) + #;Nil (#E;Success [tokens []]) + _ (#E;Error ($_ text/compose "Expected list of tokens to be empty!" (remaining-inputs tokens)))))) (def: #export end? {#;doc "Checks whether there are no more inputs."} (Syntax Bool) (function [tokens] (case tokens - #;Nil (#R;Success [tokens true]) - _ (#R;Success [tokens false])))) + #;Nil (#E;Success [tokens true]) + _ (#E;Success [tokens false])))) (def: #export (on compiler action) {#;doc "Run a Lux operation as if it was a Syntax parser."} (All [a] (-> Compiler (Lux a) (Syntax a))) (function [input] (case (macro;run compiler action) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success value) - (#R;Success [input value]) + (#E;Success value) + (#E;Success [input value]) ))) (def: #export (local local-inputs syntax) @@ -186,16 +186,16 @@ (All [a] (-> (List Code) (Syntax a) (Syntax a))) (function [real-inputs] (case (syntax local-inputs) - (#R;Error error) - (#R;Error error) + (#E;Error error) + (#E;Error error) - (#R;Success [unconsumed-inputs value]) + (#E;Success [unconsumed-inputs value]) (case unconsumed-inputs #;Nil - (#R;Success [real-inputs value]) + (#E;Success [real-inputs value]) _ - (#R;Error (text/compose "Unconsumed inputs: " + (#E;Error (text/compose "Unconsumed inputs: " (|> (list/map code;to-text unconsumed-inputs) (text;join-with ", ")))))))) @@ -265,10 +265,10 @@ g!end (code;symbol ["" ""]) error-msg (code;text (text/compose "Wrong syntax for " name)) export-ast (: (List Code) (case exported? - (#;Some #R;Error) + (#;Some #E;Error) (list (' #hidden)) - (#;Some #R;Success) + (#;Some #E;Success) (list (' #export)) _ @@ -280,15 +280,15 @@ (: (Syntax (Lux (List Code))) (do ;;_Monad<Parser>_ [(~@ (join-pairs vars+parsers)) - (~ g!end) end!] + (~ g!end) ;;end!] ((~' wrap) (do macro;Monad<Lux> [] (~ body)))))) - (#R;Success [(~ g!tokens) (~ g!body)]) + (#E;Success [(~ g!tokens) (~ g!body)]) ((~ g!body) (~ g!state)) - (#R;Error (~ g!msg)) - (#R;Error (text.join-with ": " (list (~ error-msg) (~ g!msg)))))))))))) + (#E;Error (~ g!msg)) + (#E;Error (text.join-with ": " (list (~ error-msg) (~ g!msg)))))))))))) _ (macro;fail "Wrong syntax for syntax:")))) |