diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/scriptum.lux | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index 419e8a4c9..86a45e606 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -1,7 +1,8 @@ (.module: [lux #* [abstract - ["." monad (#+ do)]] + ["." monad (#+ do)] + ["." enum]] [control [pipe (#+ when>)] ["." try (#+ Try)] @@ -16,12 +17,12 @@ ["n" nat]] [format ["md" markdown (#+ Markdown Span Block)]] - ["." text ("#;." equivalence) + ["." text ("#@." equivalence) ["%" format (#+ format)] ["." encoding]] [collection - ["." sequence (#+ Sequence) ("#;." functor)] - ["." list ("#;." functor fold)]]] + ["." sequence (#+ Sequence) ("#@." functor)] + ["." list ("#@." functor fold)]]] ["." function] ["." type ("#@." equivalence)] ["." macro] @@ -47,7 +48,7 @@ (def: type-var-names (Sequence Text) - (|> 0 (sequence.iterate inc) (sequence;map parameter-type-name))) + (|> 0 (sequence.iterate inc) (sequence@map parameter-type-name))) (template [<name> <partition>] [(def: (<name> id) @@ -83,14 +84,14 @@ (list) (|> level dec - (list.n/range 0) - (list;map (|>> (n.+ (inc offset)) parameter-type-name))))) + (enum.range n.enum 0) + (list@map (|>> (n.+ (inc offset)) parameter-type-name))))) (def: (prefix-lines prefix lines) (-> Text Text Text) (|> lines (text.split-all-with text.new-line) - (list;map (|>> (format prefix))) + (list@map (|>> (format prefix))) (text.join-with text.new-line))) (def: (pprint-type-definition level type-func-info tags module signature? recursive-type? type) @@ -109,7 +110,7 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")")) + (format "(primitive " (%.text name) " " (|> params (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")")) [_ (#.Sum _)] (let [members (type.flatten-variant type)] @@ -117,20 +118,20 @@ #.Nil (format "(| " (|> members - (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) + (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")") _ (|> members (list.zip2 tags) - (list;map (function (_ [[_ t-name] type]) + (list@map (function (_ [[_ t-name] type]) (case type (#.Product _) (let [types (type.flatten-tuple type)] (format "(#" t-name " " (|> types - (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) + (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")")) @@ -142,12 +143,12 @@ (let [members (type.flatten-tuple type)] (case tags #.Nil - (format "[" (|> members (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) "]") + (format "[" (|> members (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) "]") _ (let [member-docs (|> members (list.zip2 tags) - (list;map (function (_ [[_ t-name] type]) + (list@map (function (_ [[_ t-name] type]) (if signature? (format "(: " (pprint-type-definition level type-func-info #.None module signature? recursive-type? type) text.new-line " " t-name ")") (format "#" t-name " " (pprint-type-definition level type-func-info #.None module signature? recursive-type? type))))) @@ -158,7 +159,7 @@ [_ (#.Function input output)] (let [[ins out] (type.flatten-function type)] - (format "(-> " (|> ins (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) + (format "(-> " (|> ins (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) " " (pprint-type-definition level type-func-info #.None module signature? recursive-type? out) ")")) @@ -193,10 +194,10 @@ [_ (#.Apply param fun)] (let [[type-func type-arguments] (type.flatten-application type)] - (format "(" (pprint-type-definition level type-func-info tags module signature? recursive-type? type-func) " " (|> type-arguments (list;map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")")) + (format "(" (pprint-type-definition level type-func-info tags module signature? recursive-type? type-func) " " (|> type-arguments (list@map (pprint-type-definition level type-func-info #.None module signature? recursive-type?)) (text.join-with " ")) ")")) [_ (#.Named [_module _name] type)] - (if (text;= module _module) + (if (text@= module _module) _name (%.name [_module _name])) ))) @@ -210,20 +211,20 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list;map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) + (format "(primitive " (%.text name) " " (|> params (list@map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) (#.Sum _) (let [members (type.flatten-variant type)] - (format "(| " (|> members (list;map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) + (format "(| " (|> members (list@map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) (#.Product _) (let [members (type.flatten-tuple type)] - (format "[" (|> members (list;map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) "]")) + (format "[" (|> members (list@map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) "]")) (#.Function input output) (let [[ins out] (type.flatten-function type)] (format "(-> " - (|> ins (list;map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) + (|> ins (list@map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) " " (pprint-type level type-func-name module out) ")")) @@ -250,10 +251,10 @@ (#.Apply param fun) (let [[type-func type-arguments] (type.flatten-application type)] - (format "(" (pprint-type level type-func-name module type-func) " " (|> type-arguments (list;map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) + (format "(" (pprint-type level type-func-name module type-func) " " (|> type-arguments (list@map (pprint-type level type-func-name module)) (list.interpose " ") (text.join-with "")) ")")) (#.Named [_module _name] type) - (if (text;= module _module) + (if (text@= module _module) _name (%.name [_module _name])) )) @@ -271,7 +272,7 @@ (def: (lux-module? module-name) (-> Text Bit) - (or (text;= "lux" module-name) + (or (text@= "lux" module-name) (text.starts-with? "lux/" module-name))) (def: (add-definition [name [def-type def-annotations def-value]] organization) @@ -302,9 +303,9 @@ (def: name-sort (All [r] (-> [Text r] [Text r] Bit)) - (let [text;< (:: text.order <)] + (let [text@< (:: text.order <)] (function (_ [n1 _] [n2 _]) - (text;< n1 n2)))) + (text@< n1 n2)))) (def: (organize-definitions defs) (-> (List [Text Definition]) Organization) @@ -312,7 +313,7 @@ #macros (list) #structures (list) #values (list)}] - (|> (list;fold add-definition init defs) + (|> (list@fold add-definition init defs) (update@ #types (list.sort name-sort)) (update@ #macros (list.sort name-sort)) (update@ #structures (list.sort name-sort)) @@ -366,7 +367,7 @@ (when> recursive-type? [unrecurse-type]) (pprint-type-definition (dec nesting) [_name type-arguments] (maybe.default (list) tags) module signature? recursive-type?) (text.split-all-with text.new-line) - (list;map (|>> (format " "))) + (list@map (|>> (format " "))) (text.join-with text.new-line)) ")")))) @@ -392,14 +393,14 @@ md.empty) type-code))))) types)] - (wrap (list;fold (function.flip md.then) + (wrap (list@fold (function.flip md.then) (md.heading/2 "Types") type-docs)))) (def: (document-macros module-name names) (-> Text (List [Text Code]) (Markdown Block)) (|> names - (list;map (: (-> [Text Code] (Markdown Block)) + (list@map (: (-> [Text Code] (Markdown Block)) (function (_ [name def-annotations]) ($_ md.then (md.heading/3 name) @@ -408,7 +409,7 @@ (do maybe.monad [documentation (macro.get-documentation def-annotations)] (wrap (md.code documentation)))))))) - (list;fold (function.flip md.then) + (list@fold (function.flip md.then) (md.heading/2 "Macros")))) (template [<singular> <plural> <header>] @@ -419,7 +420,7 @@ (def: (<plural> module values) (-> Text (List Value) (Markdown Block)) (|> values - (list;map (function (_ [name def-annotations value-type]) + (list@map (function (_ [name def-annotations value-type]) (let [?doc (macro.get-documentation def-annotations) usage (case (macro.function-arguments def-annotations) #.Nil @@ -436,7 +437,7 @@ _ md.empty) (<singular> module value-type))))) - (list;fold (function.flip md.then) + (list@fold (function.flip md.then) (md.heading/2 <header>))))] [document-structure document-structures "Structures"] @@ -447,7 +448,7 @@ (-> [Text Text] Text Text) (|> block (text.split-all-with text.new-line) - (list;map (text.enclose pre+post)) + (list@map (text.enclose pre+post)) (text.join-with text.new-line))) (def: (document-module [[module-name module] organization]) @@ -505,7 +506,7 @@ (list.sort name-sort))] lux-exports (monad.map @ (function.compose macro.exports product.left) lux-modules) - module-documentation (|> (list;map organize-definitions lux-exports) + module-documentation (|> (list@map organize-definitions lux-exports) (list.zip2 lux-modules) (monad.map @ document-module)) #let [_ (io.run (monad.map io.monad save-documentation! module-documentation))]] |