diff options
Diffstat (limited to 'stdlib/source/lux/meta/type.lux')
-rw-r--r-- | stdlib/source/lux/meta/type.lux | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/stdlib/source/lux/meta/type.lux b/stdlib/source/lux/meta/type.lux index e7c630966..9d6ed5162 100644 --- a/stdlib/source/lux/meta/type.lux +++ b/stdlib/source/lux/meta/type.lux @@ -1,12 +1,12 @@ (;module: {#;doc "Basic functionality for working with types."} [lux #- function] (lux (control [eq #+ Eq] - ["M" monad #+ do Monad]) - (data [text "Text/" Monoid<Text> Eq<Text>] - [ident "Ident/" Eq<Ident>] - [number "Nat/" Codec<Text,Nat>] + [monad #+ do Monad]) + (data [text "text/" Monoid<Text> Eq<Text>] + [ident "ident/" Eq<Ident>] + [number "nat/" Codec<Text,Nat>] [maybe] - (coll [list #+ "List/" Monad<List> Monoid<List> Fold<List>])) + (coll [list #+ "list/" Monad<List> Monoid<List> Fold<List>])) (meta [code]) )) @@ -15,7 +15,7 @@ (-> (List Type) Type Type) (case type (#;Primitive name params) - (#;Primitive name (List/map (beta-reduce env) params)) + (#;Primitive name (list/map (beta-reduce env) params)) (^template [<tag>] (<tag> left right) @@ -35,7 +35,7 @@ [#;ExQ]) (#;Bound idx) - (maybe;default (error! (Text/compose "Unknown type var: " (Nat/encode idx))) + (maybe;default (error! (text/compose "Unknown type var: " (nat/encode idx))) (list;nth idx env)) _ @@ -47,9 +47,9 @@ (def: (= x y) (case [x y] [(#;Primitive xname xparams) (#;Primitive yname yparams)] - (and (Text/= xname yname) + (and (text/= xname yname) (n.= (list;size yparams) (list;size xparams)) - (List/fold (;function [[x y] prev] (and prev (= x y))) + (list/fold (;function [[x y] prev] (and prev (= x y))) true (list;zip2 xparams yparams))) @@ -69,7 +69,7 @@ (= xright yright)) [(#;Named xname xtype) (#;Named yname ytype)] - (and (Ident/= xname yname) + (and (ident/= xname yname) (= xtype ytype)) (^template [<tag>] @@ -81,7 +81,7 @@ [(#;ExQ xenv xbody) (#;ExQ yenv ybody)]) (and (n.= (list;size yenv) (list;size xenv)) (= xbody ybody) - (List/fold (;function [[x y] prev] (and prev (= x y))) + (list/fold (;function [[x y] prev] (and prev (= x y))) true (list;zip2 xenv yenv))) @@ -121,7 +121,7 @@ (case type (#;Apply arg func') (let [[func args] (flatten-application func')] - [func (List/compose args (list arg))]) + [func (list/compose args (list arg))]) _ [type (list)])) @@ -169,7 +169,7 @@ (case type (#;Primitive name params) (` (#;Primitive (~ (code;text name)) - (list (~@ (List/map to-ast params))))) + (list (~@ (list/map to-ast params))))) (^template [<tag>] <tag> @@ -189,7 +189,7 @@ (^template [<tag> <macro> <flattener>] (<tag> left right) - (` (<macro> (~@ (List/map to-ast (<flattener> type)))))) + (` (<macro> (~@ (list/map to-ast (<flattener> type)))))) ([#;Sum | flatten-variant] [#;Product & flatten-tuple]) @@ -198,7 +198,7 @@ (^template [<tag>] (<tag> env body) - (` (<tag> (list (~@ (List/map to-ast env))) + (` (<tag> (list (~@ (list/map to-ast env))) (~ (to-ast body))))) ([#;UnivQ] [#;ExQ]) )) @@ -209,10 +209,10 @@ (#;Primitive name params) (case params #;Nil - ($_ Text/compose "(primitive " name ")") + ($_ text/compose "(primitive " name ")") _ - ($_ Text/compose "(primitive " name " " (|> params (List/map to-text) list;reverse (list;interpose " ") (List/fold Text/compose "")) ")")) + ($_ text/compose "(primitive " name " " (|> params (list/map to-text) list;reverse (list;interpose " ") (list/fold text/compose "")) ")")) #;Void "Void" @@ -222,47 +222,47 @@ (^template [<tag> <open> <close> <flatten>] (<tag> _) - ($_ Text/compose <open> + ($_ text/compose <open> (|> (<flatten> type) - (List/map to-text) + (list/map to-text) list;reverse (list;interpose " ") - (List/fold Text/compose "")) + (list/fold text/compose "")) <close>)) ([#;Sum "(| " ")" flatten-variant] [#;Product "[" "]" flatten-tuple]) (#;Function input output) (let [[ins out] (flatten-function type)] - ($_ Text/compose "(-> " + ($_ text/compose "(-> " (|> ins - (List/map to-text) + (list/map to-text) list;reverse (list;interpose " ") - (List/fold Text/compose "")) + (list/fold text/compose "")) " " (to-text out) ")")) (#;Bound idx) - (Nat/encode idx) + (nat/encode idx) (#;Var id) - ($_ Text/compose "⌈v:" (Nat/encode id) "⌋") + ($_ text/compose "⌈v:" (nat/encode id) "⌋") (#;Ex id) - ($_ Text/compose "⟨e:" (Nat/encode id) "⟩") + ($_ text/compose "⟨e:" (nat/encode id) "⟩") (#;Apply param fun) (let [[type-func type-args] (flatten-application type)] - ($_ Text/compose "(" (to-text type-func) " " (|> type-args (List/map to-text) list;reverse (list;interpose " ") (List/fold Text/compose "")) ")")) + ($_ text/compose "(" (to-text type-func) " " (|> type-args (list/map to-text) list;reverse (list;interpose " ") (list/fold text/compose "")) ")")) (^template [<tag> <desc>] (<tag> env body) - ($_ Text/compose "(" <desc> " {" (|> env (List/map to-text) (text;join-with " ")) "} " (to-text body) ")")) + ($_ text/compose "(" <desc> " {" (|> env (list/map to-text) (text;join-with " ")) "} " (to-text body) ")")) ([#;UnivQ "All"] [#;ExQ "Ex"]) (#;Named [module name] type) - ($_ Text/compose module ";" name) + ($_ text/compose module ";" name) )) (def: #export (un-alias type) |