diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/macro/ast.lux | 6 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly.lux | 26 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly/eq.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly/functor.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly/text-encoder.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/macro/syntax.lux | 10 |
6 files changed, 30 insertions, 30 deletions
diff --git a/stdlib/source/lux/macro/ast.lux b/stdlib/source/lux/macro/ast.lux index cc1cffa5f..06ba2aaed 100644 --- a/stdlib/source/lux/macro/ast.lux +++ b/stdlib/source/lux/macro/ast.lux @@ -100,7 +100,7 @@ false))) ## [Values] -(def: #export (ast-to-text ast) +(def: #export (to-text ast) (-> AST Text) (case ast (^template [<tag> <struct>] @@ -120,12 +120,12 @@ (^template [<tag> <open> <close>] [_ (<tag> members)] - ($_ Text/append <open> (|> members (map ast-to-text) (interpose " ") (text;join-with "")) <close>)) + ($_ Text/append <open> (|> members (map to-text) (interpose " ") (text;join-with "")) <close>)) ([#;FormS "(" ")"] [#;TupleS "[" "]"]) [_ (#;RecordS pairs)] - ($_ Text/append "{" (|> pairs (map (lambda [[left right]] ($_ Text/append (ast-to-text left) " " (ast-to-text right)))) (interpose " ") (text;join-with "")) "}") + ($_ Text/append "{" (|> pairs (map (lambda [[left right]] ($_ Text/append (to-text left) " " (to-text right)))) (interpose " ") (text;join-with "")) "}") )) (def: #export (replace source target ast) diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index bb5c068f7..a2a7dd7d6 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -39,7 +39,7 @@ (:: compiler;Monad<Lux> wrap []) _ - (compiler;fail (format "Not " <name> " type: " (type;type-to-text :type:))))))] + (compiler;fail (format "Not " <name> " type: " (%type :type:))))))] [unit "Unit"] [bool "Bool"] @@ -70,7 +70,7 @@ <primitives>)))) (syntax: ($AST$ ast) - (wrap (;list (ast;text (ast;ast-to-text ast))))) + (wrap (;list (ast;text (ast;to-text ast))))) (do-template [<single> <multi> <flattener> <tag>] [(def: #export <single> @@ -81,7 +81,7 @@ (:: compiler;Monad<Lux> wrap [:left: :right:]) _ - (compiler;fail (format "Not a " ($AST$ <tag>) " type: " (type;type-to-text :type:)))))) + (compiler;fail (format "Not a " ($AST$ <tag>) " type: " (%type :type:)))))) (def: #export <multi> (Matcher (List Type)) @@ -89,7 +89,7 @@ (let [members (<flattener> (type;un-name :type:))] (if (n.> +1 (list;size members)) (:: compiler;Monad<Lux> wrap members) - (compiler;fail (format "Not a " ($AST$ <tag>) " type: " (type;type-to-text :type:)))))))] + (compiler;fail (format "Not a " ($AST$ <tag>) " type: " (%type :type:)))))))] [sum sum+ type;flatten-sum #;SumT] [prod prod+ type;flatten-prod #;ProdT] @@ -103,7 +103,7 @@ (:: compiler;Monad<Lux> wrap [:left: :right:]) _ - (compiler;fail (format "Not a LambdaT type: " (type;type-to-text :type:)))))) + (compiler;fail (format "Not a LambdaT type: " (%type :type:)))))) (def: #export func+ (Matcher [(List Type) Type]) @@ -111,7 +111,7 @@ (let [[ins out] (type;flatten-function (type;un-name :type:))] (if (n.> +0 (list;size ins)) (:: compiler;Monad<Lux> wrap [ins out]) - (compiler;fail (format "Not a LambdaT type: " (type;type-to-text :type:))))))) + (compiler;fail (format "Not a LambdaT type: " (%type :type:))))))) (def: #export tagged (Matcher [(List Ident) Type]) @@ -123,7 +123,7 @@ (wrap [tags :def:])) _ - (compiler;fail (format "Unnamed types can't have tags: " (type;type-to-text :type:)))))) + (compiler;fail (format "Unnamed types can't have tags: " (%type :type:)))))) (def: #export polymorphic (Matcher [(List AST) Type]) @@ -206,7 +206,7 @@ (:: compiler;Monad<Lux> wrap :arg:) _ - (compiler;fail (format "Not " <name> " type: " (type;type-to-text :type:))))))] + (compiler;fail (format "Not " <name> " type: " (%type :type:))))))] [maybe "Maybe"] [list "List"] @@ -229,10 +229,10 @@ (:: compiler;Monad<Lux> wrap poly-val) #;None - (compiler;fail (format "Unknown bound type: " (type;type-to-text :type:)))) + (compiler;fail (format "Unknown bound type: " (%type :type:)))) _ - (compiler;fail (format "Not a bound type: " (type;type-to-text :type:)))))) + (compiler;fail (format "Not a bound type: " (%type :type:)))))) (def: #export (var env var-id) (-> Env Nat (Matcher Unit)) @@ -243,7 +243,7 @@ (:: compiler;Monad<Lux> wrap []) _ - (compiler;fail (format "Not a bound type: " (type;type-to-text :type:)))))) + (compiler;fail (format "Not a bound type: " (%type :type:)))))) (def: #export (recur env) (-> Env (Matcher Unit)) @@ -263,7 +263,7 @@ (recur (n.inc base) :parts:') _ - (compiler;fail (format "Type is not a recursive instance: " (type;type-to-text :type:))))) + (compiler;fail (format "Type is not a recursive instance: " (%type :type:))))) ))) ## [Syntax] @@ -345,7 +345,7 @@ ## [Derivers] (def: #export (gen-type converter type-fun tvars type) (-> (-> AST AST) AST (List AST) Type AST) - (let [type' (type;type-to-ast type)] + (let [type' (type;to-ast type)] (case tvars #;Nil (converter type') diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux index b0506c5ed..025797751 100644 --- a/stdlib/source/lux/macro/poly/eq.lux +++ b/stdlib/source/lux/macro/poly/eq.lux @@ -94,10 +94,10 @@ [[:func: :args:] (poly;apply :x:) .func. (|Eq| env :func:) .args. (mapM @ (|Eq| env) :args:)] - (wrap (` (: (~ (->Eq (type;type-to-ast :x:))) + (wrap (` (: (~ (->Eq (type;to-ast :x:))) ((~ .func.) (~@ .args.)))))) ## Bound type-vars (poly;bound env :x:) ## If all else fails... - (compiler;fail (format "Can't create Eq for: " (type;type-to-text :x:))) + (compiler;fail (format "Can't create Eq for: " (%type :x:))) )))) diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index c9de93cbb..17fd7808f 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -80,7 +80,7 @@ (wrap (list analysis synthesis)))) cases)] - (wrap (` (: (~ (->Functor (type;type-to-ast :x:))) + (wrap (` (: (~ (->Functor (type;to-ast :x:))) (struct (def: ((~ g!map) (~ g!func) (~ g!input)) (case (~ g!input) (~@ (List/join pattern-matching))))) @@ -95,7 +95,7 @@ body (|elem| g!slot :slot:)] (wrap [g!slot body]))) members)] - (wrap (` (: (~ (->Functor (type;type-to-ast :x:))) + (wrap (` (: (~ (->Functor (type;to-ast :x:))) (struct (def: ((~ g!map) (~ g!func) (~ g!input)) (case (~ g!input) [(~@ (List/map product;left pm))] @@ -109,7 +109,7 @@ g!ins (seqM @ (list;repeat (list;size :ins:) (compiler;gensym "g!arg")))] - (wrap (` (: (~ (->Functor (type;type-to-ast :x:))) + (wrap (` (: (~ (->Functor (type;to-ast :x:))) (struct (def: ((~ g!map) (~ g!func) (~ g!input)) (lambda [(~@ g!ins)] (let [(~ g!out) ((~ g!input) (~@ g!ins))] @@ -117,10 +117,10 @@ ## No structure (as you'd expect from Identity) (do @ [_ (poly;var new-env (n.dec num-vars) :x:)] - (wrap (` (: (~ (->Functor (type;type-to-ast :x:))) + (wrap (` (: (~ (->Functor (type;to-ast :x:))) (struct (def: ((~ g!map) (~ g!func) (~ g!input)) ((~ g!func) (~ g!input)))))))) ## Failure... - (compiler;fail (format "Can't create Functor for: " (type;type-to-text :x:))) + (compiler;fail (format "Can't create Functor for: " (%type :x:))) )) ))) diff --git a/stdlib/source/lux/macro/poly/text-encoder.lux b/stdlib/source/lux/macro/poly/text-encoder.lux index 49d06daf4..c2ab30d7f 100644 --- a/stdlib/source/lux/macro/poly/text-encoder.lux +++ b/stdlib/source/lux/macro/poly/text-encoder.lux @@ -117,10 +117,10 @@ [[:func: :args:] (poly;apply :x:) .func. (|Codec@Text//encode| env :func:) .args. (mapM @ (|Codec@Text//encode| env) :args:)] - (wrap (` (: (~ (->Codec//encode (type;type-to-ast :x:))) + (wrap (` (: (~ (->Codec//encode (type;to-ast :x:))) ((~ .func.) (~@ .args.)))))) ## Bound type-variables (poly;bound env :x:) ## Failure... - (compiler;fail (format "Can't create Text encoder for: " (type;type-to-text :x:))) + (compiler;fail (format "Can't create Text encoder for: " (%type :x:))) )))) diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index c32d5d105..1d3ef021d 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -78,7 +78,7 @@ (def: (remaining-inputs asts) (-> (List AST) Text) ($_ Text/append " | Remaining input: " - (|> asts (map ast;ast-to-text) (interpose " ") (text;join-with "")))) + (|> asts (map ast;to-text) (interpose " ") (text;join-with "")))) ## [Syntaxs] (def: #export any @@ -121,7 +121,7 @@ (#;Cons [[_ (<tag> x)] tokens']) (if (:: <eq> = v x) (#;Right [tokens' []]) - (#;Left ($_ Text/append "Expected a " <desc> " but instead got " (ast;ast-to-text [_ (<tag> x)]) (remaining-inputs tokens)))) + (#;Left ($_ Text/append "Expected a " <desc> " but instead got " (ast;to-text [_ (<tag> x)]) (remaining-inputs tokens)))) _ (#;Left ($_ Text/append "Can't parse " <desc> (remaining-inputs tokens))))))] @@ -136,8 +136,8 @@ [ tag tag? tag! Ident #;TagS ident;Eq<Ident> "tag"] ) -(def: #export (assert v message) - (-> Bool Text (Syntax Unit)) +(def: #export (assert message v) + (-> Text Bool (Syntax Unit)) (lambda [tokens] (if v (#;Right [tokens []]) @@ -148,7 +148,7 @@ (Syntax Int) (do Monad<Syntax> [n int - _ (assert (<comp> 0 n) <error>)] + _ (assert <error> (<comp> 0 n))] (wrap n)))] [pos-int i.> "Expected a positive integer: N > 0"] |