diff options
Diffstat (limited to '')
70 files changed, 867 insertions, 860 deletions
diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index d43142556..bce620ee9 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -216,7 +216,7 @@ Called by `imenu--generic-function'." (regexp-opt '(";module:" "def:" "type:" "sig:" "struct:" "macro:" "syntax:" "program:" "poly:" "derived:" "actor:" "test:" "template:" "class:" "interface:" "model:" "exception:" - "lambda" "case" ":" ":!" ":!!" "undefined" "ident-for" + "function" "case" ":" ":!" ":!!" "undefined" "ident-for" "and" "or" "exec" "let" "let%" "if" "cond" "do" "be" "open" "loop" "recur" "comment" "list" "list&" "io" "vector" "tree" "get@" "set@" "update@" "|>" "|>." "<|" "_$" "$_" "~" "~@" "~'" "::" ":::" "default" @@ -363,7 +363,7 @@ This function also returns nil meaning don't specify the indentation." (define-lux-indent (def 'defun) - (lambda 'defun) + (function 'defun) (let 'defun) (let% 'defun) (case 'defun) @@ -379,7 +379,7 @@ This function also returns nil meaning don't specify the indentation." (Rec 'defun) (_lux_def 'defun) (_lux_case 'defun) - (_lux_lambda 'defun) + (_lux_function 'defun) (synchronized 'defun) (object 'defun) (do-to 'defun) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 16077a0e3..4d5885393 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2888,14 +2888,14 @@ _ (fail "Wrong syntax for let"))) -(macro:' #export (lambda tokens) +(macro:' #export (function tokens) (list [["lux" "doc"] (#TextA "## Syntax for creating functions. ## Allows for giving the function itself a name, for the sake of recursion. (: (All [a b] (-> a b a)) - (lambda [x y] x)) + (function [x y] x)) (: (All [a b] (-> a b a)) - (lambda const [x y] x))")]) + (function const [x y] x))")]) (case (: (Maybe [Ident AST (List AST) AST]) (case tokens (^ (list [_ (#TupleS (#Cons head tail))] body)) @@ -2922,7 +2922,7 @@ (` (;_lux_lambda (~ g!name) (~ g!blank) (case (~ g!blank) (~ head) (~ body+)))))))) #None - (fail "Wrong syntax for lambda"))) + (fail "Wrong syntax for function"))) (def:' (process-def-meta-value ast) (-> AST (Lux AST)) @@ -2963,15 +2963,15 @@ (do Monad<Lux> [=xs (mapM Monad<Lux> (: (-> [AST AST] (Lux AST)) - (lambda [[k v]] - (case k - [_ (#TextS =k)] - (do Monad<Lux> - [=v (process-def-meta-value v)] - (wrap (tuple$ (list (text$ =k) =v)))) - - _ - (fail (Text/append "Wrong syntax for DictA key: " (ast-to-text k)))))) + (function [[k v]] + (case k + [_ (#TextS =k)] + (do Monad<Lux> + [=v (process-def-meta-value v)] + (wrap (tuple$ (list (text$ =k) =v)))) + + _ + (fail (Text/append "Wrong syntax for DictA key: " (ast-to-text k)))))) kvs)] (wrap (form$ (list (tag$ ["lux" "DictA"]) (untemplate-list =xs))))) )) @@ -2983,16 +2983,16 @@ (do Monad<Lux> [=kvs (mapM Monad<Lux> (: (-> [AST AST] (Lux AST)) - (lambda [[k v]] - (case k - [_ (#TagS [pk nk])] - (do Monad<Lux> - [=v (process-def-meta-value v)] - (wrap (tuple$ (list (tuple$ (list (text$ pk) (text$ nk))) - =v)))) + (function [[k v]] + (case k + [_ (#TagS [pk nk])] + (do Monad<Lux> + [=v (process-def-meta-value v)] + (wrap (tuple$ (list (tuple$ (list (text$ pk) (text$ nk))) + =v)))) - _ - (fail (Text/append "Wrong syntax for Anns: " (ast-to-text ast)))))) + _ + (fail (Text/append "Wrong syntax for Anns: " (ast-to-text ast)))))) kvs)] (wrap (untemplate-list =kvs))) @@ -3007,15 +3007,15 @@ _ (` (#;Cons [["lux" "func-args"] - (#;ListA (list (~@ (map (lambda [arg] - (` (#;TextA (~ (text$ (ast-to-text arg)))))) + (#;ListA (list (~@ (map (function [arg] + (` (#;TextA (~ (text$ (ast-to-text arg)))))) args))))] (~ meta))))) (def:' (with-type-args args) (-> (List AST) AST) - (` {#;type-args (#;ListA (list (~@ (map (lambda [arg] - (` (#;TextA (~ (text$ (ast-to-text arg)))))) + (` {#;type-args (#;ListA (list (~@ (map (function [arg] + (` (#;TextA (~ (text$ (ast-to-text arg)))))) args))))})) (def:' Export-Level @@ -3095,7 +3095,7 @@ body _ - (` (lambda (~ name) [(~@ args)] (~ body)))) + (` (function (~ name) [(~@ args)] (~ body)))) body (case ?type (#Some type) (` (: (~ type) (~ body))) @@ -3224,19 +3224,19 @@ members (: (Lux (List [Text AST])) (mapM Monad<Lux> (: (-> AST (Lux [Text AST])) - (lambda [token] - (case token - (^ [_ (#FormS (list [_ (#SymbolS _ "_lux_:")] type [_ (#SymbolS ["" name])]))]) - (wrap [name type]) + (function [token] + (case token + (^ [_ (#FormS (list [_ (#SymbolS _ "_lux_:")] type [_ (#SymbolS ["" name])]))]) + (wrap [name type]) - _ - (fail "Signatures require typed members!")))) + _ + (fail "Signatures require typed members!")))) (List/join sigs'))) #let [[_module _name] name+ def-name (symbol$ name) sig-type (record$ (map (: (-> [Text AST] [AST AST]) - (lambda [[m-name m-type]] - [(tag$ ["" m-name]) m-type])) + (function [[m-name m-type]] + [(tag$ ["" m-name]) m-type])) members)) sig-meta (meta-ast-merge (` {#;sig? true}) meta) @@ -3467,17 +3467,17 @@ (def: (find-module name) (-> Text (Lux Module)) - (lambda [state] - (let [{#info info #source source #modules modules - #scopes scopes #type-vars types #host host - #seed seed #expected expected #cursor cursor - #scope-type-vars scope-type-vars} state] - (case (get name modules) - (#Some module) - (#Right state module) + (function [state] + (let [{#info info #source source #modules modules + #scopes scopes #type-vars types #host host + #seed seed #expected expected #cursor cursor + #scope-type-vars scope-type-vars} state] + (case (get name modules) + (#Some module) + (#Right state module) - _ - (#Left ($_ Text/append "Unknown module: " name)))))) + _ + (#Left ($_ Text/append "Unknown module: " name)))))) (def: get-current-module (Lux Module) @@ -3530,17 +3530,17 @@ (def: get-expected-type (Lux Type) - (lambda [state] - (let [{#info info #source source #modules modules - #scopes scopes #type-vars types #host host - #seed seed #expected expected #cursor cursor - #scope-type-vars scope-type-vars} state] - (case expected - (#Some type) - (#Right state type) - - #None - (#Left "Not expecting any type."))))) + (function [state] + (let [{#info info #source source #modules modules + #scopes scopes #type-vars types #host host + #seed seed #expected expected #cursor cursor + #scope-type-vars scope-type-vars} state] + (case expected + (#Some type) + (#Right state type) + + #None + (#Left "Not expecting any type."))))) (macro: #export (struct tokens) {#;doc "Not meant to be used directly. Prefer \"struct:\"."} @@ -3556,22 +3556,22 @@ _ (fail "No tags available for type."))) #let [tag-mappings (: (List [Text AST]) - (map (lambda [tag] [(second tag) (tag$ tag)]) + (map (function [tag] [(second tag) (tag$ tag)]) tags))] members (mapM Monad<Lux> (: (-> AST (Lux [AST AST])) - (lambda [token] - (case token - (^ [_ (#FormS (list [_ (#SymbolS _ "_lux_def")] [_ (#SymbolS "" tag-name)] value meta))]) - (case (get tag-name tag-mappings) - (#Some tag) - (wrap [tag value]) + (function [token] + (case token + (^ [_ (#FormS (list [_ (#SymbolS _ "_lux_def")] [_ (#SymbolS "" tag-name)] value meta))]) + (case (get tag-name tag-mappings) + (#Some tag) + (wrap [tag value]) - _ - (fail (Text/append "Unknown structure member: " tag-name))) + _ + (fail (Text/append "Unknown structure member: " tag-name))) - _ - (fail "Invalid structure member.")))) + _ + (fail "Invalid structure member.")))) (List/join tokens'))] (wrap (list (record$ members))))) @@ -3618,13 +3618,13 @@ (^ [_ (#;FormS (list& [_ (#;SymbolS [_ sig-name])] sig-args))]) (case (: (Maybe (List Text)) (mapM Monad<Maybe> - (lambda [sa] - (case sa - [_ (#;SymbolS [_ arg-name])] - (#;Some arg-name) + (function [sa] + (case sa + [_ (#;SymbolS [_ arg-name])] + (#;Some arg-name) - _ - #;None)) + _ + #;None)) sig-args)) (^ (#;Some params)) (#;Some (symbol$ ["" ($_ Text/append sig-name "<" (|> params (interpose ",") Text/join) ">")])) @@ -3670,7 +3670,7 @@ (case (reverse tokens) (^ (list& last init)) (return (list (fold (: (-> AST AST AST) - (lambda [pre post] (` <form>))) + (function [pre post] (` <form>))) last init))) @@ -3789,13 +3789,13 @@ (-> (List AST) (Lux (List Text))) (mapM Monad<Lux> (: (-> AST (Lux Text)) - (lambda [def] - (case def - [_ (#SymbolS ["" name])] - (return name) + (function [def] + (case def + [_ (#SymbolS ["" name])] + (return name) - _ - (fail "only/exclude requires symbols.")))) + _ + (fail "only/exclude requires symbols.")))) defs)) (def: (parse-alias tokens) @@ -3885,30 +3885,30 @@ (^ (list& [_ (#TagS "" "open")] [_ (#FormS parts)] tokens')) (if (|> parts (map (: (-> AST Bool) - (lambda [part] - (case part - (^or [_ (#TextS _)] [_ (#SymbolS _)]) - true - - _ - false)))) - (fold (lambda [r l] (and l r)) true)) + (function [part] + (case part + (^or [_ (#TextS _)] [_ (#SymbolS _)]) + true + + _ + false)))) + (fold (function [r l] (and l r)) true)) (let [openings (fold (: (-> AST (List Openings) (List Openings)) - (lambda [part openings] - (case part - [_ (#TextS prefix)] - (list& [prefix (list)] openings) - - [_ (#SymbolS struct-name)] - (case openings - #Nil - (list ["" (list struct-name)]) - - (#Cons [prefix structs] openings') - (#Cons [prefix (#Cons struct-name structs)] openings')) - - _ - openings))) + (function [part openings] + (case part + [_ (#TextS prefix)] + (list& [prefix (list)] openings) + + [_ (#SymbolS struct-name)] + (case openings + #Nil + (list ["" (list struct-name)]) + + (#Cons [prefix structs] openings') + (#Cons [prefix (#Cons struct-name structs)] openings')) + + _ + openings))) (: (List Openings) (list)) parts)] (return [openings tokens'])) @@ -3921,30 +3921,30 @@ (-> (List AST) (Lux [(List Openings) (List AST)])) (if (|> parts (map (: (-> AST Bool) - (lambda [part] - (case part - (^or [_ (#TextS _)] [_ (#SymbolS _)]) - true + (function [part] + (case part + (^or [_ (#TextS _)] [_ (#SymbolS _)]) + true - _ - false)))) - (fold (lambda [r l] (and l r)) true)) + _ + false)))) + (fold (function [r l] (and l r)) true)) (let [openings (fold (: (-> AST (List Openings) (List Openings)) - (lambda [part openings] - (case part - [_ (#TextS prefix)] - (list& [prefix (list)] openings) - - [_ (#SymbolS struct-name)] - (case openings - #Nil - (list ["" (list struct-name)]) - - (#Cons [prefix structs] openings') - (#Cons [prefix (#Cons struct-name structs)] openings')) - - _ - openings))) + (function [part openings] + (case part + [_ (#TextS prefix)] + (list& [prefix (list)] openings) + + [_ (#SymbolS struct-name)] + (case openings + #Nil + (list ["" (list struct-name)]) + + (#Cons [prefix structs] openings') + (#Cons [prefix (#Cons struct-name structs)] openings')) + + _ + openings))) (: (List Openings) (list)) parts)] (return [openings (list)])) @@ -3953,15 +3953,15 @@ (def: (decorate-sub-importations super-name) (-> Text (List Importation) (List Importation)) (map (: (-> Importation Importation) - (lambda [importation] - (let [{#import-name _name - #import-alias _alias - #import-refer {#refer-defs _referrals - #refer-open _openings}} importation] - {#import-name ($_ Text/append super-name "/" _name) - #import-alias _alias - #import-refer {#refer-defs _referrals - #refer-open _openings}}))))) + (function [importation] + (let [{#import-name _name + #import-alias _alias + #import-refer {#refer-defs _referrals + #refer-open _openings}} importation] + {#import-name ($_ Text/append super-name "/" _name) + #import-alias _alias + #import-refer {#refer-defs _referrals + #refer-open _openings}}))))) (def: (replace-all pattern value template) (-> Text Text Text Text) @@ -3994,61 +3994,61 @@ (do Monad<Lux> [imports' (mapM Monad<Lux> (: (-> AST (Lux (List Importation))) - (lambda [token] - (case token - [_ (#SymbolS "" m-name)] - (do Monad<Lux> - [m-name (clean-module m-name)] - (wrap (list [m-name #None {#refer-defs #All - #refer-open (list)}]))) - - (^ [_ (#FormS (list& [_ (#SymbolS "" m-name)] extra))]) - (do Monad<Lux> - [m-name (clean-module m-name) - alias+extra (parse-alias extra) - #let [[alias extra] alias+extra] - referral+extra (parse-referrals extra) - #let [[referral extra] referral+extra] - openings+extra (parse-openings extra) - #let [[openings extra] openings+extra] - sub-imports (parse-imports extra) - #let [sub-imports (decorate-sub-importations m-name sub-imports)]] - (wrap (case [referral alias openings] - [#Nothing #None #Nil] sub-imports - _ (list& {#import-name m-name - #import-alias alias - #import-refer {#refer-defs referral - #refer-open openings}} - sub-imports)))) - - (^ [_ (#TupleS (list& [_ (#TextS alias)] [_ (#SymbolS "" m-name)] extra))]) - (do Monad<Lux> - [m-name (clean-module m-name) - referral+extra (parse-short-referrals extra) - #let [[referral extra] referral+extra] - openings+extra (parse-short-openings extra) - #let [[openings extra] openings+extra]] - (wrap (list {#import-name m-name - #import-alias (#;Some (replace-all ";" m-name alias)) - #import-refer {#refer-defs referral - #refer-open openings}}))) - - (^ [_ (#TupleS (list& [_ (#SymbolS "" m-name)] extra))]) - (do Monad<Lux> - [m-name (clean-module m-name) - referral+extra (parse-short-referrals extra) - #let [[referral extra] referral+extra] - openings+extra (parse-short-openings extra) - #let [[openings extra] openings+extra]] - (wrap (list {#import-name m-name - #import-alias (#;Some m-name) - #import-refer {#refer-defs referral - #refer-open openings}}))) + (function [token] + (case token + [_ (#SymbolS "" m-name)] + (do Monad<Lux> + [m-name (clean-module m-name)] + (wrap (list [m-name #None {#refer-defs #All + #refer-open (list)}]))) + + (^ [_ (#FormS (list& [_ (#SymbolS "" m-name)] extra))]) + (do Monad<Lux> + [m-name (clean-module m-name) + alias+extra (parse-alias extra) + #let [[alias extra] alias+extra] + referral+extra (parse-referrals extra) + #let [[referral extra] referral+extra] + openings+extra (parse-openings extra) + #let [[openings extra] openings+extra] + sub-imports (parse-imports extra) + #let [sub-imports (decorate-sub-importations m-name sub-imports)]] + (wrap (case [referral alias openings] + [#Nothing #None #Nil] sub-imports + _ (list& {#import-name m-name + #import-alias alias + #import-refer {#refer-defs referral + #refer-open openings}} + sub-imports)))) + + (^ [_ (#TupleS (list& [_ (#TextS alias)] [_ (#SymbolS "" m-name)] extra))]) + (do Monad<Lux> + [m-name (clean-module m-name) + referral+extra (parse-short-referrals extra) + #let [[referral extra] referral+extra] + openings+extra (parse-short-openings extra) + #let [[openings extra] openings+extra]] + (wrap (list {#import-name m-name + #import-alias (#;Some (replace-all ";" m-name alias)) + #import-refer {#refer-defs referral + #refer-open openings}}))) + + (^ [_ (#TupleS (list& [_ (#SymbolS "" m-name)] extra))]) + (do Monad<Lux> + [m-name (clean-module m-name) + referral+extra (parse-short-referrals extra) + #let [[referral extra] referral+extra] + openings+extra (parse-short-openings extra) + #let [[openings extra] openings+extra]] + (wrap (list {#import-name m-name + #import-alias (#;Some m-name) + #import-refer {#refer-defs referral + #refer-open openings}}))) - _ - (do Monad<Lux> - [current-module current-module-name] - (fail (Text/append "Wrong syntax for import @ " current-module)))))) + _ + (do Monad<Lux> + [current-module current-module-name] + (fail (Text/append "Wrong syntax for import @ " current-module)))))) imports)] (wrap (List/join imports')))) @@ -4064,14 +4064,14 @@ (#Some =module) (let [to-alias (map (: (-> [Text Def] (List Text)) - (lambda [[name [def-type def-meta def-value]]] - (case [(get-meta ["lux" "export?"] def-meta) - (get-meta ["lux" "hidden?"] def-meta)] - [(#Some (#BoolA true)) #;None] - (list name) + (function [[name [def-type def-meta def-value]]] + (case [(get-meta ["lux" "export?"] def-meta) + (get-meta ["lux" "hidden?"] def-meta)] + [(#Some (#BoolA true)) #;None] + (list name) - _ - (list)))) + _ + (list)))) (let [{#module-hash _ #module-aliases _ #defs defs #imports _ #tags tags #types types #module-anns _ #module-state _} =module] defs))] (#Right state (List/join to-alias))) @@ -4093,9 +4093,9 @@ (def: (is-member? cases name) (-> (List Text) Text Bool) - (let [output (fold (lambda [case prev] - (or prev - (Text/= case name))) + (let [output (fold (function [case prev] + (or prev + (Text/= case name))) false cases)] output)) @@ -4115,16 +4115,16 @@ #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} (find (: (-> Scope (Maybe Type)) - (lambda [env] - (case env - {#name _ #inner-closures _ #locals {#counter _ #mappings locals} #closure {#counter _ #mappings closure}} - (try-both (find (: (-> [Text Analysis] (Maybe Type)) - (lambda [[bname [[type _] _]]] - (if (Text/= name bname) - (#Some type) - #None)))) - locals - closure)))) + (function [env] + (case env + {#name _ #inner-closures _ #locals {#counter _ #mappings locals} #closure {#counter _ #mappings closure}} + (try-both (find (: (-> [Text Analysis] (Maybe Type)) + (function [[bname [[type _] _]]] + (if (Text/= name bname) + (#Some type) + #None)))) + locals + closure)))) scopes))) (def: (find-def-type name state) @@ -4170,26 +4170,26 @@ (do Monad<Lux> [#let [[module name] ident] current-module current-module-name] - (lambda [state] - (if (Text/= "" module) - (case (find-in-env name state) - (#Some struct-type) - (#Right state struct-type) + (function [state] + (if (Text/= "" module) + (case (find-in-env name state) + (#Some struct-type) + (#Right state struct-type) - _ - (case (find-def-type [current-module name] state) - (#Some struct-type) - (#Right state struct-type) + _ + (case (find-def-type [current-module name] state) + (#Some struct-type) + (#Right state struct-type) - _ - (#Left ($_ Text/append "Unknown var: " (Ident/encode ident))))) - (case (find-def-type ident state) - (#Some struct-type) - (#Right state struct-type) + _ + (#Left ($_ Text/append "Unknown var: " (Ident/encode ident))))) + (case (find-def-type ident state) + (#Some struct-type) + (#Right state struct-type) - _ - (#Left ($_ Text/append "Unknown var: " (Ident/encode ident))))) - ))) + _ + (#Left ($_ Text/append "Unknown var: " (Ident/encode ident))))) + ))) (def: (zip2 xs ys) (All [a b] (-> (List a) (List b) (List [a b]))) @@ -4280,27 +4280,27 @@ (#;Some tags&members) (do Monad<Lux> [full-body ((: (-> Ident [(List Ident) (List Type)] AST (Lux AST)) - (lambda recur [source [tags members] target] - (let [pattern (record$ (map (lambda [[t-module t-name]] - [(tag$ [t-module t-name]) - (symbol$ ["" (Text/append prefix t-name)])]) - tags))] - (do Monad<Lux> - [enhanced-target (foldM Monad<Lux> - (lambda [[[_ m-name] m-type] enhanced-target] - (do Monad<Lux> - [m-structure (resolve-type-tags m-type)] - (case m-structure - (#;Some m-tags&members) - (recur ["" (Text/append prefix m-name)] - m-tags&members - enhanced-target) - - #;None - (wrap enhanced-target)))) - target - (zip2 tags members))] - (wrap (` (;_lux_case (~ (symbol$ source)) (~ pattern) (~ enhanced-target)))))))) + (function recur [source [tags members] target] + (let [pattern (record$ (map (function [[t-module t-name]] + [(tag$ [t-module t-name]) + (symbol$ ["" (Text/append prefix t-name)])]) + tags))] + (do Monad<Lux> + [enhanced-target (foldM Monad<Lux> + (function [[[_ m-name] m-type] enhanced-target] + (do Monad<Lux> + [m-structure (resolve-type-tags m-type)] + (case m-structure + (#;Some m-tags&members) + (recur ["" (Text/append prefix m-name)] + m-tags&members + enhanced-target) + + #;None + (wrap enhanced-target)))) + target + (zip2 tags members))] + (wrap (` (;_lux_case (~ (symbol$ source)) (~ pattern) (~ enhanced-target)))))))) name tags&members body)] (wrap (list full-body))))) @@ -4336,9 +4336,9 @@ (case (reverse tokens) (^ (list& else branches')) (return (list (fold (: (-> [AST AST] AST AST) - (lambda [branch else] - (let [[right left] branch] - (` (if (~ left) (~ right) (~ else)))))) + (function [branch else] + (let [[right left] branch] + (` (if (~ left) (~ right) (~ else)))))) else (as-pairs branches')))) @@ -4380,10 +4380,10 @@ (case (resolve-struct-type type) (#Some members) (let [pattern (record$ (map (: (-> [Ident [Nat Type]] [AST AST]) - (lambda [[[r-prefix r-name] [r-idx r-type]]] - [(tag$ [r-prefix r-name]) (if (n.= idx r-idx) - g!output - g!_)])) + (function [[[r-prefix r-name] [r-idx r-type]]] + [(tag$ [r-prefix r-name]) (if (n.= idx r-idx) + g!output + g!_)])) (zip2 tags (enumerate members))))] (return (list (` (;_lux_case (~ record) (~ pattern) (~ g!output)))))) @@ -4392,15 +4392,15 @@ (^ (list [_ (#TupleS slots)] record)) (return (list (fold (: (-> AST AST AST) - (lambda [slot inner] - (` (;;get@ (~ slot) (~ inner))))) + (function [slot inner] + (` (;;get@ (~ slot) (~ inner))))) record slots))) (^ (list selector)) (do Monad<Lux> [g!record (gensym "record")] - (wrap (list (` (lambda [(~ g!record)] (;;get@ (~ selector) (~ g!record))))))) + (wrap (list (` (function [(~ g!record)] (;;get@ (~ selector) (~ g!record))))))) _ (fail "Wrong syntax for get@"))) @@ -4415,7 +4415,7 @@ (do Monad<Lux> [decls' (mapM Monad<Lux> (: (-> [Ident Type] (Lux (List AST))) - (lambda [[sname stype]] (open-field prefix sname source+ stype))) + (function [[sname stype]] (open-field prefix sname source+ stype))) (zip2 tags members))] (return (List/join decls'))) @@ -4449,7 +4449,7 @@ (#Some [tags members]) (do Monad<Lux> [decls' (mapM Monad<Lux> (: (-> [Ident Type] (Lux (List AST))) - (lambda [[sname stype]] (open-field prefix sname source stype))) + (function [[sname stype]] (open-field prefix sname source stype))) (zip2 tags members))] (return (List/join decls'))) @@ -4463,13 +4463,13 @@ {#;doc "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it. (|> (map Int/encode) (interpose \" \") (fold Text/append \"\")) ## => - (lambda [<something>] + (function [<something>] (fold Text/append \"\" (interpose \" \" (map Int/encode <something>))))"} (do Monad<Lux> [g!arg (gensym "arg")] - (return (list (` (lambda [(~ g!arg)] (|> (~ g!arg) (~@ tokens)))))))) + (return (list (` (function [(~ g!arg)] (|> (~ g!arg) (~@ tokens)))))))) (def: (imported-by? import-name module-name) (-> Text Text (Lux Bool)) @@ -4487,14 +4487,14 @@ #let [[openings options] openings+options] current-module current-module-name #let [test-referrals (: (-> Text (List Text) (List Text) (Lux (List Unit))) - (lambda [module-name all-defs referred-defs] - (mapM Monad<Lux> - (: (-> Text (Lux Unit)) - (lambda [_def] - (if (is-member? all-defs _def) - (return []) - (fail ($_ Text/append _def " is not defined in module " module-name " @ " current-module))))) - referred-defs)))]] + (function [module-name all-defs referred-defs] + (mapM Monad<Lux> + (: (-> Text (Lux Unit)) + (function [_def] + (if (is-member? all-defs _def) + (return []) + (fail ($_ Text/append _def " is not defined in module " module-name " @ " current-module))))) + referred-defs)))]] (case options #;Nil (wrap {#refer-defs referral @@ -4512,14 +4512,14 @@ (do Monad<Lux> [current-module current-module-name #let [test-referrals (: (-> Text (List Text) (List Text) (Lux (List Unit))) - (lambda [module-name all-defs referred-defs] - (mapM Monad<Lux> - (: (-> Text (Lux Unit)) - (lambda [_def] - (if (is-member? all-defs _def) - (return []) - (fail ($_ Text/append _def " is not defined in module " module-name " @ " current-module))))) - referred-defs)))] + (function [module-name all-defs referred-defs] + (mapM Monad<Lux> + (: (-> Text (Lux Unit)) + (function [_def] + (if (is-member? all-defs _def) + (return []) + (fail ($_ Text/append _def " is not defined in module " module-name " @ " current-module))))) + referred-defs)))] defs' (case r-defs #All (exported-defs module-name) @@ -4539,16 +4539,16 @@ #Nothing (wrap (list))) #let [defs (map (: (-> Text AST) - (lambda [def] - (` (;_lux_def (~ (symbol$ ["" def])) - (~ (symbol$ [module-name def])) - (#Cons [["lux" "alias"] (#IdentA [(~ (text$ module-name)) (~ (text$ def))])] - #Nil))))) + (function [def] + (` (;_lux_def (~ (symbol$ ["" def])) + (~ (symbol$ [module-name def])) + (#Cons [["lux" "alias"] (#IdentA [(~ (text$ module-name)) (~ (text$ def))])] + #Nil))))) defs') openings (join-map (: (-> Openings (List AST)) - (lambda [[prefix structs]] - (map (lambda [[_ name]] (` (open (~ (symbol$ [module-name name])) (~ (text$ prefix))))) - structs))) + (function [[prefix structs]] + (map (function [[_ name]] (` (open (~ (symbol$ [module-name name])) (~ (text$ prefix))))) + structs))) r-opens)]] (wrap (List/append defs openings)) )) @@ -4580,8 +4580,8 @@ #Nothing (list))) - =opens (join-map (lambda [[prefix structs]] - (list& (text$ prefix) (map symbol$ structs))) + =opens (join-map (function [[prefix structs]] + (list& (text$ prefix) (map symbol$ structs))) r-opens)] (` (;;refer (~ (text$ module-name)) (~@ =defs) @@ -4624,12 +4624,12 @@ [(list) tokens]))] imports (parse-imports _imports) #let [=imports (map (: (-> Importation AST) - (lambda [[m-name m-alias =refer]] - (` [(~ (text$ m-name)) (~ (text$ (default "" m-alias)))]))) + (function [[m-name m-alias =refer]] + (` [(~ (text$ m-name)) (~ (text$ (default "" m-alias)))]))) imports) =refers (map (: (-> Importation AST) - (lambda [[m-name m-alias =refer]] - (refer-to-ast m-name =refer))) + (function [[m-name m-alias =refer]] + (refer-to-ast m-name =refer))) imports)] =meta (process-def-meta (record$ (list& [(` #;imports) (` [(~@ =imports)])] _meta))) @@ -4677,20 +4677,20 @@ (do Monad<Lux> [pattern' (mapM Monad<Lux> (: (-> [Ident [Nat Type]] (Lux [Ident Nat AST])) - (lambda [[r-slot-name [r-idx r-type]]] - (do Monad<Lux> - [g!slot (gensym "")] - (return [r-slot-name r-idx g!slot])))) + (function [[r-slot-name [r-idx r-type]]] + (do Monad<Lux> + [g!slot (gensym "")] + (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] (let [pattern (record$ (map (: (-> [Ident Nat AST] [AST AST]) - (lambda [[r-slot-name r-idx r-var]] - [(tag$ r-slot-name) r-var])) + (function [[r-slot-name r-idx r-var]] + [(tag$ r-slot-name) r-var])) pattern')) output (record$ (map (: (-> [Ident Nat AST] [AST AST]) - (lambda [[r-slot-name r-idx r-var]] - [(tag$ r-slot-name) (if (n.= idx r-idx) - value - r-var)])) + (function [[r-slot-name r-idx r-var]] + [(tag$ r-slot-name) (if (n.= idx r-idx) + value + r-var)])) pattern'))] (return (list (` (;_lux_case (~ record) (~ pattern) (~ output))))))) @@ -4706,18 +4706,18 @@ (do Monad<Lux> [bindings (mapM Monad<Lux> (: (-> AST (Lux AST)) - (lambda [_] (gensym "temp"))) + (function [_] (gensym "temp"))) slots) #let [pairs (zip2 slots bindings) update-expr (fold (: (-> [AST AST] AST AST) - (lambda [[s b] v] - (` (;;set@ (~ s) (~ v) (~ b))))) + (function [[s b] v] + (` (;;set@ (~ s) (~ v) (~ b))))) value (reverse pairs)) [_ accesses'] (fold (: (-> [AST AST] [AST (List (List AST))] [AST (List (List AST))]) - (lambda [[new-slot new-binding] [old-record accesses']] - [(` (get@ (~ new-slot) (~ new-binding))) - (#;Cons (list new-binding old-record) accesses')])) + (function [[new-slot new-binding] [old-record accesses']] + [(` (get@ (~ new-slot) (~ new-binding))) + (#;Cons (list new-binding old-record) accesses')])) [record (: (List (List AST)) #;Nil)] pairs) accesses (List/join (reverse accesses'))]] @@ -4727,13 +4727,13 @@ (^ (list selector value)) (do Monad<Lux> [g!record (gensym "record")] - (wrap (list (` (lambda [(~ g!record)] (;;set@ (~ selector) (~ value) (~ g!record))))))) + (wrap (list (` (function [(~ g!record)] (;;set@ (~ selector) (~ value) (~ g!record))))))) (^ (list selector)) (do Monad<Lux> [g!value (gensym "value") g!record (gensym "record")] - (wrap (list (` (lambda [(~ g!value) (~ g!record)] (;;set@ (~ selector) (~ g!value) (~ g!record))))))) + (wrap (list (` (function [(~ g!value) (~ g!record)] (;;set@ (~ selector) (~ g!value) (~ g!record))))))) _ (fail "Wrong syntax for set@"))) @@ -4763,20 +4763,20 @@ (do Monad<Lux> [pattern' (mapM Monad<Lux> (: (-> [Ident [Nat Type]] (Lux [Ident Nat AST])) - (lambda [[r-slot-name [r-idx r-type]]] - (do Monad<Lux> - [g!slot (gensym "")] - (return [r-slot-name r-idx g!slot])))) + (function [[r-slot-name [r-idx r-type]]] + (do Monad<Lux> + [g!slot (gensym "")] + (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] (let [pattern (record$ (map (: (-> [Ident Nat AST] [AST AST]) - (lambda [[r-slot-name r-idx r-var]] - [(tag$ r-slot-name) r-var])) + (function [[r-slot-name r-idx r-var]] + [(tag$ r-slot-name) r-var])) pattern')) output (record$ (map (: (-> [Ident Nat AST] [AST AST]) - (lambda [[r-slot-name r-idx r-var]] - [(tag$ r-slot-name) (if (n.= idx r-idx) - (` ((~ fun) (~ r-var))) - r-var)])) + (function [[r-slot-name r-idx r-var]] + [(tag$ r-slot-name) (if (n.= idx r-idx) + (` ((~ fun) (~ r-var))) + r-var)])) pattern'))] (return (list (` (;_lux_case (~ record) (~ pattern) (~ output))))))) @@ -4799,13 +4799,13 @@ (^ (list selector fun)) (do Monad<Lux> [g!record (gensym "record")] - (wrap (list (` (lambda [(~ g!record)] (;;update@ (~ selector) (~ fun) (~ g!record))))))) + (wrap (list (` (function [(~ g!record)] (;;update@ (~ selector) (~ fun) (~ g!record))))))) (^ (list selector)) (do Monad<Lux> [g!fun (gensym "fun") g!record (gensym "record")] - (wrap (list (` (lambda [(~ g!fun) (~ g!record)] (;;update@ (~ selector) (~ g!fun) (~ g!record))))))) + (wrap (list (` (function [(~ g!fun) (~ g!record)] (;;update@ (~ selector) (~ g!fun) (~ g!record))))))) _ (fail "Wrong syntax for update@"))) @@ -4856,7 +4856,7 @@ data' (mapM Monad<Maybe> tuple->list data)] (if (every? (i.= (length bindings')) (map length data')) (let [apply (: (-> RepEnv (List AST)) - (lambda [env] (map (apply-template env) templates)))] + (function [env] (map (apply-template env) templates)))] (|> data' (join-map (. apply (make-env bindings'))) wrap)) @@ -5016,9 +5016,9 @@ (^template [<tag> <open> <close> <prep>] [group-cursor (<tag> parts)] - (let [[group-cursor' parts-text] (fold (lambda [part [last-cursor text-accum]] - (let [[part-cursor part-text] (doc-example->Text last-cursor baseline part)] - [part-cursor (Text/append text-accum part-text)])) + (let [[group-cursor' parts-text] (fold (function [part [last-cursor text-accum]] + (let [[part-cursor part-text] (doc-example->Text last-cursor baseline part)] + [part-cursor (Text/append text-accum part-text)])) [(delim-update-cursor group-cursor) ""] (<prep> parts))] [(delim-update-cursor group-cursor') @@ -5041,7 +5041,7 @@ (#Doc-Comment comment) (|> comment (split-text "\n") - (map (lambda [line] ($_ Text/append "## " line "\n"))) + (map (function [line] ($_ Text/append "## " line "\n"))) Text/join) (#Doc-Example example) @@ -5148,13 +5148,13 @@ expected get-expected-type] (return (list (` ((;_lux_: (-> (~@ (map type-to-ast init-types)) (~ (type-to-ast expected))) - (lambda (~ (symbol$ ["" "recur"])) [(~@ vars)] - (~ body))) + (function (~ (symbol$ ["" "recur"])) [(~@ vars)] + (~ body))) (~@ inits)))))) (do Monad<Lux> [aliases (mapM Monad<Lux> (: (-> AST (Lux AST)) - (lambda [_] (gensym ""))) + (function [_] (gensym ""))) inits)] (return (list (` (let [(~@ (interleave aliases inits))] (;loop [(~@ (interleave vars aliases))] @@ -5189,14 +5189,14 @@ g!_ (gensym "_") #let [[idx tags exported? type] output slot-pairings (map (: (-> Ident [Text AST]) - (lambda [[module name]] [name (symbol$ ["" name])])) + (function [[module name]] [name (symbol$ ["" name])])) (list& hslot tslots)) pattern (record$ (map (: (-> Ident [AST AST]) - (lambda [[module name]] - (let [tag (tag$ [module name])] - (case (get name slot-pairings) - (#Some binding) [tag binding] - #None [tag g!_])))) + (function [[module name]] + (let [tag (tag$ [module name])] + (case (get name slot-pairings) + (#Some binding) [tag binding] + #None [tag g!_])))) tags))]] (return (list& pattern body branches))) @@ -5227,16 +5227,16 @@ (do Monad<Maybe> [=pairs (mapM Monad<Maybe> (: (-> [AST AST] (Maybe [AST AST])) - (lambda [[slot value]] - (do Monad<Maybe> - [slot' (place-tokens label tokens slot) - value' (place-tokens label tokens value)] - (case [slot' value'] - (^ [(list =slot) (list =value)]) - (wrap [=slot =value]) + (function [[slot value]] + (do Monad<Maybe> + [slot' (place-tokens label tokens slot) + value' (place-tokens label tokens value)] + (case [slot' value'] + (^ [(list =slot) (list =value)]) + (wrap [=slot =value]) - _ - #None)))) + _ + #None)))) pairs)] (wrap (list (record$ =pairs)))) )) @@ -5348,10 +5348,10 @@ (do Monad<Lux> [=pairs (mapM Monad<Lux> (: (-> [AST AST] (Lux [AST AST])) - (lambda [[slot value]] - (do Monad<Lux> - [=value (anti-quote value)] - (wrap [slot =value])))) + (function [[slot value]] + (do Monad<Lux> + [=value (anti-quote value)] + (wrap [slot =value])))) pairs)] (wrap [meta (#RecordS =pairs)])) @@ -5413,13 +5413,13 @@ (def: (multi-level-case$ g!_ [[init-pattern levels] body]) (-> AST [MultiLevelCase AST] (List AST)) - (let [inner-pattern-body (fold (lambda [[calculation pattern] success] - (` (case (~ calculation) - (~ pattern) - (~ success) + (let [inner-pattern-body (fold (function [[calculation pattern] success] + (` (case (~ calculation) + (~ pattern) + (~ success) - (~ g!_) - #;None))) + (~ g!_) + #;None))) (` (#;Some (~ body))) (: (List [AST AST]) (reverse levels)))] (list init-pattern inner-pattern-body))) @@ -5551,7 +5551,7 @@ (macro: #export (^@ tokens) {#;doc (doc "Allows you to simultaneously bind and de-structure a value." (def: (hash (^@ set [Hash<a> _])) - (List/fold (lambda [elem acc] (n.+ (:: Hash<a> hash elem) acc)) + (List/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc)) +0 (to-list set))))} (case tokens @@ -5657,13 +5657,13 @@ (^ (list& [_ (#FormS (list& [_ (#SymbolS ["" name])] args'))] tokens')) (do Monad<Lux> [args (mapM Monad<Lux> - (lambda [arg'] - (case arg' - [_ (#SymbolS ["" arg-name])] - (wrap arg-name) + (function [arg'] + (case arg' + [_ (#SymbolS ["" arg-name])] + (wrap arg-name) - _ - (fail "Couldn't parse an argument."))) + _ + (fail "Couldn't parse an argument."))) args')] (wrap [[name args] tokens'])) @@ -5719,8 +5719,8 @@ g!tokens (gensym "tokens") g!compiler (gensym "compiler") g!_ (gensym "_") - #let [rep-env (map (lambda [arg] - [arg (` ((~' ~) (~ (symbol$ ["" arg]))))]) + #let [rep-env (map (function [arg] + [arg (` ((~' ~) (~ (symbol$ ["" arg]))))]) args)]] (wrap (list (` (macro: (~@ (gen-export-level ?export-level)) ((~ (symbol$ ["" name])) (~ g!tokens) (~ g!compiler)) diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index 8a89c3bc1..4d729af37 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -61,7 +61,7 @@ (def: #export any {#;doc "Just returns the next input without applying any logic."} (CLI Text) - (lambda [inputs] + (function [inputs] (case inputs (#;Cons arg inputs') (#;Right [inputs' arg]) @@ -72,7 +72,7 @@ (def: #export (parse parser) {#;doc "Parses the next input with a parsing function."} (All [a] (-> (-> Text (Error a)) (CLI a))) - (lambda [inputs] + (function [inputs] (case inputs (#;Cons arg inputs') (case (parser arg) @@ -88,7 +88,7 @@ (def: #export (option names) {#;doc "Checks that a given option (with multiple possible names) has a value."} (-> (List Text) (CLI Text)) - (lambda [inputs] + (function [inputs] (let [[pre post] (list;split-with (. ;not (list;member? text;Eq<Text> names)) inputs)] (case post #;Nil @@ -104,7 +104,7 @@ (def: #export (flag names) {#;doc "Checks that a given flag (with multiple possible names) is set."} (-> (List Text) (CLI Bool)) - (lambda [inputs] + (function [inputs] (let [[pre post] (list;split-with (. ;not (list;member? text;Eq<Text> names)) inputs)] (case post #;Nil @@ -116,7 +116,7 @@ (def: #export end {#;doc "Ensures there are no more inputs."} (CLI Unit) - (lambda [inputs] + (function [inputs] (case inputs #;Nil (#;Right [inputs []]) _ (#;Left (Text/append "Unknown parameters: " (text;join-with " " inputs)))))) @@ -124,7 +124,7 @@ (def: #export (assert message test) {#;doc "Fails with the given message if the test is false."} (-> Text Bool (CLI Unit)) - (lambda [inputs] + (function [inputs] (if test (#;Right [inputs []]) (#;Left message)))) @@ -133,7 +133,7 @@ {#;doc "Optionality combinator."} (All [a] (-> (CLI a) (CLI (Maybe a)))) - (lambda [inputs] + (function [inputs] (case (opt inputs) (#;Left _) (#;Right [inputs #;None]) (#;Right [inputs' x]) (#;Right [inputs' (#;Some x)])))) @@ -149,7 +149,7 @@ (def: #export (alt optL optR) {#;doc "Heterogeneous alternative combinator."} (All [a b] (-> (CLI a) (CLI b) (CLI (| a b)))) - (lambda [inputs] + (function [inputs] (case (optL inputs) (#;Left msg) (case (optR inputs) @@ -165,7 +165,7 @@ (def: #export (not opt) {#;doc "The opposite of the given CLI."} (All [a] (-> (CLI a) (CLI Unit))) - (lambda [inputs] + (function [inputs] (case (opt inputs) (#;Left msg) (#;Right [inputs []]) @@ -177,7 +177,7 @@ {#;doc "0-or-more combinator."} (All [a] (-> (CLI a) (CLI (List a)))) - (lambda [inputs] + (function [inputs] (case (opt inputs) (#;Left _) (#;Right [inputs (list)]) (#;Right [inputs' x]) (run' (do Monad<CLI> @@ -198,7 +198,7 @@ {#;doc "Homogeneous alternative combinator."} (All [a] (-> (CLI a) (CLI a) (CLI a))) - (lambda [inputs] + (function [inputs] (case (pl inputs) (#;Left _) (pr inputs) output output))) @@ -252,7 +252,7 @@ (case ((: (CLI (io;IO Unit)) (do Monad<CLI> [(~@ (|> args - (List/map (lambda [[name parser]] + (List/map (function [[name parser]] (list (ast;symbol ["" name]) parser))) List/join)) (~ g!_) end] diff --git a/stdlib/source/lux/compiler.lux b/stdlib/source/lux/compiler.lux index fe503113a..0f95defb6 100644 --- a/stdlib/source/lux/compiler.lux +++ b/stdlib/source/lux/compiler.lux @@ -17,7 +17,7 @@ (struct: #export _ (Functor Lux) (def: (map f fa) - (lambda [state] + (function [state] (case (fa state) (#;Left msg) (#;Left msg) @@ -29,11 +29,11 @@ (def: functor Functor<Lux>) (def: (wrap x) - (lambda [state] + (function [state] (#;Right [state x]))) (def: (apply ff fa) - (lambda [state] + (function [state] (case (ff state) (#;Right [state' f]) (case (fa state') @@ -50,7 +50,7 @@ (def: applicative Applicative<Lux>) (def: (join mma) - (lambda [state] + (function [state] (case (mma state) (#;Left msg) (#;Left msg) @@ -86,7 +86,7 @@ (def: #export (either left right) {#;doc "Pick whichever computation succeeds."} (All [a] (-> (Lux a) (Lux a) (Lux a))) - (lambda [compiler] + (function [compiler] (case (left compiler) (#;Left error) (right compiler) @@ -97,7 +97,7 @@ (def: #export (assert message test) {#;doc "Fails with the given message if the test is false."} (-> Text Bool (Lux Unit)) - (lambda [compiler] + (function [compiler] (if test (#;Right [compiler []]) (#;Left message)))) @@ -106,12 +106,12 @@ {#;doc "Fails with the given message."} (All [a] (-> Text (Lux a))) - (lambda [_] + (function [_] (#;Left msg))) (def: #export (find-module name) (-> Text (Lux Module)) - (lambda [state] + (function [state] (case (get name (get@ #;modules state)) (#;Some module) (#;Right [state module]) @@ -121,7 +121,7 @@ (def: #export current-module-name (Lux Text) - (lambda [state] + (function [state] (case (list;last (get@ #;scopes state)) (#;Some scope) (case (get@ #;name scope) @@ -255,7 +255,7 @@ [this-module current-module-name] (let [[module name] ident] (: (Lux (Maybe Macro)) - (lambda [state] + (function [state] (#;Right [state (find-macro' (get@ #;modules state) this-module module name)])))))) (def: #export (normalize ident) @@ -354,7 +354,7 @@ A prefix can be given (or just be empty text \"\") to better identify the code for debugging purposes."} (-> Text (Lux AST)) - (lambda [state] + (function [state] (#;Right [(update@ #;seed n.inc state) (ast;symbol ["" ($_ Text/append "__gensym__" prefix (:: number;Codec<Text,Nat> encode (get@ #;seed state)))])]))) @@ -382,7 +382,7 @@ (do Monad<Lux> [symbol-names (mapM @ get-local-symbol symbols) #let [symbol-defs (List/join (List/map (: (-> Text (List AST)) - (lambda [name] (list (ast;symbol ["" name]) (` (gensym (~ (ast;text name))))))) + (function [name] (list (ast;symbol ["" name]) (` (gensym (~ (ast;text name))))))) symbol-names))]] (wrap (list (` (do Monad<Lux> [(~@ symbol-defs)] @@ -405,7 +405,7 @@ (def: #export (module-exists? module) (-> Text (Lux Bool)) - (lambda [state] + (function [state] (#;Right [state (case (get module (get@ #;modules state)) (#;Some _) true @@ -423,11 +423,11 @@ (def: #export (find-var-type name) {#;doc "Looks-up the type of a local variable somewhere in the environment."} (-> Text (Lux Type)) - (lambda [state] + (function [state] (let [test (: (-> [Text Analysis] Bool) (|>. product;left (Text/= name)))] (case (do Monad<Maybe> - [scope (find (lambda [env] + [scope (find (function [env] (or (any? test (get@ [#;locals #;mappings] env)) (any? test (get@ [#;closure #;mappings] env)))) (get@ #;scopes state)) @@ -444,7 +444,7 @@ (def: #export (find-def name) {#;doc "Looks-up a definition's whole data in the available modules (including the current one)."} (-> Ident (Lux Def)) - (lambda [state] + (function [state] (case (: (Maybe Def) (do Monad<Maybe> [#let [[v-prefix v-name] name] @@ -483,7 +483,7 @@ (def: #export (defs module-name) {#;doc "The entire list of definitions in a module (including the unexported/private ones)."} (-> Text (Lux (List [Text Def]))) - (lambda [state] + (function [state] (case (get module-name (get@ #;modules state)) #;None (#;Left ($_ Text/append "Unknown module: " module-name)) (#;Some module) (#;Right [state (get@ #;defs module)]) @@ -494,7 +494,7 @@ (-> Text (Lux (List [Text Def]))) (do Monad<Lux> [defs (defs module-name)] - (wrap (filter (lambda [[name [def-type def-anns def-value]]] + (wrap (filter (function [[name [def-type def-anns def-value]]] (and (export? def-anns) (not (hidden? def-anns)))) defs)))) @@ -502,7 +502,7 @@ (def: #export modules {#;doc "All the available modules (including the current one)."} (Lux (List [Text Module])) - (lambda [state] + (function [state] (|> state (get@ #;modules) [state] @@ -524,13 +524,13 @@ (def: #export cursor {#;doc "The cursor of the current expression being analyzed."} (Lux Cursor) - (lambda [state] + (function [state] (#;Right [state (get@ #;cursor state)]))) (def: #export expected-type {#;doc "The expected type of the current expression being analyzed."} (Lux Type) - (lambda [state] + (function [state] (case (get@ #;expected state) (#;Some type) (#;Right [state type]) @@ -569,16 +569,16 @@ [=module (find-module module) this-module-name current-module-name] (wrap (|> (get@ #;types =module) - (list;filter (lambda [[type-name [tag-list exported? type]]] + (list;filter (function [[type-name [tag-list exported? type]]] (or exported? (Text/= this-module-name module)))) - (List/map (lambda [[type-name [tag-list exported? type]]] + (List/map (function [[type-name [tag-list exported? type]]] [tag-list type])))))) (def: #export locals {#;doc "All the local variables currently in scope, separated in different scopes."} (Lux (List (List [Text Type]))) - (lambda [state] + (function [state] (case (list;inits (get@ #;scopes state)) #;None (#;Left "No local environment") @@ -586,7 +586,7 @@ (#;Some scopes) (#;Right [state (List/map (|>. (get@ [#;locals #;mappings]) - (List/map (lambda [[name [[type cursor] analysis]]] + (List/map (function [[name [[type cursor] analysis]]] [name type]))) scopes)])))) @@ -606,5 +606,5 @@ (def: #export get-compiler {#;doc "Obtains the current state of the compiler."} (Lux Compiler) - (lambda [compiler] + (function [compiler] (#;Right [compiler compiler]))) diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index 56b40f41b..281e42fdd 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -44,7 +44,7 @@ step (step self) |mailbox| (stm;var mailbox-chan) _ (:: Monad<Promise> map - (lambda [_] + (function [_] (io;run (do Monad<IO> [mb (stm;read! |mailbox|)] (frp;close mb)))) @@ -111,7 +111,7 @@ (All [s m] (-> s (Behavior s m) (IO (Actor s m)))) (io (let [ka-actor (: (Actor (Actor ($ +0) ($ +1)) ($ +1)) (io;run (spawn (io;run (spawn init behavior)) - {#step (lambda [*self* message server] + {#step (function [*self* message server] (do Monad<Promise> [was-sent? (send message server)] (if was-sent? @@ -127,11 +127,11 @@ _ (P;future (mapM io;Monad<IO> ((flip stm;write!) mailbox) (#;Cons message unprocessed-messages)))] (wrap (#;Right new-server)))) )))) - #end (lambda [_ server] (exec (io;run (poison server)) + #end (function [_ server] (exec (io;run (poison server)) (:: Monad<Promise> wrap [])))})))] (update@ #obituary (: (-> (P;Promise [(Maybe Text) (Actor ($ +0) ($ +1)) (List ($ +1))]) (P;Promise [(Maybe Text) ($ +0) (List ($ +1))])) - (lambda [process] + (function [process] (do Monad<Promise> [[_ server unprocessed-messages-0] process [cause state unprocessed-messages-1] (get@ #obituary server)] @@ -219,14 +219,14 @@ g!state (ast;symbol ["" "*state*"]) g!cause (ast;symbol ["" "*cause*"]) g!stop-body (default (` (:: P;Monad<Promise> (~' wrap) [])) ?stop) - protocol (List/map (lambda [(^slots [#name #vars #args #return #body])] + protocol (List/map (function [(^slots [#name #vars #args #return #body])] (` ((~ (ast;tag ["" name])) [(~@ (List/map product;right args))] (P;Promise (~ return))))) methods) protocol-pm (List/map (: (-> Method [AST AST]) - (lambda [(^slots [#name #vars #args #return #body])] + (function [(^slots [#name #vars #args #return #body])] (let [arg-names (|> (list;size args) (list;n.range +1) (List/map (|>. Nat/encode [""] ast;symbol))) body-func (` (: (-> (~ g!state-name) (~@ (List/map product;right args)) (P;Promise (Error [(~ g!state-name) (~ return)]))) - (lambda (~ (ast;symbol ["" _name])) [(~ g!state) (~@ (List/map (|>. product;left [""] ast;symbol) args))] + (function (~ (ast;symbol ["" _name])) [(~ g!state) (~@ (List/map (|>. product;left [""] ast;symbol) args))] (do P;Monad<Promise> [] (~ body)))))] @@ -242,24 +242,24 @@ ((~' wrap) (#;Left (~ g!error)))) ))]))) methods) - g!behavior (` {#step (lambda [(~ g!self) (~ g!message) (~ g!state)] + g!behavior (` {#step (function [(~ g!self) (~ g!message) (~ g!state)] (case (~ g!message) (~@ (if (n.= +1 (list;size protocol-pm)) - (List/join (List/map (lambda [[pattern clause]] + (List/join (List/map (function [[pattern clause]] (list pattern clause)) protocol-pm)) - (List/join (List/map (lambda [[method [pattern clause]]] + (List/join (List/map (function [[method [pattern clause]]] (list (` ((~ (ast;tag ["" (get@ #name method)])) (~ pattern))) clause)) (list;zip2 methods protocol-pm))))) )) - #end (lambda [(~ g!cause) (~ g!state)] + #end (function [(~ g!cause) (~ g!state)] (do P;Monad<Promise> [] (~ g!stop-body)))}) g!actor-name (ast;symbol ["" _name]) g!methods (List/map (: (-> Method AST) - (lambda [(^slots [#name #vars #args #return #body])] + (function [(^slots [#name #vars #args #return #body])] (let [arg-names (|> (list;size args) (list;n.range +1) (List/map (|>. Nat/encode [""] ast;symbol))) type (` (-> (~@ (List/map product;right args)) (~ g!actor-name) diff --git a/stdlib/source/lux/concurrency/atom.lux b/stdlib/source/lux/concurrency/atom.lux index f2ec8b46c..fdb9754f7 100644 --- a/stdlib/source/lux/concurrency/atom.lux +++ b/stdlib/source/lux/concurrency/atom.lux @@ -35,4 +35,4 @@ (def: #export (set value atom) (All [a] (-> a (Atom a) (IO Unit))) - (update (lambda [_] value) atom)) + (update (function [_] value) atom)) diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index 6d18a73bb..a45d01485 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -106,7 +106,7 @@ (All [a] (-> (List (Chan a)) (Chan a))) (let [output (chan ($ +0))] (exec (do &;Monad<Promise> - [_ (mapM @ (lambda [input] (pipe' input output)) xss)] + [_ (mapM @ (function [input] (pipe' input output)) xss)] (exec (io;run (close output)) (wrap []))) output))) @@ -240,7 +240,7 @@ (def: #export (sliding-window max inputs) (All [a] (-> Nat (Chan a) (Chan (List a)))) (let [(^open) &;Monad<Promise>] - (folds (lambda [input window] + (folds (function [input window] (let [window' (L/append window (list input))] (wrap (if (n.<= max (list;size window')) window' @@ -286,7 +286,7 @@ (struct: #export _ (Functor Chan) (def: (map f xs) (:: &;Functor<Promise> map - (lambda [?x+xs] + (function [?x+xs] (case ?x+xs #;None #;None (#;Some [x xs']) (#;Some [(f x) (map f xs')]))) @@ -302,7 +302,7 @@ (def: (apply ff fa) (let [fb (chan ($ +1))] (exec (let [(^open) Functor<Chan>] - (map (lambda [f] (pipe (map f fa) fb)) + (map (function [f] (pipe (map f fa) fb)) ff)) fb)))) @@ -312,7 +312,7 @@ (def: (join mma) (let [output (chan ($ +0))] (exec (let [(^open) Functor<Chan>] - (map (lambda [ma] + (map (function [ma] (pipe ma output)) mma)) output)))) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index e94aa68e5..0d3619925 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -77,7 +77,7 @@ succeeded? (atom;compare-and-swap old new promise)] (if succeeded? (do @ - [_ (mapM @ (lambda [f] (f value)) + [_ (mapM @ (function [f] (f value)) (get@ #observers old))] (wrap true)) (resolve value promise)))))) @@ -98,9 +98,9 @@ (struct: #export _ (Functor Promise) (def: (map f fa) (let [fb (promise ($ +1))] - (exec (await (lambda [a] (do Monad<IO> - [_ (resolve (f a) fb)] - (wrap []))) + (exec (await (function [a] (do Monad<IO> + [_ (resolve (f a) fb)] + (wrap []))) fa) fb)))) @@ -113,10 +113,10 @@ (def: (apply ff fa) (let [fb (promise ($ +1))] - (exec (await (lambda [f] - (io (await (lambda [a] (do Monad<IO> - [_ (resolve (f a) fb)] - (wrap []))) + (exec (await (function [f] + (io (await (function [a] (do Monad<IO> + [_ (resolve (f a) fb)] + (wrap []))) fa))) ff) fb)) @@ -127,8 +127,8 @@ (def: (join mma) (let [ma (promise ($ +0))] - (exec (await (lambda [ma'] - (io (await (lambda [a'] + (exec (await (function [ma'] + (io (await (function [a'] (do Monad<IO> [_ (resolve a' ma)] (wrap []))) @@ -149,7 +149,7 @@ (All [a b] (-> (Promise a) (Promise b) (Promise (| a b)))) (let [a|b (promise (Either ($ +0) ($ +1)))] (let% [<sides> (do-template [<promise> <tag>] - [(await (lambda [value] + [(await (function [value] (do Monad<IO> [_ (resolve (<tag> value) a|b)] (wrap []))) @@ -166,7 +166,7 @@ (All [a] (-> (Promise a) (Promise a) (Promise a))) (let [left||right (promise ($ +0))] (let% [<sides> (do-template [<promise>] - [(await [(lambda [value] + [(await [(function [value] (do Monad<IO> [_ (resolve value left||right)] (wrap [])))] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index c1c3153dd..8f8fe4828 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -53,16 +53,16 @@ (def: (find-var-value var tx) (All [a] (-> (Var a) Tx (Maybe a))) (|> tx - (find (lambda [[_var _original _current]] + (find (function [[_var _original _current]] (is (:! (Var Unit) var) (:! (Var Unit) _var)))) - (:: Monad<Maybe> map (lambda [[_var _original _current]] + (:: Monad<Maybe> map (function [[_var _original _current]] _current)) (:! (Maybe ($ +0))))) (def: #export (read var) (All [a] (-> (Var a) (STM a))) - (lambda [tx] + (function [tx] (case (find-var-value var tx) (#;Some value) [tx value] @@ -98,7 +98,7 @@ (def: #export (write value var) (All [a] (-> a (Var a) (STM Unit))) - (lambda [tx] + (function [tx] (case (find-var-value var tx) (#;Some _) [(update-tx-value var value tx) @@ -121,7 +121,7 @@ [_ (|> old (get@ #observers) dict;values - (mapM @ (lambda [f] (f new-value))))] + (mapM @ (function [f] (f new-value))))] (wrap [])) (write! new-value var)))) @@ -130,20 +130,20 @@ (All [a] (-> (Var a) (IO (frp;Chan a)))) (let [head (frp;chan ($ +0)) chan-var (var head) - observer (lambda [label value] + observer (function [label value] (case (io;run (|> chan-var raw-read (frp;write value))) #;None ## By closing the output Chan, the ## observer becomes obsolete. - (atom;update (lambda [[value observers]] + (atom;update (function [[value observers]] [value (dict;remove label observers)]) target) (#;Some tail') (write! tail' chan-var)))] (do Monad<IO> - [_ (atom;update (lambda [[value observers]] - (let [label (Nat/encode (List/fold (lambda [key base] + [_ (atom;update (function [[value observers]] + (let [label (Nat/encode (List/fold (function [key base] (case (Nat/decode key) (#;Left _) base @@ -158,7 +158,7 @@ (struct: #export _ (Functor STM) (def: (map f fa) - (lambda [tx] + (function [tx] (let [[tx' a] (fa tx)] [tx' (f a)])))) @@ -166,10 +166,10 @@ (def: functor Functor<STM>) (def: (wrap a) - (lambda [tx] [tx a])) + (function [tx] [tx a])) (def: (apply ff fa) - (lambda [tx] + (function [tx] (let [[tx' f] (ff tx) [tx'' a] (fa tx')] [tx'' (f a)])))) @@ -178,7 +178,7 @@ (def: applicative Applicative<STM>) (def: (join mma) - (lambda [tx] + (function [tx] (let [[tx' ma] (mma tx)] (ma tx'))))) @@ -205,7 +205,7 @@ (def: (can-commit? tx) (-> Tx Bool) - (every? (lambda [[_var _original _current]] + (every? (function [[_var _original _current]] (is _original (raw-read _var))) tx)) diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index 428bb484f..abf281a0a 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -27,7 +27,7 @@ (macro: #export (be tokens state) {#;doc (doc "A co-monadic parallel to the \"do\" macro." - (let [square (lambda [n] (i.* n n))] + (let [square (function [n] (i.* n n))] (be CoMonad<Stream> [inputs (iterate i.inc 2)] (square (head inputs)))))} @@ -36,14 +36,14 @@ (let [g!map (: AST [_cursor (#;SymbolS ["" " map "])]) g!split (: AST [_cursor (#;SymbolS ["" " split "])]) body' (fold (: (-> [AST AST] AST AST) - (lambda [binding body'] + (function [binding body'] (let [[var value] binding] (case var [_ (#;TagS ["" "let"])] (` (let (~ value) (~ body'))) _ - (` (|> (~ value) (~ g!split) ((~ g!map) (lambda [(~ var)] (~ body'))))) + (` (|> (~ value) (~ g!split) ((~ g!map) (function [(~ var)] (~ body'))))) )))) body (reverse (as-pairs bindings)))] diff --git a/stdlib/source/lux/control/effect.lux b/stdlib/source/lux/control/effect.lux index d0e2e0576..1f0046fce 100644 --- a/stdlib/source/lux/control/effect.lux +++ b/stdlib/source/lux/control/effect.lux @@ -55,7 +55,7 @@ [(#M;Effect ff) _] (#M;Effect (:: dsl map - (lambda [f] (apply f ea)) + (function [f] (apply f ea)) ff)) ))) @@ -159,7 +159,7 @@ "'fieldA' will be a value provided by a handler.")} (do @ [g!output (compiler;gensym "g!output") - #let [op-types (List/map (lambda [op] + #let [op-types (List/map (function [op] (let [g!tag (ast;tag ["" (get@ #name op)]) g!inputs (` [(~@ (get@ #inputs op))]) g!output (` (-> (~ (get@ #output op)) (~ g!output)))] @@ -179,7 +179,7 @@ ((~' <tag>) (~' params) (. (~' f) (~' cont)))) ((~@ op-tags)))) )) - function-defs (List/map (lambda [op] + function-defs (List/map (function [op] (let [g!name (ast;symbol ["" (get@ #name op)]) g!tag (ast;tag ["" (get@ #name op)]) g!params (: (List AST) @@ -233,7 +233,7 @@ g!value (compiler;gensym "value") g!wrap (compiler;gensym "wrap") #let [g!cases (|> defs - (List/map (lambda [def] + (List/map (function [def] (let [g!tag (ast;tag [e-module (get@ #common;def-name def)]) g!args (List/map (|>. [""] ast;symbol) (get@ #common;def-args def)) @@ -380,7 +380,7 @@ [(type;apply-type stackT1 recT0) (#;Some unfoldT1)] [(flatten-effect-stack unfoldT1) stack] [(|> stack list;enumerate - (list;find (lambda [[idx effect]] + (list;find (function [[idx effect]] (same-effect? effect eff0)))) (#;Some [idx _])]) (wrap (list (` (#M;Effect (:: (~ g!functor) (~' map) (~' wrap) diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux index 0563857f4..bfbe55c77 100644 --- a/stdlib/source/lux/control/monad.lux +++ b/stdlib/source/lux/control/monad.lux @@ -27,7 +27,7 @@ (def: (reverse xs) (All [a] (-> (List a) (List a))) - (fold (lambda [head tail] (#;Cons head tail)) + (fold (function [head tail] (#;Cons head tail)) #;Nil xs)) @@ -69,14 +69,14 @@ g!join (: AST [_cursor (#;SymbolS ["" " join "])]) g!apply (: AST [_cursor (#;SymbolS ["" " apply "])]) body' (fold (: (-> [AST AST] AST AST) - (lambda [binding body'] + (function [binding body'] (let [[var value] binding] (case var [_ (#;TagS ["" "let"])] (` (let (~ value) (~ body'))) _ - (` (|> (~ value) ((~ g!map) (lambda [(~ var)] (~ body'))) (~ g!join))) + (` (|> (~ value) ((~ g!map) (function [(~ var)] (~ body'))) (~ g!join))) )))) body (reverse (as-pairs bindings)))] @@ -142,7 +142,7 @@ {#;doc "Lift a normal function into the space of monads."} (All [M a b] (-> (Monad M) (-> a b) (-> (M a) (M b)))) - (lambda [ma] + (function [ma] (do Monad<M> [a ma] (wrap (f a))))) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index cfb05491d..20d506dc7 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -36,7 +36,7 @@ (|> 5 (@> [(i.+ @ @)])))} - (wrap (list (fold (lambda [next prev] + (wrap (list (fold (function [next prev] (` (let% [(~ (ast;symbol ["" name])) (~ prev)] (~ next)))) prev @@ -122,7 +122,7 @@ (do @ [g!temp (compiler;gensym "")] (wrap (list (` (let [(~ g!temp) (~ prev)] - [(~@ (List/map (lambda [body] (` (|> (~ g!temp) (~@ body)))) + [(~@ (List/map (function [body] (` (|> (~ g!temp) (~@ body)))) paths))])))))) (syntax: #export (case> [branches (s;many (s;seq s;any s;any))] prev) @@ -142,5 +142,5 @@ _ "???")))} (let [(^open "List/") Monad<List>] (wrap (list (` (case (~ prev) - (~@ (List/join (List/map (lambda [[pattern body]] (list pattern body)) + (~@ (List/join (List/map (function [[pattern body]] (list pattern body)) branches))))))))) diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux index 160fa69f3..304bd6ec7 100644 --- a/stdlib/source/lux/data/coll/array.lux +++ b/stdlib/source/lux/data/coll/array.lux @@ -45,7 +45,7 @@ (Array a))) (if (n.= +0 length) dest-array - (List/fold (lambda [offset target] + (List/fold (function [offset target] (case (get (n.+ offset src-start) src-array) #;None target @@ -58,7 +58,7 @@ (def: #export (occupied array) {#;doc "Finds out how many cells in an array are occupied."} (All [a] (-> (Array a) Nat)) - (List/fold (lambda [idx count] + (List/fold (function [idx count] (case (get idx array) #;None count @@ -77,7 +77,7 @@ (All [a] (-> (-> a Bool) (Array a) (Array a))) (List/fold (: (-> Nat (Array ($ +0)) (Array ($ +0))) - (lambda [idx xs'] + (function [idx xs'] (case (get idx xs) #;None xs' @@ -125,7 +125,7 @@ (def: #export (clone xs) (All [a] (-> (Array a) (Array a))) (let [arr-size (size xs)] - (List/fold (lambda [idx ys] + (List/fold (function [idx ys] (case (get idx xs) #;None ys @@ -137,7 +137,7 @@ (def: #export (from-list xs) (All [a] (-> (List a) (Array a))) - (product;right (List/fold (lambda [x [idx arr]] + (product;right (List/fold (function [x [idx arr]] [(n.inc idx) (put idx x arr)]) [+0 (new (list;size xs))] xs))) @@ -145,7 +145,7 @@ (def: #export (to-list array) (All [a] (-> (Array a) (List a))) (let [_size (size array)] - (product;right (List/fold (lambda [_ [idx tail]] + (product;right (List/fold (function [_ [idx tail]] (case (get idx array) (#;Some head) [(n.dec idx) (#;Cons head tail)] @@ -163,7 +163,7 @@ (let [sxs (size xs) sxy (size ys)] (and (n.= sxy sxs) - (List/fold (lambda [idx prev] + (List/fold (function [idx prev] (and prev (case [(get idx xs) (get idx ys)] [#;None #;None] @@ -195,7 +195,7 @@ (if (n.= +0 arr-size) (new arr-size) (List/fold (: (-> Nat (Array ($ +1)) (Array ($ +1))) - (lambda [idx mb] + (function [idx mb] (case (get idx ma) #;None mb diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux index 72a549759..ecd470ef9 100644 --- a/stdlib/source/lux/data/coll/dict.lux +++ b/stdlib/source/lux/data/coll/dict.lux @@ -215,7 +215,7 @@ (def: (collision-index Hash<K> key colls) (All [K V] (-> (Hash K) K (Collisions K V) (Maybe Index))) (:: Monad<Maybe> map product;left - (array;find+ (lambda [idx [key' val']] + (array;find+ (function [idx [key' val']] (:: Hash<K> = key key')) colls))) @@ -223,7 +223,7 @@ ## nodes to save space. (def: (demote-hierarchy except-idx [h-size h-array]) (All [k v] (-> Index (Hierarchy k v) [BitMap (Base k v)])) - (product;right (List/fold (lambda [idx [insertion-idx node]] + (product;right (List/fold (function [idx [insertion-idx node]] (let [[bitmap base] node] (case (array;get idx h-array) #;None [insertion-idx node] @@ -248,7 +248,7 @@ (Hash K) Level BitMap (Base K V) (Array (Node K V)))) - (product;right (List/fold (lambda [hierarchy-idx (^@ default [base-idx h-array])] + (product;right (List/fold (function [hierarchy-idx (^@ default [base-idx h-array])] (if (bit-position-is-set? (->bit-position hierarchy-idx) bitmap) [(n.inc base-idx) @@ -512,7 +512,7 @@ (Array/fold n.+ +0 (Array/map size' hierarchy)) (#Base _ base) - (Array/fold n.+ +0 (Array/map (lambda [sub-node'] + (Array/fold n.+ +0 (Array/map (function [sub-node'] (case sub-node' (#;Left sub-node) (size' sub-node) (#;Right _) +1)) @@ -526,12 +526,12 @@ (All [K V] (-> (Node K V) (List [K V]))) (case node (#Hierarchy _size hierarchy) - (Array/fold (lambda [sub-node tail] (List/append (entries' sub-node) tail)) + (Array/fold (function [sub-node tail] (List/append (entries' sub-node) tail)) #;Nil hierarchy) (#Base bitmap base) - (Array/fold (lambda [branch tail] + (Array/fold (function [branch tail] (case branch (#;Left sub-node) (List/append (entries' sub-node) tail) @@ -542,7 +542,7 @@ base) (#Collisions hash colls) - (Array/fold (lambda [[key' val'] tail] (#;Cons [key' val'] tail)) + (Array/fold (function [[key' val'] tail] (#;Cons [key' val'] tail)) #;Nil colls))) @@ -609,7 +609,7 @@ (def: #export (from-list Hash<K> kvs) (All [K V] (-> (Hash K) (List [K V]) (Dict K V))) - (List/fold (lambda [[k v] dict] + (List/fold (function [[k v] dict] (put k v dict)) (new Hash<K>) kvs)) @@ -628,7 +628,7 @@ If any collisions with keys occur, the values of dict2 will overwrite those of dict1."} (All [K V] (-> (Dict K V) (Dict K V) (Dict K V))) - (List/fold (lambda [[key val] dict] (put key val dict)) + (List/fold (function [[key val] dict] (put key val dict)) dict1 (entries dict2))) @@ -637,7 +637,7 @@ If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1."} (All [K V] (-> (-> V V V) (Dict K V) (Dict K V) (Dict K V))) - (List/fold (lambda [[key val2] dict] + (List/fold (function [[key val2] dict] (case (get key dict) #;None (put key val2 dict) @@ -662,7 +662,7 @@ {#;doc "Creates a sub-set of the given dict, with only the specified keys."} (All [K V] (-> (List K) (Dict K V) (Dict K V))) (let [[Hash<K> _] dict] - (List/fold (lambda [key new-dict] + (List/fold (function [key new-dict] (case (get key dict) #;None new-dict (#;Some val) (put key val new-dict))) @@ -674,7 +674,7 @@ (def: (= test subject) (and (n.= (size test) (size subject)) - (list;every? (lambda [k] + (list;every? (function [k] (case [(get k test) (get k subject)] [(#;Some tk) (#;Some sk)] (:: Eq<v> = tk sk) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 4f93bb541..86afacfc6 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -30,7 +30,7 @@ (def: #export (reverse xs) (All [a] (-> (List a) (List a))) - (fold (lambda [head tail] (#;Cons head tail)) + (fold (function [head tail] (#;Cons head tail)) #;Nil xs)) @@ -198,13 +198,13 @@ (def: #export (size list) (All [a] (-> (List a) Nat)) - (fold (lambda [_ acc] (n.+ +1 acc)) +0 list)) + (fold (function [_ acc] (n.+ +1 acc)) +0 list)) (do-template [<name> <init> <op>] [(def: #export (<name> p xs) (All [a] (-> (-> a Bool) (List a) Bool)) - (fold (lambda [_2 _1] (<op> _1 (p _2))) <init> xs))] + (fold (function [_2 _1] (<op> _1 (p _2))) <init> xs))] [every? true and] [any? false or]) @@ -283,7 +283,7 @@ (list) (#;Cons x xs') - (let [[pre post] (fold (lambda [x' [pre post]] + (let [[pre post] (fold (function [x' [pre post]] (if (< x x') [(#;Cons x' pre) post] [pre (#;Cons x' post)])) @@ -348,21 +348,21 @@ indices (i.range 0 (i.dec num-lists)) type-vars (: (List AST) (map (. symbol$ Int/encode) indices)) zip-type (` (All [(~@ type-vars)] - (-> (~@ (map (: (-> AST AST) (lambda [var] (` (List (~ var))))) + (-> (~@ (map (: (-> AST AST) (function [var] (` (List (~ var))))) type-vars)) (List [(~@ type-vars)])))) vars+lists (|> indices (map i.inc) - (map (lambda [idx] + (map (function [idx] [(symbol$ (Int/encode idx)) (symbol$ (Int/encode (Int/negate idx)))]))) - pattern (` [(~@ (map (lambda [[v vs]] (` (#;Cons (~ v) (~ vs)))) + pattern (` [(~@ (map (function [[v vs]] (` (#;Cons (~ v) (~ vs)))) vars+lists))]) g!step (symbol$ "\tstep\t") g!blank (symbol$ "\t_\t") list-vars (map product;right vars+lists) code (` (: (~ zip-type) - (lambda (~ g!step) [(~@ list-vars)] + (function (~ g!step) [(~@ list-vars)] (case [(~@ list-vars)] (~ pattern) (#;Cons [(~@ (map product;left vars+lists))] @@ -394,21 +394,21 @@ type-vars (: (List AST) (map (. symbol$ Int/encode) indices)) zip-type (` (All [(~@ type-vars) (~ g!return-type)] (-> (-> (~@ type-vars) (~ g!return-type)) - (~@ (map (: (-> AST AST) (lambda [var] (` (List (~ var))))) + (~@ (map (: (-> AST AST) (function [var] (` (List (~ var))))) type-vars)) (List (~ g!return-type))))) vars+lists (|> indices (map i.inc) - (map (lambda [idx] + (map (function [idx] [(symbol$ (Int/encode idx)) (symbol$ (Int/encode (Int/negate idx)))]))) - pattern (` [(~@ (map (lambda [[v vs]] (` (#;Cons (~ v) (~ vs)))) + pattern (` [(~@ (map (function [[v vs]] (` (#;Cons (~ v) (~ vs)))) vars+lists))]) g!step (symbol$ "\tstep\t") g!blank (symbol$ "\t_\t") list-vars (map product;right vars+lists) code (` (: (~ zip-type) - (lambda (~ g!step) [(~ g!func) (~@ list-vars)] + (function (~ g!step) [(~ g!func) (~@ list-vars)] (case [(~@ list-vars)] (~ pattern) (#;Cons ((~ g!func) (~@ (map product;left vars+lists))) diff --git a/stdlib/source/lux/data/coll/set.lux b/stdlib/source/lux/data/coll/set.lux index e10f20488..8d075a961 100644 --- a/stdlib/source/lux/data/coll/set.lux +++ b/stdlib/source/lux/data/coll/set.lux @@ -74,6 +74,6 @@ (def: eq Eq<Set>) (def: (hash (^@ set [Hash<a> _])) - (List/fold (lambda [elem acc] (n.+ (:: Hash<a> hash elem) acc)) + (List/fold (function [elem acc] (n.+ (:: Hash<a> hash elem) acc)) +0 (to-list set)))) diff --git a/stdlib/source/lux/data/coll/stream.lux b/stdlib/source/lux/data/coll/stream.lux index c86ab5b61..f8ee835b3 100644 --- a/stdlib/source/lux/data/coll/stream.lux +++ b/stdlib/source/lux/data/coll/stream.lux @@ -134,7 +134,7 @@ (let [(^stream& x y z _tail) (some-stream-func 1 2 3)] (func x y z)))} (with-gensyms [g!s] - (let [body+ (` (let [(~@ (List/join (List/map (lambda [pattern] + (let [body+ (` (let [(~@ (List/join (List/map (function [pattern] (list (` [(~ pattern) (~ g!s)]) (` (cont;run (~ g!s))))) patterns)))] diff --git a/stdlib/source/lux/data/coll/tree/zipper.lux b/stdlib/source/lux/data/coll/tree/zipper.lux index 59a4d40ff..d5e2e47c8 100644 --- a/stdlib/source/lux/data/coll/tree/zipper.lux +++ b/stdlib/source/lux/data/coll/tree/zipper.lux @@ -73,7 +73,7 @@ (#;Some parent) (|> parent (update@ #node (: (-> (Tree ($ +0)) (Tree ($ +0))) - (lambda [node] + (function [node] (set@ #rose;children (L/append (list;reverse (get@ #lefts zipper)) (#;Cons (get@ #node zipper) (get@ #rights zipper))) @@ -95,14 +95,14 @@ (#;Cons next side') (|> zipper - (update@ <op-side> (lambda [op-side] + (update@ <op-side> (function [op-side] (#;Cons (get@ #node zipper) op-side))) (set@ <side> side') (set@ #node next)))) (def: #export (<all-name> zipper) (All [a] (-> (Zipper a) (Zipper a))) - (L/fold (lambda [_] <one-name>) zipper (get@ <side> zipper)))] + (L/fold (function [_] <one-name>) zipper (get@ <side> zipper)))] [right rightmost #rights #lefts] [left leftmost #lefts #rights] @@ -119,7 +119,7 @@ (def: #export (prepend-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #rose;children] - (lambda [children] + (function [children] (list& (: (Tree ($ +0)) (rose;tree [value {}])) children)) @@ -128,7 +128,7 @@ (def: #export (append-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #rose;children] - (lambda [children] + (function [children] (L/append children (list (: (Tree ($ +0)) (rose;tree [value {}]))))) @@ -160,7 +160,7 @@ _ (#;Some (|> zipper - (update@ <side> (lambda [side] + (update@ <side> (function [side] (#;Cons (: (Tree ($ +0)) (rose;tree [value {}])) side)))))))] @@ -210,7 +210,7 @@ ## (def: unwrap (get@ [#node #rose;value])) ## (def: (split wa) -## (let [tree-splitter (lambda tree-splitter [tree] +## (let [tree-splitter (function tree-splitter [tree] ## {#rose;value (from-tree tree) ## #rose;children (L/map tree-splitter ## (get@ #rose;children tree))})] diff --git a/stdlib/source/lux/data/coll/vector.lux b/stdlib/source/lux/data/coll/vector.lux index 1c4a1dd9d..efb52e01b 100644 --- a/stdlib/source/lux/data/coll/vector.lux +++ b/stdlib/source/lux/data/coll/vector.lux @@ -172,7 +172,7 @@ (|> hierarchy array;to-list list;reverse - (List/fold (lambda [sub acc] (List/append (to-list' sub) acc)) + (List/fold (function [sub acc] (List/append (to-list' sub) acc)) #;Nil)))) ## [Types] @@ -374,7 +374,7 @@ (Array/fold f init base) (#Hierarchy hierarchy) - (Array/fold (lambda [node init'] (fold f init' node)) + (Array/fold (function [node init'] (fold f init' node)) init hierarchy)) )) @@ -423,7 +423,7 @@ (let [(^open) Functor<Vector> (^open) Fold<Vector> (^open) Monoid<Vector> - results (map (lambda [f] (map f fa)) + results (map (function [f] (map f fa)) ff)] (fold append unit results))) ) @@ -434,7 +434,7 @@ (def: join (let [(^open) Fold<Vector> (^open) Monoid<Vector>] - (fold (lambda [post pre] (append pre post)) unit))) + (fold (function [post pre] (append pre post)) unit))) ) (def: #export (reverse xs) diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 153920700..91bd9c2fd 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -72,7 +72,7 @@ (json {"this" "is" "an" "object"}))} (let [(^open) Monad<Lux> - wrapper (lambda [x] (` (;;json (~ x))))] + wrapper (function [x] (` (;;json (~ x))))] (case token (^template [<ast-tag> <ctor> <json-tag>] [_ (<ast-tag> value)] @@ -91,7 +91,7 @@ [_ (#;RecordS pairs)] (do Monad<Lux> [pairs' (mapM @ - (lambda [[slot value]] + (function [[slot value]] (case slot [_ (#;TextS key-name)] (wrap (` [(~ (ast;text key-name)) (~ (wrapper value))])) @@ -125,7 +125,7 @@ (format "{" (|> object dict;entries - (List/map (lambda [[key value]] (format (:: text;Codec<Text,Text> encode key) ":" (show-json value)))) + (List/map (function [[key value]] (format (:: text;Codec<Text,Text> encode key) ":" (show-json value)))) (text;join-with ",")) "}")) @@ -220,7 +220,7 @@ (def: #export (gen-nullable gen) {#;doc "Builds a JSON generator for potentially inexistent values."} (All [a] (-> (Gen a) (Gen (Maybe a)))) - (lambda [elem] + (function [elem] (case elem #;None #Null (#;Some value) (gen value)))) @@ -349,7 +349,7 @@ ## [Structures] (struct: #export _ (Functor Parser) (def: (map f ma) - (lambda [json] + (function [json] (case (ma json) (#;Left msg) (#;Left msg) @@ -364,7 +364,7 @@ (#;Right x)) (def: (apply ff fa) - (lambda [json] + (function [json] (case (ff json) (#;Right f) (case (fa json) @@ -381,7 +381,7 @@ (def: applicative Applicative<Parser>) (def: (join mma) - (lambda [json] + (function [json] (case (mma json) (#;Left msg) (#;Left msg) @@ -494,7 +494,7 @@ (def: #export (nullable parser) {#;doc "A parser that can handle the presence of null values."} (All [a] (-> (Parser a) (Parser (Maybe a)))) - (lambda [json] + (function [json] (case json #Null (#;Right #;None) @@ -511,7 +511,7 @@ (def: #export (array parser) {#;doc "Parses a JSON array, assuming that every element can be parsed the same way."} (All [a] (-> (Parser a) (Parser (List a)))) - (lambda [json] + (function [json] (case json (#Array values) (do Monad<Error> @@ -524,12 +524,12 @@ (def: #export (object parser) {#;doc "Parses a JSON object, assuming that every field's value can be parsed the same way."} (All [a] (-> (Parser a) (Parser (Dict String a)))) - (lambda [json] + (function [json] (case json (#Object fields) (do Monad<Error> [kvs (mapM @ - (lambda [[key val']] + (function [[key val']] (do @ [val (parser val')] (wrap [key val]))) @@ -542,7 +542,7 @@ (def: #export (nth idx parser) {#;doc "Parses an element inside a JSON array."} (All [a] (-> Nat (Parser a) (Parser a))) - (lambda [json] + (function [json] (case json (#Array values) (case (vector;nth idx values) @@ -563,7 +563,7 @@ (def: #export (field field-name parser) {#;doc "Parses a field inside a JSON object."} (All [a] (-> Text (Parser a) (Parser a))) - (lambda [json] + (function [json] (case (get field-name json) (#;Some value) (case (parser value) @@ -579,7 +579,7 @@ (def: #export any {#;doc "Just returns the JSON input without applying any logic."} (Parser JSON) - (lambda [json] + (function [json] (#;Right json))) (def: #export (seq pa pb) @@ -680,7 +680,7 @@ [(#Array xs) (#Array ys)] (and (n.= (vector;size xs) (vector;size ys)) - (fold (lambda [idx prev] + (fold (function [idx prev] (and prev (default false (do Monad<Maybe> @@ -692,7 +692,7 @@ [(#Object xs) (#Object ys)] (and (n.= (dict;size xs) (dict;size ys)) - (fold (lambda [[xk xv] prev] + (fold (function [[xk xv] prev] (and prev (case (dict;get xk ys) #;None false @@ -705,7 +705,7 @@ (struct: #export _ (Codec Text JSON) (def: encode show-json) - (def: decode (lambda [input] (lexer;run input (json~' []))))) + (def: decode (function [input] (lexer;run input (json~' []))))) ## [Syntax] (type: Shape @@ -728,13 +728,13 @@ (let [array-size (list;size parts) parsers (|> parts (list;zip2 (list;indices array-size)) - (List/map (lambda [[idx parser]] + (List/map (function [[idx parser]] (` (nth (~ (ast;nat idx)) (~ parser))))))] (wrap (list (` ($_ seq (~@ parsers)))))) (#ObjectShape kvs) (let [fields (List/map product;left kvs) - parsers (List/map (lambda [[field-name parser]] + parsers (List/map (function [[field-name parser]] (` (field (~ (ast;text field-name)) (~ parser)))) kvs)] (wrap (list (` ($_ seq (~@ parsers)))))) @@ -751,14 +751,14 @@ (let [array-size (list;size parts) parsers (|> parts (list;zip2 (list;indices array-size)) - (List/map (lambda [[idx parser]] + (List/map (function [[idx parser]] (` (nth (~ (ast;nat idx)) (~ parser))))))] (wrap (list (` (ensure (array-size! (~ (ast;nat array-size))) ($_ seq (~@ parsers))))))) (#ObjectShape kvs) (let [fields (List/map product;left kvs) - parsers (List/map (lambda [[field-name parser]] + parsers (List/map (function [[field-name parser]] (` (field (~ (ast;text field-name)) (~ parser)))) kvs)] (wrap (list (` (ensure (object-fields! (list (~@ (List/map ast;text fields)))) @@ -772,11 +772,11 @@ (poly: #hidden (Codec<JSON,?>//encode *env* :x:) (let [->Codec//encode (: (-> AST AST) - (lambda [.type.] (` (-> (~ .type.) JSON))))] + (function [.type.] (` (-> (~ .type.) JSON))))] (let% [<basic> (do-template [<type> <matcher> <encoder>] [(do @ [_ (<matcher> :x:)] (wrap (` (: (~ (->Codec//encode (` <type>))) <encoder>))))] - [Unit poly;unit (lambda [(~ (ast;symbol ["" "0"]))] #Null)] + [Unit poly;unit (function [(~ (ast;symbol ["" "0"]))] #Null)] [Bool poly;bool ;;gen-boolean] [Int poly;int (|>. ;int-to-real ;;gen-number)] [Real poly;real ;;gen-number] @@ -809,11 +809,11 @@ (-> (~@ (List/map ->Codec//encode g!vars)) (~ (->Codec//encode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ g!input)] + (function [(~@ g!vars) (~ g!input)] (|> (~ g!input) (_map_ (: (-> [Text (~ (type;to-ast :val:))] [Text JSON]) - (lambda [[(~ g!key) (~ g!val)]] + (function [[(~ g!key) (~ g!val)]] [(~ g!key) ((~ .val.) (~ g!val))]))) ;;object)) @@ -836,7 +836,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] pattern-matching (mapM @ - (lambda [[name :case:]] + (function [[name :case:]] (do @ [#let [tag (ast;tag name)] encoder (Codec<JSON,?>//encode new-*env* :case:)] @@ -853,7 +853,7 @@ (-> (~@ (List/map ->Codec//encode g!vars)) (~ (->Codec//encode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ g!input)] + (function [(~@ g!vars) (~ g!input)] (case (~ g!input) (~@ (List/join pattern-matching)))) ))))) @@ -864,7 +864,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] synthesis (mapM @ - (lambda [[name :slot:]] + (function [[name :slot:]] (do @ [encoder (Codec<JSON,?>//encode new-*env* :slot:)] (wrap [(` (~ (ast;text (product;right name)))) @@ -879,7 +879,7 @@ (-> (~@ (List/map ->Codec//encode g!vars)) (~ (->Codec//encode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ g!input)] + (function [(~@ g!vars) (~ g!input)] (;;json (~ (ast;record synthesis)))) ))))) (with-gensyms [g!type-fun g!case] @@ -889,7 +889,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] pattern-matching (mapM @ - (lambda [:member:] + (function [:member:] (do @ [g!member (compiler;gensym "g!member") encoder (Codec<JSON,?>//encode new-*env* :member:)] @@ -905,8 +905,8 @@ (~ (->Codec//encode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))] #let [.tuple. (` [(~@ (List/map product;left pattern-matching))])]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ .tuple.)] - (;;json [(~@ (List/map (lambda [[g!member g!encoder]] + (function [(~@ g!vars) (~ .tuple.)] + (;;json [(~@ (List/map (function [[g!member g!encoder]] (` ((~ g!encoder) (~ g!member)))) pattern-matching))])) ))) @@ -923,7 +923,7 @@ (poly: #hidden (Codec<JSON,?>//decode *env* :x:) (let [->Codec//decode (: (-> AST AST) - (lambda [.type.] (` (-> JSON (Error (~ .type.))))))] + (function [.type.] (` (-> JSON (Error (~ .type.))))))] (let% [<basic> (do-template [<type> <matcher> <decoder>] [(do @ [_ (<matcher> :x:)] (wrap (` (: (~ (->Codec//decode (` <type>))) <decoder>))))] @@ -968,11 +968,11 @@ (-> (~@ (List/map ->Codec//decode g!vars)) (~ (->Codec//decode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ g!input)] + (function [(~@ g!vars) (~ g!input)] (do Monad<Error> [(~ g!key) (;;fields (~ g!input))] (mapM (~ (' %)) - (lambda [(~ g!key)] + (function [(~ g!key)] (do Monad<Error> [(~ g!val) (;;get (~ g!key) (~ g!input)) (~ g!val) (;;run (~ g!val) (~ .val.))] @@ -988,7 +988,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] pattern-matching (mapM @ - (lambda [[name :case:]] + (function [[name :case:]] (do @ [#let [tag (ast;tag name)] decoder (Codec<JSON,?>//decode new-*env* :case:)] @@ -1012,7 +1012,7 @@ base-parser _ - (` (lambda [(~@ g!vars)] (~ base-parser))))]] + (` (function [(~@ g!vars)] (~ base-parser))))]] (wrap (` (: (~ :x:+) (~ parser)))) )) (with-gensyms [g!type-fun g!case g!input] @@ -1022,7 +1022,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] extraction (mapM @ - (lambda [[name :slot:]] + (function [[name :slot:]] (do @ [#let [g!member (ast;symbol ["" (product;right name)])] decoder (Codec<JSON,?>//decode new-*env* :slot:)] @@ -1040,10 +1040,10 @@ (-> (~@ (List/map ->Codec//decode g!vars)) (~ (->Codec//decode (` ((~ (type;to-ast :x:)) (~@ g!vars)))))))))]] (wrap (` (: (~ :x:+) - (lambda [(~@ g!vars) (~ g!input)] + (function [(~@ g!vars) (~ g!input)] (do Monad<Error> [(~@ (List/join extraction))] - ((~ (' wrap)) (~ (ast;record (List/map (lambda [[name :slot:]] + ((~ (' wrap)) (~ (ast;record (List/map (function [[name :slot:]] [(ast;tag name) (ast;symbol ["" (product;right name)])]) members)))))) ))))) @@ -1054,7 +1054,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) *env*)] pattern-matching (mapM @ - (lambda [:member:] + (function [:member:] (do @ [g!member (compiler;gensym "g!member") decoder (Codec<JSON,?>//decode new-*env* :member:)] @@ -1073,7 +1073,7 @@ (` (;;shape [(~@ (List/map product;right pattern-matching))])) _ - (` (lambda [(~@ g!vars)] + (` (function [(~@ g!vars)] (;;shape [(~@ (List/map product;right pattern-matching))]))))]] (wrap (` (: (~ :x:+) (~ .decoder.)))) )) diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux index fbe088ae7..57af6cf37 100644 --- a/stdlib/source/lux/data/format/xml.lux +++ b/stdlib/source/lux/data/format/xml.lux @@ -155,7 +155,7 @@ (def: xml^ (l;Lexer XML) (|> (l;rec - (lambda [node^] + (function [node^] (l;either text^ (spaced^ (do l;Monad<Lexer> @@ -211,7 +211,7 @@ (-> Attrs Text) (|> attrs D;entries - (L/map (lambda [[key value]] + (L/map (function [[key value]] (format (write-tag key) "=" "\""(sanitize-value value) "\""))) (text;join-with " "))) diff --git a/stdlib/source/lux/data/log.lux b/stdlib/source/lux/data/log.lux index 5ac546b87..ae644c94f 100644 --- a/stdlib/source/lux/data/log.lux +++ b/stdlib/source/lux/data/log.lux @@ -53,7 +53,7 @@ (def: #export (lift-log Monoid<l> Monad<M>) (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Log l a))))) - (lambda [ma] + (function [ma] (do Monad<M> [a ma] (wrap [(:: Monoid<l> unit) a])))) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index f9289c682..86fb73515 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -299,7 +299,7 @@ nth-phi (|> input argument (r./ r-nth)) slice (|> math;pi (r.* 2.0) (r./ r-nth))] (|> (list;n.range +0 (n.dec nth)) - (List/map (lambda [nth'] + (List/map (function [nth'] (let [inner (|> nth' nat-to-int int-to-real (r.* slice) (r.+ nth-phi)) diff --git a/stdlib/source/lux/data/product.lux b/stdlib/source/lux/data/product.lux index 2a25e53a0..fe31c2020 100644 --- a/stdlib/source/lux/data/product.lux +++ b/stdlib/source/lux/data/product.lux @@ -15,13 +15,13 @@ (All [a b c] (-> (-> [a b] c) (-> a b c))) - (lambda [x y] + (function [x y] (f [x y]))) (def: #export (uncurry f) (All [a b c] (-> (-> a b c) (-> [a b] c))) - (lambda [xy] + (function [xy] (let [[x y] xy] (f x y)))) @@ -33,5 +33,5 @@ (def: #export (both f g) (All [a b c] (-> (-> a b) (-> a c) (-> a [b c]))) - (lambda [input] + (function [input] [(f input) (g input)])) diff --git a/stdlib/source/lux/data/store.lux b/stdlib/source/lux/data/store.lux index 4badfb382..e60c3703c 100644 --- a/stdlib/source/lux/data/store.lux +++ b/stdlib/source/lux/data/store.lux @@ -11,11 +11,12 @@ (def: (extend f wa) (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) {#cursor (get@ #cursor wa) - #peek (lambda [s] (f (set@ #cursor s wa)))}) + #peek (function [s] (f (set@ #cursor s wa)))}) (struct: #export Functor<Store> (All [s] (Functor (Store s))) (def: (map f fa) - (extend (lambda [store] (f (:: store peek (:: store cursor)))) + (extend (function [store] + (f (:: store peek (:: store cursor)))) fa))) (struct: #export CoMonad<Store> (All [s] (CoMonad (Store s))) diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux index ade411e6b..2c71f67d4 100644 --- a/stdlib/source/lux/data/sum.lux +++ b/stdlib/source/lux/data/sum.lux @@ -13,7 +13,7 @@ (def: #export (either f g) (All [a b c] (-> (-> a c) (-> b c) (-> (| a b) c))) - (lambda [input] + (function [input] (case input (+0 l) (f l) (+1 r) (g r)))) diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux index 153ef4fe3..575448be2 100644 --- a/stdlib/source/lux/data/text/format.lux +++ b/stdlib/source/lux/data/text/format.lux @@ -49,7 +49,7 @@ (def: #export (%list formatter) (All [a] (-> (Formatter a) (Formatter (List a)))) - (lambda [values] + (function [values] (case values #;Nil "(list)" diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index 5fcbe8e6e..49a711236 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -19,7 +19,7 @@ ## [Structures] (struct: #export _ (Functor Lexer) (def: (map f fa) - (lambda [input] + (function [input] (case (fa input) (#E;Error msg) (#E;Error msg) (#E;Success [input' output]) (#E;Success [input' (f output)]))))) @@ -28,11 +28,11 @@ (def: functor Functor<Lexer>) (def: (wrap a) - (lambda [input] + (function [input] (#E;Success [input a]))) (def: (apply ff fa) - (lambda [input] + (function [input] (case (ff input) (#E;Success [input' f]) (case (fa input') @@ -49,7 +49,7 @@ (def: applicative Applicative<Lexer>) (def: (join mma) - (lambda [input] + (function [input] (case (mma input) (#E;Error msg) (#E;Error msg) (#E;Success [input' ma]) (ma input')))) @@ -74,13 +74,13 @@ ## Combinators (def: #export (fail message) (All [a] (-> Text (Lexer a))) - (lambda [input] + (function [input] (#E;Error message))) (def: #export any {#;doc "Just returns the next character without applying any logic."} (Lexer Char) - (lambda [input] + (function [input] (case [(text;nth +0 input) (text;split +1 input)] [(#;Some output) (#;Some [_ input'])] (#E;Success [input' output]) @@ -100,7 +100,7 @@ (def: #export (alt left right) {#;doc "Heterogeneous alternative combinator."} (All [a b] (-> (Lexer a) (Lexer b) (Lexer (| a b)))) - (lambda [input] + (function [input] (case (left input) (#E;Error msg) (case (right input) @@ -116,7 +116,7 @@ (def: #export (not! p) {#;doc "Ensure a lexer fails."} (All [a] (-> (Lexer a) (Lexer Unit))) - (lambda [input] + (function [input] (case (p input) (#E;Error msg) (#E;Success [input []]) @@ -127,7 +127,7 @@ (def: #export (not p) {#;doc "Produce a character if the lexer fails."} (All [a] (-> (Lexer a) (Lexer Char))) - (lambda [input] + (function [input] (case (p input) (#E;Error msg) (any input) @@ -138,7 +138,7 @@ (def: #export (either left right) {#;doc "Homogeneous alternative combinator."} (All [a] (-> (Lexer a) (Lexer a) (Lexer a))) - (lambda [input] + (function [input] (case (left input) (#E;Error msg) (right input) @@ -149,7 +149,7 @@ (def: #export (assert message test) {#;doc "Fails with the given message if the test is false."} (-> Text Bool (Lexer Unit)) - (lambda [input] + (function [input] (if test (#E;Success [input []]) (#E;Error message)))) @@ -157,7 +157,7 @@ (def: #export (some p) {#;doc "0-or-more combinator."} (All [a] (-> (Lexer a) (Lexer (List a)))) - (lambda [input] + (function [input] (case (p input) (#E;Error msg) (#E;Success [input (list)]) @@ -191,7 +191,7 @@ {#;doc "Lex at most N times."} (All [a] (-> Nat (Lexer a) (Lexer (List a)))) (if (n.> +0 n) - (lambda [input] + (function [input] (case (p input) (#E;Error msg) (#E;Success [input (list)]) @@ -223,7 +223,7 @@ (def: #export (opt p) {#;doc "Optionality combinator."} (All [a] (-> (Lexer a) (Lexer (Maybe a)))) - (lambda [input] + (function [input] (case (p input) (#E;Error msg) (#E;Success [input #;None]) @@ -235,7 +235,7 @@ (def: #export (text test) {#;doc "Lex a text if it matches the given sample."} (-> Text (Lexer Text)) - (lambda [input] + (function [input] (if (text;starts-with? test input) (case (text;split (text;size test) input) #;None (#E;Error "") @@ -261,7 +261,7 @@ (def: #export end {#;doc "Ensure the lexer's input is empty."} (Lexer Unit) - (lambda [input] + (function [input] (case input "" (#E;Success [input []]) _ (#E;Error ($_ Text/append "The text input has not been fully consumed @ " (:: text;Codec<Text,Text> encode input))) @@ -270,7 +270,7 @@ (def: #export peek {#;doc "Lex the next character (without consuming it from the input)."} (Lexer Char) - (lambda [input] + (function [input] (case (text;nth +0 input) (#;Some output) (#E;Success [input output]) @@ -282,7 +282,7 @@ (def: #export (char test) {#;doc "Lex a character if it matches the given sample."} (-> Char (Lexer Char)) - (lambda [input] + (function [input] (case [(text;nth +0 input) (text;split +1 input)] [(#;Some char') (#;Some [_ input'])] (if (Char/= test char') @@ -296,7 +296,7 @@ (def: #export get-input {#;doc "Get all of the remaining input (without consuming it)."} (Lexer Text) - (lambda [input] + (function [input] (#E;Success [input input]))) (def: #export (char-range bottom top) @@ -343,7 +343,7 @@ (def: #export (one-of options) {#;doc "Only lex characters that are part of a piece of text."} (-> Text (Lexer Char)) - (lambda [input] + (function [input] (case (text;split +1 input) (#;Some [init input']) (if (text;contains? init options) @@ -361,7 +361,7 @@ (def: #export (none-of options) {#;doc "Only lex characters that aren't part of a piece of text."} (-> Text (Lexer Char)) - (lambda [input] + (function [input] (case (text;split +1 input) (#;Some [init input']) (if (;not (text;contains? init options)) @@ -379,7 +379,7 @@ (def: #export (satisfies p) {#;doc "Only lex characters that satisfy a predicate."} (-> (-> Char Bool) (Lexer Char)) - (lambda [input] + (function [input] (case (: (Maybe [Text Char]) (do Monad<Maybe> [[init input'] (text;split +1 input) @@ -443,7 +443,7 @@ (def: #export end? {#;doc "Ask if the lexer's input is empty."} (Lexer Bool) - (lambda [input] + (function [input] (#E;Success [input (text;empty? input)]))) (def: #export (after param subject) @@ -462,7 +462,7 @@ (def: #export (default value lexer) {#;doc "If the given lexer fails, this lexer will succeed with the provided value."} (All [a] (-> a (Lexer a) (Lexer a))) - (lambda [input] + (function [input] (case (lexer input) (#E;Error error) (#E;Success [input value]) @@ -473,7 +473,7 @@ (def: #export (codec codec lexer) {#;doc "Lex a token by means of a codec."} (All [a] (-> (Codec Text a) (Lexer Text) (Lexer a))) - (lambda [input] + (function [input] (case (lexer input) (#E;Error error) (#E;Error error) @@ -495,13 +495,13 @@ (def: #export (rec lexer) (All [a] (-> (-> (Lexer a) (Lexer a)) (Lexer a))) - (lambda [input] + (function [input] (run' input (lexer (rec lexer))))) (def: #export (local local-input lexer) {#;doc "Run a lexer with the given input, instead of the real one."} (All [a] (-> Text (Lexer a) (Lexer a))) - (lambda [real-input] + (function [real-input] (case (run' local-input lexer) (#E;Error error) (#E;Error error) diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index 6ed17d8c2..c1075af34 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -34,7 +34,7 @@ (def: (local^ state lexer) (All [a] (-> Text (Lexer a) (Lexer a))) - (lambda [old-state] + (function [old-state] (case (lexer state) (#;Left error) (#;Left error) @@ -131,7 +131,7 @@ [_ (wrap []) init re-user-class^' rest (&;some (&;after (&;text "&&") (&;enclosed ["[" "]"] re-user-class^')))] - (wrap (fold (lambda [refinement base] + (wrap (fold (function [refinement base] (` (refine^ (~ refinement) (~ base)))) init rest)))) @@ -291,7 +291,7 @@ [_ names steps] (fold (: (-> (Either AST [Re-Group AST]) [Int (List AST) (List (List AST))] [Int (List AST) (List (List AST))]) - (lambda [part [idx names steps]] + (function [part [idx names steps]] (case part (^or (#;Left complex) (#;Right [#Non-Capturing complex])) [idx @@ -335,7 +335,7 @@ (def: #hidden (|||^ left right) (All [l r] (-> (Lexer [Text l]) (Lexer [Text r]) (Lexer [Text (| l r)]))) - (lambda [input] + (function [input] (case (left input) (#;Right [input' [lt lv]]) (#;Right [input' [lt (+0 lv)]]) @@ -350,7 +350,7 @@ (def: #hidden (|||_^ left right) (All [l r] (-> (Lexer [Text l]) (Lexer [Text r]) (Lexer Text))) - (lambda [input] + (function [input] (case (left input) (#;Right [input' [lt lv]]) (#;Right [input' lt]) diff --git a/stdlib/source/lux/data/trace.lux b/stdlib/source/lux/data/trace.lux index f8094565b..137713fa7 100644 --- a/stdlib/source/lux/data/trace.lux +++ b/stdlib/source/lux/data/trace.lux @@ -23,10 +23,11 @@ (def: (split wa) (let [monoid (get@ #monoid wa)] {#monoid monoid - #trace (lambda [t1] + #trace (function [t1] {#monoid monoid - #trace (lambda [t2] ((get@ #trace wa) - (:: monoid append t1 t2)))})}))) + #trace (function [t2] + ((get@ #trace wa) + (:: monoid append t1 t2)))})}))) (def: #export (run context tracer) (All [t a] (-> t (Trace t a) a)) diff --git a/stdlib/source/lux/function.lux b/stdlib/source/lux/function.lux index cddf5d472..d4f4abce0 100644 --- a/stdlib/source/lux/function.lux +++ b/stdlib/source/lux/function.lux @@ -6,13 +6,13 @@ (def: #export (const c) {#;doc "Create constant functions."} (All [a b] (-> a (-> b a))) - (lambda [_] c)) + (function [_] c)) (def: #export (flip f) {#;doc "Flips the order of the arguments of a function."} (All [a b c] (-> (-> a b c) (-> b a c))) - (lambda [x y] (f y x))) + (function [x y] (f y x))) ## [Structures] (struct: #export Monoid<Function> (Monoid (All [a] (-> a a))) diff --git a/stdlib/source/lux/function/cont.lux b/stdlib/source/lux/function/cont.lux index 7635d7129..08f784035 100644 --- a/stdlib/source/lux/function/cont.lux +++ b/stdlib/source/lux/function/cont.lux @@ -24,25 +24,25 @@ (struct: #export Functor<Cont> (All [o] (Functor (All [i] (Cont i o)))) (def: (map f fv) - (lambda [k] (fv (. k f))))) + (function [k] (fv (. k f))))) (struct: #export Applicative<Cont> (All [o] (Applicative (All [i] (Cont i o)))) (def: functor Functor<Cont>) (def: (wrap value) - (lambda [k] (k value))) + (function [k] (k value))) (def: (apply ff fv) - (lambda [k] + (function [k] (|> (k (f v)) - (lambda [v]) fv - (lambda [f]) ff)))) + (function [v]) fv + (function [f]) ff)))) (struct: #export Monad<Cont> (All [o] (Monad (All [i] (Cont i o)))) (def: applicative Applicative<Cont>) (def: (join ffa) - (lambda [k] + (function [k] (ffa (continue k))))) (def: #export (call/cc f) @@ -51,15 +51,15 @@ (-> (-> (-> a (Cont b z)) (Cont a z)) (Cont a z))) - (lambda [k] - (f (lambda [a] (lambda [_] (k a))) + (function [k] + (f (function [a] (function [_] (k a))) k))) (syntax: #export (pending expr) {#;doc (doc "Turns any expression into a function that is pending a continuation." (pending (some-computation some-input)))} (with-gensyms [g!k] - (wrap (list (` (;lambda [(~ g!k)] ((~ g!k) (~ expr)))))))) + (wrap (list (` (;function [(~ g!k)] ((~ g!k) (~ expr)))))))) (def: #export (portal init) (All [i o z] @@ -67,16 +67,16 @@ (Cont [(-> i (Cont o z)) i] z))) - (call/cc (lambda [k] + (call/cc (function [k] (do Monad<Cont> - [#let [nexus (lambda nexus [val] + [#let [nexus (function nexus [val] (k [nexus val]))] _ (k [nexus init])] (wrap (undefined)))))) (def: #export (reset scope) (All [i o] (-> (Cont i i) (Cont i o))) - (lambda [k] + (function [k] (k (run scope)))) (def: #export (shift f) @@ -84,6 +84,6 @@ (-> (-> (-> a (Cont a a)) (Cont a a)) (Cont a a))) - (lambda [oc] - (f (lambda [a] (lambda [ic] (ic (oc a)))) + (function [oc] + (f (function [a] (function [ic] (ic (oc a)))) id))) diff --git a/stdlib/source/lux/function/reader.lux b/stdlib/source/lux/function/reader.lux index 955b4bba3..598bfc670 100644 --- a/stdlib/source/lux/function/reader.lux +++ b/stdlib/source/lux/function/reader.lux @@ -12,31 +12,31 @@ ## [Structures] (struct: #export Functor<Reader> (All [r] (Functor (Reader r))) (def: (map f fa) - (lambda [env] + (function [env] (f (fa env))))) (struct: #export Applicative<Reader> (All [r] (Applicative (Reader r))) (def: functor Functor<Reader>) (def: (wrap x) - (lambda [env] x)) + (function [env] x)) (def: (apply ff fa) - (lambda [env] + (function [env] ((ff env) (fa env))))) (struct: #export Monad<Reader> (All [r] (Monad (Reader r))) (def: applicative Applicative<Reader>) (def: (join mma) - (lambda [env] + (function [env] (mma env env)))) ## [Values] (def: #export ask {#;doc "Get the environment."} (All [r] (Reader r r)) - (lambda [env] env)) + (function [env] env)) (def: #export (local change reader-proc) {#;doc "Run computation with a locally-modified environment."} @@ -52,7 +52,7 @@ (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Reader e (M a))))))) (def: applicative (compA Applicative<Reader> (get@ #M;applicative Monad<M>))) (def: (join eMeMa) - (lambda [env] + (function [env] (do Monad<M> [eMa (run env eMeMa)] (run env eMa))))) diff --git a/stdlib/source/lux/function/state.lux b/stdlib/source/lux/function/state.lux index edca1d81b..9ee12e93d 100644 --- a/stdlib/source/lux/function/state.lux +++ b/stdlib/source/lux/function/state.lux @@ -12,7 +12,7 @@ ## [Structures] (struct: #export Functor<State> (All [s] (Functor (State s))) (def: (map f ma) - (lambda [state] + (function [state] (let [[state' a] (ma state)] [state' (f a)])))) @@ -20,11 +20,11 @@ (def: functor Functor<State>) (def: (wrap a) - (lambda [state] + (function [state] [state a])) (def: (apply ff fa) - (lambda [state] + (function [state] (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)])))) @@ -33,7 +33,7 @@ (def: applicative Applicative<State>) (def: (join mma) - (lambda [state] + (function [state] (let [[state' ma] (mma state)] (ma state'))))) @@ -41,31 +41,31 @@ (def: #export get {#;doc "Read the current state."} (All [s] (State s s)) - (lambda [state] + (function [state] [state state])) (def: #export (put new-state) {#;doc "Set the new state."} (All [s] (-> s (State s Unit))) - (lambda [state] + (function [state] [new-state []])) (def: #export (update change) {#;doc "Compute the new state."} (All [s] (-> (-> s s) (State s Unit))) - (lambda [state] + (function [state] [(change state) []])) (def: #export (use user) {#;doc "Run function on current state."} (All [s a] (-> (-> s a) (State s a))) - (lambda [state] + (function [state] [state (user state)])) (def: #export (local change action) {#;doc "Run computation with a locally-modified state."} (All [s a] (-> (-> s s) (State s a) (State s a))) - (lambda [state] + (function [state] (let [[state' output] (action (change state))] [state output]))) @@ -77,8 +77,8 @@ (struct: (Functor<StateT> Functor<M>) (All [M s] (-> (Functor M) (Functor (All [a] (-> s (M [s a])))))) (def: (map f sfa) - (lambda [state] - (:: Functor<M> map (lambda [[s a]] [s (f a)]) + (function [state] + (:: Functor<M> map (function [[s a]] [s (f a)]) (sfa state))))) (struct: (Applicative<StateT> Monad<M>) @@ -86,11 +86,11 @@ (def: functor (Functor<StateT> (:: Monad<M> functor))) (def: (wrap a) - (lambda [state] + (function [state] (:: Monad<M> wrap [state a]))) (def: (apply sFf sFa) - (lambda [state] + (function [state] (do Monad<M> [[state f] (sFf state) [state a] (sFa state)] @@ -110,7 +110,7 @@ (All [M s] (-> (Monad M) (Monad (State' M s)))) (def: applicative (Applicative<StateT> Monad<M>)) (def: (join sMsMa) - (lambda [state] + (function [state] (do Monad<M> [[state' sMa] (sMsMa state)] (sMa state'))))) @@ -118,7 +118,7 @@ (def: #export (lift-state Monad<M> ma) {#;doc "Lift monadic values to the State' wrapper."} (All [M s a] (-> (Monad M) (M a) (State' M s a))) - (lambda [state] + (function [state] (do Monad<M> [a ma] (wrap [state a])))) diff --git a/stdlib/source/lux/function/thunk.lux b/stdlib/source/lux/function/thunk.lux index 12af1dfe2..03545b8b6 100644 --- a/stdlib/source/lux/function/thunk.lux +++ b/stdlib/source/lux/function/thunk.lux @@ -13,7 +13,7 @@ (All [a] (-> (-> [] a) (-> [] a))) (let [cache (: (A;Atom (Maybe ($ +0))) (A;atom #;None))] - (lambda [_] + (function [_] (case (io;run (A;get cache)) (#;Some value) value @@ -26,7 +26,7 @@ (syntax: #export (freeze expr) (do @ [g!arg (compiler;gensym "")] - (wrap (list (` (freeze' (lambda [(~ g!arg)] (~ expr)))))))) + (wrap (list (` (freeze' (function [(~ g!arg)] (~ expr)))))))) (def: #export (thaw thunk) (All [a] (-> (Thunk a) a)) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index f935dc8d6..0d8d182a7 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -46,7 +46,7 @@ {#;doc (doc "A way to create JavaScript objects." (object) (object "foo" foo "bar" (inc bar)))} - (wrap (list (L/fold (lambda [[k v] object] + (wrap (list (L/fold (function [[k v] object] (` (set! (~ k) (~ v) (~ object)))) (` (;_lux_proc ["js" "object"] [])) kvs)))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index d9f6c0019..4c8f614bc 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -305,7 +305,7 @@ (-> Primitive-Mode (List TypeParam) Bool GenericType AST) (case class (#GenericTypeVar name) - (case (find (lambda [[pname pbounds]] + (case (find (function [[pname pbounds]] (and (Text/= name pname) (not (list;empty? pbounds)))) type-params) @@ -341,7 +341,7 @@ (def: (class-decl-type$ (^slots [#class-name #class-params])) (-> ClassDecl AST) (let [=params (map (: (-> TypeParam AST) - (lambda [[pname pbounds]] + (function [[pname pbounds]] (case pbounds #;Nil (ast;symbol ["" pname]) @@ -373,7 +373,7 @@ [current-module compiler;current-module-name defs (compiler;defs current-module)] (wrap (fold (: (-> [Text Def] ClassImports ClassImports) - (lambda [[short-name [_ meta _]] imports] + (function [[short-name [_ meta _]] imports] (case (compiler;get-text-ann (ident-for #;;jvm-class) meta) (#;Some full-class-name) (add-import [short-name full-class-name] imports) @@ -489,7 +489,7 @@ (-> (List TypeParam) GenericType Text) (case class (#GenericTypeVar name) - (case (find (lambda [[pname pbounds]] + (case (find (function [[pname pbounds]] (and (Text/= name pname) (not (list;empty? pbounds)))) params) @@ -562,7 +562,7 @@ [meta (#;RecordS pairs)] [meta (#;RecordS (map (: (-> [AST AST] [AST AST]) - (lambda [[key val]] + (function [[key val]] [(pre-walk-replace f key) (pre-walk-replace f val)])) pairs))] @@ -1326,7 +1326,7 @@ (:= .resolved true) (let [sleepers .waitingList sleepers-count (java.util.List.size [] sleepers)] - (map (lambda [idx] + (map (function [idx] (let [sleeper (java.util.List.get [(l2i idx)] sleepers)] (Executor.execute [(@runnable (lux.Function.apply [(:! Object value)] sleeper))] executor))) @@ -1475,7 +1475,7 @@ "If it fails, you get (#;Left error+stack-traces-as-text)." (try (risky-computation input)))} (with-gensyms [g!_] - (wrap (list (`' (_lux_proc ["lux" "try"] [(lambda [(~ g!_)] (~ expr))])))))) + (wrap (list (`' (_lux_proc ["lux" "try"] [(function [(~ g!_)] (~ expr))])))))) (syntax: #export (instance? [#let [imports (class-imports *compiler*)]] [class (generic-type^ imports (list))] @@ -1491,7 +1491,7 @@ (do @ [g!obj (compiler;gensym "obj")] (wrap (list (` (: (-> (host (~' java.lang.Object)) Bool) - (lambda [(~ g!obj)] + (function [(~ g!obj)] (;_lux_proc ["jvm" (~ (ast;text (format "instanceof" ":" (simple-class$ (list) class))))] [(~ g!obj)]))))))) )) @@ -1542,7 +1542,7 @@ (host (~ (ast;symbol ["" full-name]))))) (#;Cons _) - (let [params' (map (lambda [[p _]] (ast;symbol ["" p])) params)] + (let [params' (map (function [[p _]] (ast;symbol ["" p])) params)] (` (def: (~ (ast;symbol ["" def-name])) {#;type? true #;;jvm-class (~ (ast;text full-name))} @@ -1576,7 +1576,7 @@ (do Monad<Lux> [arg-inputs (mapM @ (: (-> [Bool GenericType] (Lux [AST AST])) - (lambda [[maybe? _]] + (function [[maybe? _]] (with-gensyms [arg-name] (wrap [arg-name (if maybe? (` (!!! (~ arg-name))) @@ -1586,15 +1586,15 @@ (map (. (simple-class$ (List/append type-params import-member-tvars)) product;right) import-member-args)) arg-types (map (: (-> [Bool GenericType] AST) - (lambda [[maybe? arg]] + (function [[maybe? arg]] (let [arg-type (class->type (get@ #import-member-mode commons) type-params arg)] (if maybe? (` (Maybe (~ arg-type))) arg-type)))) import-member-args) - arg-lambda-inputs (map product;left arg-inputs) + arg-function-inputs (map product;left arg-inputs) arg-method-inputs (map product;right arg-inputs)]] - (wrap [arg-lambda-inputs arg-method-inputs arg-classes arg-types]))) + (wrap [arg-function-inputs arg-method-inputs arg-classes arg-types]))) _ (:: Monad<Lux> wrap [(list) (list) (list) (list)]))) @@ -1736,7 +1736,7 @@ "float" (` (d2f (~ input))) _ input))) -(def: (member-def-interop type-params kind class [arg-lambda-inputs arg-method-inputs arg-classes arg-types] member method-prefix) +(def: (member-def-interop type-params kind class [arg-function-inputs arg-method-inputs arg-classes arg-types] member method-prefix) (-> (List TypeParam) ClassKind ClassDecl [(List AST) (List AST) (List Text) (List AST)] ImportMemberDecl Text (Lux (List AST))) (let [[full-name class-tvars] class all-params (|> (member-type-vars class-tvars member) @@ -1756,7 +1756,7 @@ (map type-param->type-arg))] (` (All [(~@ =class-tvars)] (host (~ (ast;symbol ["" full-name])) [(~@ =class-tvars)])))))) getter-interop (: (-> Text AST) - (lambda [name] + (function [name] (let [getter-name (ast;symbol ["" (format method-prefix member-separator name)])] (` (def: (~ getter-name) (~ enum-type) @@ -1767,11 +1767,11 @@ (do Monad<Lux> [return-type (member-def-return (get@ #import-member-mode commons) type-params class member) #let [def-name (ast;symbol ["" (format method-prefix member-separator (get@ #import-member-alias commons))]) - def-params (list (ast;tuple arg-lambda-inputs)) + def-params (list (ast;tuple arg-function-inputs)) jvm-interop (|> (` (;_lux_proc ["jvm" (~ (ast;text (format "new" ":" full-name ":" (text;join-with "," arg-classes))))] [(~@ arg-method-inputs)])) (with-mode-inputs (get@ #import-member-mode commons) - (list;zip2 arg-classes arg-lambda-inputs))) + (list;zip2 arg-classes arg-function-inputs))) [return-type jvm-interop] (|> [return-type jvm-interop] (decorate-return-maybe member) (decorate-return-try member) @@ -1806,7 +1806,7 @@ (list g!obj) (list (class-decl-type$ class))] ))) - def-params (#;Cons (ast;tuple arg-lambda-inputs) obj-ast) + def-params (#;Cons (ast;tuple arg-function-inputs) obj-ast) def-param-types (#;Cons (` [(~@ arg-types)]) class-ast) jvm-interop (|> (` (;_lux_proc ["jvm" (~ (ast;text (format jvm-op ":" full-name ":" import-method-name ":" (text;join-with "," arg-classes))))] @@ -1814,7 +1814,7 @@ (with-mode-output (get@ #import-member-mode commons) (get@ #import-method-return method)) (with-mode-inputs (get@ #import-member-mode commons) - (list;zip2 arg-classes arg-lambda-inputs))) + (list;zip2 arg-classes arg-function-inputs))) [return-type jvm-interop] (|> [return-type jvm-interop] (decorate-return-maybe member) (decorate-return-try member) @@ -2094,10 +2094,10 @@ bar (do-something-else my-res2)] (do-one-last-thing foo bar))))} (with-gensyms [g!output g!_] - (let [inits (List/join (List/map (lambda [[res-name res-ctor]] + (let [inits (List/join (List/map (function [[res-name res-ctor]] (list (ast;symbol ["" res-name]) res-ctor)) bindings)) - closes (List/map (lambda [res] + closes (List/map (function [res] (` (try (;_lux_proc ["jvm" "invokevirtual:java.io.Closeable:close:"] [(~ (ast;symbol ["" (product;left res)]))])))) bindings)] @@ -2115,7 +2115,7 @@ (def: get-compiler (Lux Compiler) - (lambda [compiler] + (function [compiler] (#;Right [compiler compiler]))) (def: (fully-qualify-class-name+ imports name) diff --git a/stdlib/source/lux/macro/ast.lux b/stdlib/source/lux/macro/ast.lux index 6647307dd..ff572c6bd 100644 --- a/stdlib/source/lux/macro/ast.lux +++ b/stdlib/source/lux/macro/ast.lux @@ -78,7 +78,7 @@ (^template [<tag>] [[_ (<tag> xs')] [_ (<tag> ys')]] (and (:: Eq<Nat> = (size xs') (size ys')) - (fold (lambda [[x' y'] old] + (fold (function [[x' y'] old] (and old (= x' y'))) true (zip2 xs' ys')))) @@ -87,7 +87,7 @@ [[_ (#;RecordS xs')] [_ (#;RecordS ys')]] (and (:: Eq<Nat> = (size xs') (size ys')) - (fold (lambda [[[xl' xr'] [yl' yr']] old] + (fold (function [[[xl' xr'] [yl' yr']] old] (and old (= xl' yl') (= xr' yr'))) true (zip2 xs' ys'))) @@ -121,7 +121,7 @@ [#;TupleS "[" "]"]) [_ (#;RecordS pairs)] - ($_ Text/append "{" (|> pairs (map (lambda [[left right]] ($_ Text/append (to-text left) " " (to-text right)))) (interpose " ") (text;join-with "")) "}") + ($_ Text/append "{" (|> pairs (map (function [[left right]] ($_ Text/append (to-text left) " " (to-text right)))) (interpose " ") (text;join-with "")) "}") )) (def: #export (replace original substitute ast) @@ -137,7 +137,7 @@ [#;TupleS]) [cursor (#;RecordS parts)] - [cursor (#;RecordS (map (lambda [[left right]] + [cursor (#;RecordS (map (function [[left right]] [(replace original substitute left) (replace original substitute right)]) parts))] diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 872ce84b5..1dfafe38a 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -1,5 +1,5 @@ (;module: - [lux #- list] + [lux #- list function] (lux (control monad [eq]) (data [text] @@ -28,7 +28,7 @@ (do-template [<combinator> <name> <type>] [(def: #export <combinator> (Matcher Unit) - (lambda [:type:] + (;function [:type:] (case (type;un-name :type:) <type> (:: compiler;Monad<Lux> wrap []) @@ -43,7 +43,7 @@ (do-template [<combinator> <name>] [(def: #export <combinator> (Matcher Unit) - (lambda [:type:] + (;function [:type:] (case (type;un-alias :type:) (#;NamedT ["lux" <name>] _) (:: compiler;Monad<Lux> wrap []) @@ -62,7 +62,7 @@ (def: #export primitive (Matcher Type) - (lambda [:type:] + (;function [:type:] (let% [<primitives> (do-template [<parser> <type>] [(do Monad<Lux> [_ (<parser> :type:)] @@ -86,7 +86,7 @@ (do-template [<single> <multi> <flattener> <tag>] [(def: #export <single> (Matcher [Type Type]) - (lambda [:type:] + (;function [:type:] (case (type;un-name :type:) (<tag> :left: :right:) (:: compiler;Monad<Lux> wrap [:left: :right:]) @@ -96,7 +96,7 @@ (def: #export <multi> (Matcher (List Type)) - (lambda [:type:] + (;function [:type:] (let [members (<flattener> (type;un-name :type:))] (if (n.> +1 (list;size members)) (:: compiler;Monad<Lux> wrap members) @@ -108,7 +108,7 @@ (def: #export func (Matcher [Type Type]) - (lambda [:type:] + (;function [:type:] (case (type;un-name :type:) (#;LambdaT :left: :right:) (:: compiler;Monad<Lux> wrap [:left: :right:]) @@ -118,7 +118,7 @@ (def: #export func+ (Matcher [(List Type) Type]) - (lambda [:type:] + (;function [:type:] (let [[ins out] (type;flatten-function (type;un-name :type:))] (if (n.> +0 (list;size ins)) (:: compiler;Monad<Lux> wrap [ins out]) @@ -126,7 +126,7 @@ (def: #export tagged (Matcher [(List Ident) Type]) - (lambda [:type:] + (;function [:type:] (case (type;un-alias :type:) (#;NamedT type-name :def:) (do compiler;Monad<Lux> @@ -138,7 +138,7 @@ (def: #export polymorphic (Matcher [(List AST) Type]) - (lambda [:type:] + (;function [:type:] (loop [:type: (type;un-name :type:)] (case :type: (#;UnivQ _ :type:') @@ -154,7 +154,7 @@ (do-template [<combinator> <sub-comb> <build>] [(def: #export <combinator> (Matcher [(List AST) (List [Ident Type])]) - (lambda [:type:] + (;function [:type:] (do compiler;Monad<Lux> [[tags :type:] (tagged :type:) _ (compiler;assert "Records and variants must have tags." @@ -175,7 +175,7 @@ (def: #export tuple (Matcher [(List AST) (List Type)]) - (lambda [:type:] + (;function [:type:] (do compiler;Monad<Lux> [[vars :type:] (polymorphic :type:) members (prod+ :type:)] @@ -183,7 +183,7 @@ (def: #export function (Matcher [(List AST) [(List Type) Type]]) - (lambda [:type:] + (;function [:type:] (do compiler;Monad<Lux> [[vars :type:] (polymorphic :type:) ins+out (func+ :type:)] @@ -191,7 +191,7 @@ (def: #export apply (Matcher [Type (List Type)]) - (lambda [:type:] + (;function [:type:] (do compiler;Monad<Lux> [#let [[:func: :args:] (loop [:type: (type;un-name :type:)] (case :type: @@ -211,7 +211,7 @@ (do-template [<combinator> <name>] [(def: #export <combinator> (Matcher Type) - (lambda [:type:] + (;function [:type:] (case (type;un-name :type:) (^=> (#;AppT :quant: :arg:) [(type;un-alias :quant:) (#;NamedT ["lux" <name>] _)]) @@ -233,7 +233,7 @@ (def: #export (bound env) (-> Env (Matcher AST)) - (lambda [:type:] + (;function [:type:] (case :type: (#;BoundT idx) (case (dict;get (adjusted-idx env idx) env) @@ -248,7 +248,7 @@ (def: #export (recur env) (-> Env (Matcher AST)) - (lambda [:type:] + (;function [:type:] (do Monad<Lux> [[t-func t-args] (apply :type:)] (case t-func @@ -256,7 +256,7 @@ (n.= +0 (adjusted-idx env t-func-idx)) [(do maybe;Monad<Maybe> [=func (dict;get +0 env) - =args (mapM @ (lambda [t-arg] + =args (mapM @ (;function [t-arg] (case t-arg (#;BoundT idx) (dict;get (adjusted-idx env idx) env) @@ -274,7 +274,7 @@ (def: #export (var env var-id) (-> Env Nat (Matcher Unit)) - (lambda [:type:] + (;function [:type:] (case :type: (^=> (#;BoundT idx) (n.= var-id (adjusted-idx env idx))) @@ -309,15 +309,15 @@ (let [g!inputs (List/map (|>. [""] ast;symbol) inputs) g!name (ast;symbol ["" name]) g!env (ast;symbol ["" env])] - (wrap (;list (` (syntax: (~@ (common;gen-export-level _ex-lev)) ((~ g!name) (~@ (List/map (lambda [g!input] (` [(~ g!input) s;symbol])) + (wrap (;list (` (syntax: (~@ (common;gen-export-level _ex-lev)) ((~ g!name) (~@ (List/map (;function [g!input] (` [(~ g!input) s;symbol])) g!inputs))) (do Monad<Lux> - [(~@ (List/join (List/map (lambda [g!input] (;list g!input (` (compiler;find-type-def (~ g!input))))) + [(~@ (List/join (List/map (;function [g!input] (;list g!input (` (compiler;find-type-def (~ g!input))))) g!inputs))) (~' #let) [(~ g!env) (: Env (dict;new number;Hash<Nat>))] (~ g!body) (: (Lux AST) (loop [(~ g!env) (~ g!env) - (~@ (List/join (List/map (lambda [g!input] (;list g!input g!input)) + (~@ (List/join (List/map (;function [g!input] (;list g!input g!input)) g!inputs)))] (let [(~ g!name) (~' recur)] (~ body))))] diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux index eff158a83..174d8e51e 100644 --- a/stdlib/source/lux/macro/poly/eq.lux +++ b/stdlib/source/lux/macro/poly/eq.lux @@ -27,21 +27,21 @@ output _ - (` (lambda (~@ (if (list;empty? inputs) (list) (list func))) + (` (function (~@ (if (list;empty? inputs) (list) (list func))) [(~@ inputs)] (~ output))))) ## [Derivers] (poly: #export (Eq<?> env :x:) (let [->Eq (: (-> AST AST) - (lambda [.type.] (` (eq;Eq (~ .type.)))))] + (function [.type.] (` (eq;Eq (~ .type.)))))] (let% [<basic> (do-template [<type> <matcher> <eq>] [(do @ [_ (<matcher> :x:)] (wrap (` (: (~ (->Eq (` <type>))) <eq>))))] - [Unit poly;unit (lambda [(~' test) (~' input)] true)] + [Unit poly;unit (function [(~' test) (~' input)] true)] [Bool poly;bool bool;Eq<Bool>] [Nat poly;nat number;Eq<Nat>] [Int poly;int number;Eq<Int>] @@ -60,7 +60,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) env)] pattern-matching (mapM @ - (lambda [[name :case:]] + (function [[name :case:]] (do @ [g!eq (Eq<?> new-env :case:)] (wrap (list (` [((~ (ast;tag name)) (~ g!left)) @@ -68,7 +68,7 @@ (` ((~ g!eq) (~ g!left) (~ g!right))))))) members) #let [base (function$ g!type-fun g!vars - (` (lambda [(~ g!left) (~ g!right)] + (` (function [(~ g!left) (~ g!right)] (case [(~ g!left) (~ g!right)] (~@ (List/join pattern-matching))))))]] (wrap (` (: (~ (poly;gen-type new-env ->Eq g!type-fun g!vars :x:)) @@ -81,7 +81,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) env)] pattern-matching (mapM @ - (lambda [:member:] + (function [:member:] (do @ [g!left (compiler;gensym "g!left") g!right (compiler;gensym "g!right") @@ -91,8 +91,8 @@ #let [.left. (` [(~@ (List/map product;left pattern-matching))]) .right. (` [(~@ (List/map (|>. product;right product;left) pattern-matching))]) base (function$ g!type-fun g!vars - (` (lambda [(~ .left.) (~ .right.)] - (and (~@ (List/map (lambda [[g!left g!right g!eq]] + (` (function [(~ .left.) (~ .right.)] + (and (~@ (List/map (function [[g!left g!right g!eq]] (` ((~ g!eq) (~ g!left) (~ g!right)))) pattern-matching))))))]] (wrap (` (: (~ (poly;gen-type new-env ->Eq g!type-fun g!vars :x:)) diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index f5bf71c39..f6961d717 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -34,13 +34,13 @@ _ (compiler;assert "Functors must have at least 1 type-variable." (n.> +0 num-vars))] (let [->Functor (: (-> AST AST) - (lambda [.type.] + (function [.type.] (if (n.= +1 num-vars) (` (functor;Functor (~ .type.))) (let [type-params (|> num-vars n.dec list;indices (List/map (|>. %n ast;local-symbol)))] (` (All [(~@ type-params)] (functor;Functor ((~ .type.) (~@ type-params))))))))) Arg<?> (: (-> AST (poly;Matcher AST)) - (lambda Arg<?> [value :type:] + (function Arg<?> [value :type:] ($_ compiler;either ## Nothing to do. (do @ @@ -58,7 +58,7 @@ (do @ [[g!vars members] (poly;tuple :type:) pm (mapM @ - (lambda [:slot:] + (function [:slot:] (do @ [g!slot (compiler;gensym "g!slot") body (Arg<?> g!slot :slot:)] @@ -78,7 +78,7 @@ (do @ [[g!vars cases] (poly;variant :x:) pattern-matching (mapM @ - (lambda [[name :case:]] + (function [[name :case:]] (do @ [#let [analysis (` ((~ (ast;tag name)) (~ g!input)))] synthesis (Arg<?> g!input :case:)] @@ -94,7 +94,7 @@ (do @ [[g!vars members] (poly;tuple :x:) pm (mapM @ - (lambda [:slot:] + (function [:slot:] (do @ [g!slot (compiler;gensym "g!slot") body (Arg<?> g!slot :slot:)] @@ -116,7 +116,7 @@ (compiler;gensym "g!envs")))] (wrap (` (: (~ (->Functor (type;to-ast :x:))) (struct (def: ((~ g!map) (~ g!func) (~ g!input)) - (lambda [(~@ g!envs)] + (function [(~@ g!envs)] (let [(~ g!out) ((~ g!input) (~@ g!envs))] (~ .out.)))))))))) ## No structure (as you'd expect from Identity) diff --git a/stdlib/source/lux/macro/poly/text-encoder.lux b/stdlib/source/lux/macro/poly/text-encoder.lux index c4b148709..5649622de 100644 --- a/stdlib/source/lux/macro/poly/text-encoder.lux +++ b/stdlib/source/lux/macro/poly/text-encoder.lux @@ -28,21 +28,21 @@ output _ - (` (lambda (~@ (if (list;empty? inputs) (list) (list func))) + (` (function (~@ (if (list;empty? inputs) (list) (list func))) [(~@ inputs)] (~ output))))) ## [Derivers] (poly: #export (Codec<Text,?>::encode env :x:) (let [->Codec::encode (: (-> AST AST) - (lambda [.type.] (` (-> (~ .type.) Text))))] + (function [.type.] (` (-> (~ .type.) Text))))] (let% [<basic> (do-template [<type> <matcher> <encoder>] [(do @ [_ (<matcher> :x:)] (wrap (` (: (~ (->Codec::encode (` <type>))) (~' <encoder>)))))] - [Unit poly;unit (lambda [_0] "[]")] + [Unit poly;unit (function [_0] "[]")] [Bool poly;bool (:: bool;Codec<Text,Bool> encode)] [Nat poly;nat (:: number;Codec<Text,Nat> encode)] [Int poly;int (:: number;Codec<Text,Int> encode)] @@ -61,7 +61,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) env)] pattern-matching (mapM @ - (lambda [[name :case:]] + (function [[name :case:]] (do @ [encoder (Codec<Text,?>::encode new-env :case:)] (wrap (list (` ((~ (ast;tag name)) (~ g!case))) @@ -72,7 +72,7 @@ ")")))))) cases) #let [base (function$ g!type-fun g!vars - (` (lambda [(~ g!input)] + (` (function [(~ g!input)] (case (~ g!input) (~@ (List/join pattern-matching))))))]] (wrap (` (: (~ (poly;gen-type env ->Codec::encode g!type-fun g!vars :x:)) @@ -86,7 +86,7 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) env)] synthesis (mapM @ - (lambda [[name :slot:]] + (function [[name :slot:]] (do @ [encoder (Codec<Text,?>::encode new-env :slot:)] (wrap (` (format "#" @@ -95,7 +95,7 @@ ((~ encoder) (get@ (~ (ast;tag name)) (~ g!input)))))))) slots) #let [base (function$ g!type-fun g!vars - (` (lambda [(~ g!input)] + (` (function [(~ g!input)] (format "{" (~@ (list;interpose (' " ") synthesis)) "}"))))]] (wrap (` (: (~ (poly;gen-type env ->Codec::encode g!type-fun g!vars :x:)) (~ base) @@ -108,18 +108,18 @@ (list;zip2 (|> g!vars list;size poly;type-var-indices) g!vars) env)] parts (mapM @ - (lambda [:member:] + (function [:member:] (do @ [g!member (compiler;gensym "g!member") encoder (Codec<Text,?>::encode new-env :member:)] (wrap [g!member encoder]))) members) #let [analysis (` [(~@ (List/map product;left parts))]) - synthesis (List/map (lambda [[g!member g!encoder]] + synthesis (List/map (function [[g!member g!encoder]] (` ((~ g!encoder) (~ g!member)))) parts) base (function$ g!type-fun g!vars - (` (lambda [(~ g!input)] + (` (function [(~ g!input)] (case (~ g!input) (~ analysis) (format "[" (~@ (list;interpose (' " ") synthesis)) "]")))))]] diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 4b8339b8e..3d7b4575f 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -30,7 +30,7 @@ ## [Structures] (struct: #export _ (Functor Syntax) (def: (map f ma) - (lambda [tokens] + (function [tokens] (case (ma tokens) (#;Left msg) (#;Left msg) @@ -45,7 +45,7 @@ (#;Right [tokens x])) (def: (apply ff fa) - (lambda [tokens] + (function [tokens] (case (ff tokens) (#;Right [tokens' f]) (case (fa tokens') @@ -62,7 +62,7 @@ (def: applicative Applicative<Syntax>) (def: (join mma) - (lambda [tokens] + (function [tokens] (case (mma tokens) (#;Left msg) (#;Left msg) @@ -80,7 +80,7 @@ (def: #export any {#;doc "Just returns the next input without applying any logic."} (Syntax AST) - (lambda [tokens] + (function [tokens] (case tokens #;Nil (#;Left "There are no tokens to parse!") (#;Cons [t tokens']) (#;Right [tokens' t])))) @@ -89,7 +89,7 @@ [(def: #export <get-name> {#;doc (#;TextA ($_ Text/append "Parses the next " <desc> " input AST."))} (Syntax <type>) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [[_ (<tag> x)] tokens']) (#;Right [tokens' x]) @@ -111,7 +111,7 @@ (def: #export (this? ast) {#;doc "Asks if the given AST is the next input."} (-> AST (Syntax Bool)) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [token tokens']) (let [is-it? (AST/= ast token) @@ -126,7 +126,7 @@ (def: #export (this! ast) {#;doc "Ensures the given AST is the next input."} (-> AST (Syntax Unit)) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [token tokens']) (if (AST/= ast token) @@ -140,7 +140,7 @@ (def: #export (assert message test) {#;doc "Fails with the given message if the test is false."} (-> Text Bool (Syntax Unit)) - (lambda [tokens] + (function [tokens] (if test (#;Right [tokens []]) (#;Left ($_ Text/append message (remaining-inputs tokens)))))) @@ -161,7 +161,7 @@ [(def: #export <name> {#;doc (#;TextA ($_ Text/append "Parse a local " <desc> " (a " <desc> " that has no module prefix)."))} (Syntax Text) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [[_ (<tag> ["" x])] tokens']) (#;Right [tokens' x]) @@ -178,7 +178,7 @@ {#;doc (#;TextA ($_ Text/append "Parse inside the contents of a " <desc> " as if they were the input ASTs."))} (All [a] (-> (Syntax a) (Syntax a))) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [[_ (<tag> members)] tokens']) (case (p members) @@ -196,7 +196,7 @@ {#;doc (#;TextA ($_ Text/append "Parse inside the contents of a record as if they were the input ASTs."))} (All [a] (-> (Syntax a) (Syntax a))) - (lambda [tokens] + (function [tokens] (case tokens (#;Cons [[_ (#;RecordS pairs)] tokens']) (case (p (join-pairs pairs)) @@ -210,7 +210,7 @@ {#;doc "Optionality combinator."} (All [a] (-> (Syntax a) (Syntax (Maybe a)))) - (lambda [tokens] + (function [tokens] (case (p tokens) (#;Left _) (#;Right [tokens #;None]) (#;Right [tokens' x]) (#;Right [tokens' (#;Some x)])))) @@ -224,7 +224,7 @@ {#;doc "0-or-more combinator."} (All [a] (-> (Syntax a) (Syntax (List a)))) - (lambda [tokens] + (function [tokens] (case (p tokens) (#;Left _) (#;Right [tokens (list)]) (#;Right [tokens' x]) (run tokens' @@ -255,7 +255,7 @@ {#;doc "Heterogeneous alternative combinator."} (All [a b] (-> (Syntax a) (Syntax b) (Syntax (| a b)))) - (lambda [tokens] + (function [tokens] (case (p1 tokens) (#;Right [tokens' x1]) (#;Right [tokens' (+0 x1)]) (#;Left _) (run tokens @@ -268,7 +268,7 @@ {#;doc "Homogeneous alternative combinator."} (All [a] (-> (Syntax a) (Syntax a) (Syntax a))) - (lambda [tokens] + (function [tokens] (case (pl tokens) (#;Left _) (pr tokens) output output @@ -277,7 +277,7 @@ (def: #export end! {#;doc "Ensures there are no more inputs."} (Syntax Unit) - (lambda [tokens] + (function [tokens] (case tokens #;Nil (#;Right [tokens []]) _ (#;Left ($_ Text/append "Expected list of tokens to be empty!" (remaining-inputs tokens)))))) @@ -285,7 +285,7 @@ (def: #export end? {#;doc "Checks whether there are no more inputs."} (Syntax Bool) - (lambda [tokens] + (function [tokens] (case tokens #;Nil (#;Right [tokens true]) _ (#;Right [tokens false])))) @@ -312,7 +312,7 @@ {#;doc "Parse at most N times."} (All [a] (-> Nat (Syntax a) (Syntax (List a)))) (if (n.> +0 n) - (lambda [input] + (function [input] (case (p input) (#;Left msg) (#;Right [input (list)]) @@ -350,7 +350,7 @@ (def: #export (not p) (All [a] (-> (Syntax a) (Syntax Unit))) - (lambda [input] + (function [input] (case (p input) (#;Left msg) (#;Right [input []]) @@ -360,13 +360,13 @@ (def: #export (fail message) (All [a] (-> Text (Syntax a))) - (lambda [input] + (function [input] (#;Left message))) (def: #export (default value parser) {#;doc "If the given parser fails, returns the default value."} (All [a] (-> a (Syntax a) (Syntax a))) - (lambda [input] + (function [input] (case (parser input) (#;Left error) (#;Right [input value]) @@ -377,7 +377,7 @@ (def: #export (on compiler action) {#;doc "Run a Lux operation as if it was a Syntax parser."} (All [a] (-> Compiler (Lux a) (Syntax a))) - (lambda [input] + (function [input] (case (compiler;run compiler action) (#;Left error) (#;Left error) @@ -389,7 +389,7 @@ (def: #export (local local-inputs syntax) {#;doc "Run a syntax parser with the given list of inputs, instead of the real ones."} (All [a] (-> (List AST) (Syntax a) (Syntax a))) - (lambda [real-inputs] + (function [real-inputs] (case (syntax local-inputs) (#;Left error) (#;Left error) @@ -407,7 +407,7 @@ (def: #export (rec syntax) {#;doc "Combinator for recursive syntax."} (All [a] (-> (-> (Syntax a) (Syntax a)) (Syntax a))) - (lambda [inputs] + (function [inputs] (run inputs (syntax (rec syntax))))) ## [Syntax] @@ -458,7 +458,7 @@ (do Monad<Lux> [vars+parsers (mapM Monad<Lux> (: (-> AST (Lux [AST AST])) - (lambda [arg] + (function [arg] (case arg (^ [_ (#;TupleS (list var parser))]) (wrap [var parser]) @@ -483,7 +483,7 @@ (list)))]] (wrap (list (` (macro: (~@ export-ast) ((~ (ast;symbol ["" name])) (~ g!tokens)) (~ meta) - (lambda [(~ g!state)] + (function [(~ g!state)] (;_lux_case (run (~ g!tokens) (: (Syntax (Lux (List AST))) (do Monad<Syntax> diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index c49e82969..7ebce4268 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -122,7 +122,7 @@ init-op s;any init-param (infix^ []) steps (s;some (s;seq s;any (infix^ [])))] - (wrap (product;right (fold (lambda [[op param] [subject [_subject _op _param]]] + (wrap (product;right (fold (function [[op param] [subject [_subject _op _param]]] [param [(#Infix _subject _op _param) (` and) (#Infix subject op param)]]) @@ -134,7 +134,7 @@ init-op s;any init-param (infix^ []) steps (s;some (s;seq s;any (infix^ [])))] - (wrap (fold (lambda [[op param] [_subject _op _param]] + (wrap (fold (function [[op param] [_subject _op _param]] [(#Infix _subject _op _param) op param]) [init-subject init-op init-param] steps))) diff --git a/stdlib/source/lux/math/logic/fuzzy.lux b/stdlib/source/lux/math/logic/fuzzy.lux index ea3a795ff..c3677649b 100644 --- a/stdlib/source/lux/math/logic/fuzzy.lux +++ b/stdlib/source/lux/math/logic/fuzzy.lux @@ -16,30 +16,30 @@ (def: #export (union left right) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) - (lambda [elem] + (function [elem] (&;~or (membership elem left) (membership elem right)))) (def: #export (intersection left right) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) - (lambda [elem] + (function [elem] (&;~and (membership elem left) (membership elem right)))) (def: #export (complement set) (All [a] (-> (Fuzzy a) (Fuzzy a))) - (lambda [elem] + (function [elem] (&;~not (membership elem set)))) (def: #export (difference sub base) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) - (lambda [elem] + (function [elem] (&;~and (membership elem base) (&;~not (membership elem sub))))) (def: #export (from-predicate predicate) (All [a] (-> (-> a Bool) (Fuzzy a))) - (lambda [elem] + (function [elem] (if (predicate elem) &;~true &;~false))) @@ -51,7 +51,7 @@ (do-template [<ascending> <descending> <gradient> <type> <lt> <gt> <lte> <gte> <sub> <div> <post>] [(def: (<ascending> from to) (-> <type> <type> (Fuzzy <type>)) - (lambda [elem] + (function [elem] (cond (<lte> from elem) &;~false @@ -64,7 +64,7 @@ (def: (<descending> from to) (-> <type> <type> (Fuzzy <type>)) - (lambda [elem] + (function [elem] (cond (<lte> from elem) &;~true @@ -112,7 +112,7 @@ (def: #export (gaussian deviation center) (-> Real Real (Fuzzy Real)) - (lambda [elem] + (function [elem] (let [scale (|> deviation (math;pow 2.0) (r.* 2.0)) membership (|> elem (r.- center) @@ -126,7 +126,7 @@ (def: #export (cut treshold set) (All [a] (-> Deg (Fuzzy a) (Fuzzy a))) - (lambda [elem] + (function [elem] (let [membership (set elem)] (if (d.> treshold membership) (|> membership (d.- treshold) (d.* &;~true)) @@ -134,7 +134,7 @@ (def: #export (to-predicate treshold set) (All [a] (-> Deg (Fuzzy a) (-> a Bool))) - (lambda [elem] + (function [elem] (d.> treshold (set elem)))) (type: #export (Fuzzy2 a) @@ -142,7 +142,7 @@ (def: #export (type-2 lower upper) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy2 a))) - (lambda [elem] + (function [elem] (let [l-deg (lower elem) u-deg (upper elem)] [(d.min l-deg diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index e828cb715..372aafbfc 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -32,7 +32,7 @@ (struct: #export _ (Functor Random) (def: (map f fa) - (lambda [state] + (function [state] (let [[state' a] (fa state)] [state' (f a)])))) @@ -40,11 +40,11 @@ (def: functor Functor<Random>) (def: (wrap a) - (lambda [state] + (function [state] [state a])) (def: (apply ff fa) - (lambda [state] + (function [state] (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)])))) @@ -53,13 +53,13 @@ (def: applicative Applicative<Random>) (def: (join ffa) - (lambda [state] + (function [state] (let [[state' fa] (ffa state)] (fa state'))))) (def: #export nat (Random Nat) - (lambda [prng] + (function [prng] (let [[prng left] (prng []) [prng right] (prng [])] [prng (n.+ (bit;<< +32 left) @@ -67,7 +67,7 @@ (def: #export int (Random Int) - (lambda [prng] + (function [prng] (let [[prng left] (prng []) [prng right] (prng [])] [prng (nat-to-int (n.+ (bit;<< +32 left) @@ -75,13 +75,13 @@ (def: #export bool (Random Bool) - (lambda [prng] + (function [prng] (let [[prng output] (prng [])] [prng (|> output (bit;& +1) (n.= +1))]))) (def: (bits n) (-> Nat (Random Nat)) - (lambda [prng] + (function [prng] (let [[prng output] (prng [])] [prng (bit;>>> (n.- n +64) output)]))) @@ -164,7 +164,7 @@ (def: #export (rec gen) {#;doc "A combinator for producing recursive random generators."} (All [a] (-> (-> (Random a) (Random a)) (Random a))) - (lambda [state] + (function [state] (let [gen' (gen (rec gen))] (gen' state)))) @@ -257,7 +257,7 @@ For more information, please see: http://www.pcg-random.org/"} (-> [Nat Nat] PRNG) - (lambda [_] + (function [_] (let [seed' (|> seed (n.* pcg-32-magic-mult) (n.+ inc)) xor-shifted (|> seed (bit;>>> +18) (bit;^ seed) (bit;>>> +27)) rot (|> seed (bit;>>> +59))] @@ -270,7 +270,7 @@ For more information, please see: http://xoroshiro.di.unimi.it/"} (-> [Nat Nat] PRNG) - (lambda [_] + (function [_] (let [result (n.+ s0 s1) s01 (bit;^ s0 s1) s0' (|> (bit;rotate-left +55 s0) @@ -292,7 +292,7 @@ (All [a] (-> Nat (V;Vector a) (V;Vector a))) (let [_size (V;size vector) _shuffle (foldM Monad<Random> - (lambda [idx vec] + (function [idx vec] (do Monad<Random> [rand nat] (wrap (swap idx (n.% _size rand) vec)))) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 8e854d501..6465cd632 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -49,7 +49,7 @@ (-> (List [Text (IO Test) Text]) (Promise Nat)) (do Monad<Promise> [#let [test-runs (List/map (: (-> [Text (IO Test) Text] (Promise Nat)) - (lambda [[module test description]] + (function [[module test description]] (do @ [#let [pre (io;run now)] outcome (io;run test) @@ -251,7 +251,7 @@ (do Monad<Lux> [defs (compiler;exports module-name)] (wrap (|> defs - (List/map (lambda [[def-name [_ def-anns _]]] + (List/map (function [[def-name [_ def-anns _]]] (case (compiler;get-text-ann (ident-for #;;test) def-anns) (#;Some description) [true module-name def-name description] @@ -276,7 +276,7 @@ list;reverse (mapM @ exported-tests) (:: @ map List/join))) - #let [tests+ (List/map (lambda [[module-name test desc]] + #let [tests+ (List/map (function [[module-name test desc]] (` [(~ (ast;text module-name)) (~ (ast;symbol [module-name test])) (~ (ast;text desc))])) tests) num-tests (list;size tests+) @@ -284,7 +284,7 @@ (wrap (list (` (: (IO Unit) (io (exec (do Monad<Promise> [(~' #let) [(~ g!accum) +0] - (~@ (List/join (List/map (lambda [group] + (~@ (List/join (List/map (function [group] (list g!_ (` (run' (list (~@ group)))) (' #let) (` [(~ g!accum) (n.+ (~ g!_) (~ g!accum))]))) groups))) diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux index e53c89ca9..001c95389 100644 --- a/stdlib/source/lux/type.lux +++ b/stdlib/source/lux/type.lux @@ -1,5 +1,5 @@ (;module: {#;doc "Basic functionality for working with types."} - lux + [lux #- function] (lux (control eq monad) (data [text "Text/" Monoid<Text> Eq<Text>] @@ -49,7 +49,7 @@ [(#;HostT xname xparams) (#;HostT yname yparams)] (and (Text/= xname yname) (n.= (list;size yparams) (list;size xparams)) - (List/fold (lambda [[x y] prev] (and prev (= x y))) + (List/fold (;function [[x y] prev] (and prev (= x y))) true (list;zip2 xparams yparams))) @@ -81,7 +81,7 @@ [(#;ExQ xenv xbody) (#;ExQ yenv ybody)]) (and (n.= (list;size yenv) (list;size xenv)) (= xbody ybody) - (List/fold (lambda [[x y] prev] (and prev (= x y))) + (List/fold (;function [[x y] prev] (and prev (= x y))) true (list;zip2 xenv yenv))) diff --git a/stdlib/source/lux/type/auto.lux b/stdlib/source/lux/type/auto.lux index 7059536c3..585617c3a 100644 --- a/stdlib/source/lux/type/auto.lux +++ b/stdlib/source/lux/type/auto.lux @@ -109,23 +109,23 @@ (def: (prepare-defs this-module-name defs) (-> Text (List [Text Def]) (List [Ident Type])) (|> defs - (list;filter (lambda [[name [def-type def-anns def-value]]] + (list;filter (function [[name [def-type def-anns def-value]]] (compiler;struct? def-anns))) - (List/map (lambda [[name [def-type def-anns def-value]]] + (List/map (function [[name [def-type def-anns def-value]]] [[this-module-name name] def-type])))) (def: local-env (Lux (List [Ident Type])) (do Monad<Lux> [local-batches compiler;locals - #let [total-locals (List/fold (lambda [[name type] table] + #let [total-locals (List/fold (function [[name type] table] (dict;put~ name type table)) (: (dict;Dict Text Type) (dict;new text;Hash<Text>)) (List/join local-batches))]] (wrap (|> total-locals dict;entries - (List/map (lambda [[name type]] [["" name] type])))))) + (List/map (function [[name type]] [["" name] type])))))) (def: local-structs (Lux (List [Ident Type])) @@ -139,7 +139,7 @@ (do Monad<Lux> [this-module-name compiler;current-module-name imp-mods (compiler;imported-modules this-module-name) - export-batches (mapM @ (lambda [imp-mod] + export-batches (mapM @ (function [imp-mod] (do @ [exports (compiler;exports imp-mod)] (wrap (prepare-defs imp-mod exports)))) @@ -185,7 +185,7 @@ (-> Type (List Type) Type (Check [])) (do Monad<Check> [member-type' (foldM Monad<Check> - (lambda [input member] + (function [input member] (apply-function-type member input)) member-type input-types)] @@ -193,7 +193,7 @@ (def: compiler-type-context (Lux tc;Context) - (lambda [compiler] + (function [compiler] (let [type-vars (get@ #;type-vars compiler) context (|> tc;fresh-context (set@ #tc;var-counter (get@ #;counter type-vars)) @@ -211,7 +211,7 @@ (do Monad<Lux> [compiler compiler;get-compiler] (case (|> alts - (List/map (lambda [[alt-name alt-type]] + (List/map (function [[alt-name alt-type]] (case (tc;run context (do Monad<Check> [[tvars alt-type] (concrete-type alt-type) @@ -260,7 +260,7 @@ [compiler compiler;get-compiler context compiler-type-context] (case (|> alts - (List/map (lambda [[alt-name alt-type]] + (List/map (function [[alt-name alt-type]] (case (tc;run context (do Monad<Check> [[tvars alt-type] (concrete-type alt-type) diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux index db5ca251f..a7214a002 100644 --- a/stdlib/source/lux/type/check.lux +++ b/stdlib/source/lux/type/check.lux @@ -32,7 +32,7 @@ (struct: #export _ (Functor Check) (def: (map f fa) - (lambda [context] + (function [context] (case (fa context) (#;Left error) (#;Left error) @@ -45,11 +45,11 @@ (def: functor Functor<Check>) (def: (wrap x) - (lambda [context] + (function [context] (#;Right [context x]))) (def: (apply ff fa) - (lambda [context] + (function [context] (case (ff context) (#;Right [context' f]) (case (fa context') @@ -68,7 +68,7 @@ (def: applicative Applicative<Check>) (def: (join ffa) - (lambda [context] + (function [context] (case (ffa context) (#;Right [context' fa]) (case (fa context') @@ -97,7 +97,7 @@ (def: (apply-type! t-func t-arg) (-> Type Type (Check Type)) - (lambda [context] + (function [context] (case (type;apply-type t-func t-arg) #;None (#;Left (format "Invalid type application: " (%type t-func) " on " (%type t-arg))) @@ -108,14 +108,14 @@ (def: #export existential {#;doc "A producer of existential types."} (Check [Id Type]) - (lambda [context] + (function [context] (let [id (get@ #ex-counter context)] (#;Right [(update@ #ex-counter n.inc context) [id (#;ExT id)]])))) (def: (bound? id) (-> Id (Check Bool)) - (lambda [context] + (function [context] (case (|> context (get@ #bindings) (dict;get id)) (#;Some (#;Some _)) (#;Right [context true]) @@ -128,7 +128,7 @@ (def: #export (read-var id) (-> Id (Check Type)) - (lambda [context] + (function [context] (case (|> context (get@ #bindings) (dict;get id)) (#;Some (#;Some type)) (#;Right [context type]) @@ -141,7 +141,7 @@ (def: #export (write-var id type) (-> Id Type (Check Unit)) - (lambda [context] + (function [context] (case (|> context (get@ #bindings) (dict;get id)) (#;Some (#;Some bound)) (#;Left (format "Can't rebind type-var: " (%n id) " | Current type: " (%type bound))) @@ -155,7 +155,7 @@ (def: (rewrite-var id type) (-> Id Type (Check Unit)) - (lambda [context] + (function [context] (case (|> context (get@ #bindings) (dict;get id)) (#;Some _) (#;Right [(update@ #bindings (dict;put id (#;Some type)) context) @@ -166,7 +166,7 @@ (def: #export (clear-var id) (-> Id (Check Unit)) - (lambda [context] + (function [context] (case (|> context (get@ #bindings) (dict;get id)) (#;Some _) (#;Right [(update@ #bindings (dict;put id #;None) context) @@ -238,7 +238,7 @@ (def: #export create-var (Check [Id Type]) - (lambda [context] + (function [context] (let [id (get@ #var-counter context)] (#;Right [(|> context (update@ #var-counter n.inc) @@ -248,13 +248,13 @@ (do-template [<get> <set> <tag> <type>] [(def: <get> (Check <type>) - (lambda [context] + (function [context] (#;Right [context (get@ <tag> context)]))) (def: (<set> value) (-> <type> (Check Unit)) - (lambda [context] + (function [context] (#;Right [(set@ <tag> value context) []])))] @@ -273,7 +273,7 @@ (write-var id ex))) bindings get-bindings bindings' (mapM @ - (lambda [(^@ binding [b-id b-type])] + (function [(^@ binding [b-id b-type])] (if (n.= id b-id) (wrap binding) (case b-type @@ -313,7 +313,7 @@ (def: (attempt op) (All [a] (-> (Check a) (Check (Maybe a)))) - (lambda [context] + (function [context] (case (op context) (#;Right [context' output]) (#;Right [context' (#;Some output)]) @@ -323,7 +323,7 @@ (def: #export (fail message) (All [a] (-> Text (Check a))) - (lambda [context] + (function [context] (#;Left message))) (def: (fail-check expected actual) @@ -335,7 +335,7 @@ (def: (either left right) (All [a] (-> (Check a) (Check a) (Check a))) - (lambda [context] + (function [context] (case (left context) (#;Right [context' output]) (#;Right [context' output]) @@ -346,7 +346,7 @@ (def: (fp-get [e a] fixpoints) (-> [Type Type] Fixpoints (Maybe Bool)) (:: Monad<Maybe> map product;right - (list;find (lambda [[[fe fa] status]] + (list;find (function [[[fe fa] status]] (and (Type/= e fe) (Type/= a fa))) fixpoints))) @@ -446,7 +446,7 @@ [_ (#;UnivQ _)] (with-var - (lambda [[var-id var]] + (function [[var-id var]] (do Monad<Check> [actual' (apply-type! actual var) =output (check expected actual') @@ -455,7 +455,7 @@ [(#;ExQ e!env e!def) _] (with-var - (lambda [[var-id var]] + (function [[var-id var]] (do Monad<Check> [expected' (apply-type! expected var) =output (check expected' actual) @@ -472,7 +472,7 @@ (if (Text/= e-name a-name) (do Monad<Check> [_ (mapM Monad<Check> - (lambda [[e a]] (check e a)) + (function [[e a]] (check e a)) (list;zip2 e-params a-params))] success) (fail-check expected actual)) @@ -519,5 +519,5 @@ (def: #export get-context (Check Context) - (lambda [context] + (function [context] (#;Right [context context]))) diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux index 49100ef01..a4c69a880 100644 --- a/stdlib/test/test/lux/concurrency/actor.lux +++ b/stdlib/test/test/lux/concurrency/actor.lux @@ -22,11 +22,11 @@ (test: "Actors" (let [counter-proc (: (&;Behavior Int (Promise Int)) - [(lambda [self output state] + [(function [self output state] (let [state' (i.inc state)] (exec (io;run (promise;resolve state' output)) (Promise/wrap (#;Right state'))))) - (lambda [?error state] (Promise/wrap []))])] + (function [?error state] (Promise/wrap []))])] ($_ seq (assert "Can check where an actor is alive." (let [counter (: (&;Actor Int (Promise Int)) diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index 6c2e9af99..a141753a8 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -13,7 +13,7 @@ (-> (List Int) (&;Chan Int)) (let [_chan (: (&;Chan Int) (&;chan))] (io;run (do Monad<IO> - [_ (mapM @ (lambda [value] (&;write value _chan)) + [_ (mapM @ (function [value] (&;write value _chan)) values) _ (&;close _chan)] (wrap _chan))))) @@ -65,7 +65,7 @@ false))) (do Monad<Promise> - [output (&;fold (lambda [base input] (Promise/wrap (i.+ input base))) 0 (List->Chan (list 0 1 2 3 4 5)))] + [output (&;fold (function [base input] (Promise/wrap (i.+ input base))) 0 (List->Chan (list 0 1 2 3 4 5)))] (assert "Can fold over a channel." (i.= 15 output))) diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux index d6b6c1d43..c1c8144ae 100644 --- a/stdlib/test/test/lux/concurrency/stm.lux +++ b/stdlib/test/test/lux/concurrency/stm.lux @@ -44,8 +44,8 @@ (let [_concurrency-var (&;var 0)] (do promise;Monad<Promise> [_ (seqM @ - (map (lambda [_] - (mapM @ (lambda [_] (&;commit (&;update i.inc _concurrency-var))) + (map (function [_] + (mapM @ (function [_] (&;commit (&;update i.inc _concurrency-var))) (list;i.range 1 iterations/processes))) (list;i.range 1 (nat-to-int promise;concurrency-level)))) last-val (&;commit (&;read _concurrency-var))] diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux index f7d09ae9a..6006cf021 100644 --- a/stdlib/test/test/lux/data/coll/array.lux +++ b/stdlib/test/test/lux/data/coll/array.lux @@ -34,7 +34,7 @@ (not (is original copy))))) (assert "Array folding should go over all values." (exec (:: &;Fold<Array> fold - (lambda [x idx] + (function [x idx] (exec (&;put idx x manual-copy) (n.inc idx))) +0 @@ -83,7 +83,7 @@ (case> (#;Some _) true #;None false))) (assert "Can find values inside arrays (with access to indices)." - (|> (&;find+ (lambda [idx n] + (|> (&;find+ (function [idx n] (and (n.even? n) (n.< size idx))) array) diff --git a/stdlib/test/test/lux/data/coll/dict.lux b/stdlib/test/test/lux/data/coll/dict.lux index 34e99cf58..ee54f9204 100644 --- a/stdlib/test/test/lux/data/coll/dict.lux +++ b/stdlib/test/test/lux/data/coll/dict.lux @@ -17,9 +17,9 @@ size capped-nat dict (R;dict char;Hash<Char> size R;char capped-nat) non-key (|> R;char - (R;filter (lambda [key] (not (&;contains? key dict))))) + (R;filter (function [key] (not (&;contains? key dict))))) test-val (|> R;nat - (R;filter (lambda [val] (not (list;member? number;Eq<Nat> (&;values dict) val)))))] + (R;filter (function [val] (not (list;member? number;Eq<Nat> (&;values dict) val)))))] ($_ seq (assert "Size function should correctly represent Dict size." (n.= size (&;size dict))) @@ -36,13 +36,13 @@ (&;values dict)))) (assert "Dict should be able to recognize it's own keys." - (list;every? (lambda [key] (&;contains? key dict)) + (list;every? (function [key] (&;contains? key dict)) (&;keys dict))) (assert "Should be able to get every key." - (list;every? (lambda [key] (case (&;get key dict) - (#;Some _) true - _ false)) + (list;every? (function [key] (case (&;get key dict) + (#;Some _) true + _ false)) (&;keys dict))) (assert "Shouldn't be able to access non-existant keys." @@ -99,13 +99,13 @@ (assert "If you merge, and the second dict has overlapping keys, it should overwrite yours." (let [dict' (|> dict &;entries - (List/map (lambda [[k v]] [k (n.inc v)])) + (List/map (function [[k v]] [k (n.inc v)])) (&;from-list char;Hash<Char>)) (^open) (&;Eq<Dict> number;Eq<Nat>)] (= dict' (&;merge dict' dict)))) (assert "Can merge values in such a way that they become combined." - (list;every? (lambda [[x x*2]] (n.= (n.* +2 x) x*2)) + (list;every? (function [[x x*2]] (n.= (n.* +2 x) x*2)) (list;zip2 (&;values dict) (&;values (&;merge-with n.+ dict dict))))) diff --git a/stdlib/test/test/lux/data/coll/list.lux b/stdlib/test/test/lux/data/coll/list.lux index bd6f78015..0840b11e3 100644 --- a/stdlib/test/test/lux/data/coll/list.lux +++ b/stdlib/test/test/lux/data/coll/list.lux @@ -197,7 +197,7 @@ (assert "You can iteratively construct a list, generating values until you're done." (= (&;n.range +0 (n.dec size)) - (&;iterate (lambda [n] (if (n.< size n) (#;Some (n.inc n)) #;None)) + (&;iterate (function [n] (if (n.< size n) (#;Some (n.inc n)) #;None)) +0))) (assert "Can enumerate all elements in a list." diff --git a/stdlib/test/test/lux/data/coll/priority-queue.lux b/stdlib/test/test/lux/data/coll/priority-queue.lux index 3e28334db..f82216f54 100644 --- a/stdlib/test/test/lux/data/coll/priority-queue.lux +++ b/stdlib/test/test/lux/data/coll/priority-queue.lux @@ -11,7 +11,7 @@ (-> Nat (R;Random (&;Queue Nat))) (do R;Monad<Random> [inputs (R;list size R;nat)] - (foldM @ (lambda [head tail] + (foldM @ (function [head tail] (do @ [priority R;nat] (wrap (&;push priority head tail)))) diff --git a/stdlib/test/test/lux/data/coll/stream.lux b/stdlib/test/test/lux/data/coll/stream.lux index 2ee3013e2..edc7d52dc 100644 --- a/stdlib/test/test/lux/data/coll/stream.lux +++ b/stdlib/test/test/lux/data/coll/stream.lux @@ -86,7 +86,7 @@ (List/= (&;take size (&/map Nat/encode (&;iterate n.inc offset))) (&;take size - (&;unfold (lambda [n] [(n.inc n) (Nat/encode n)]) + (&;unfold (function [n] [(n.inc n) (Nat/encode n)]) offset))))) (assert "Can cycle over the same elements as an infinite stream." diff --git a/stdlib/test/test/lux/data/coll/tree/zipper.lux b/stdlib/test/test/lux/data/coll/tree/zipper.lux index 143229dc5..a6799d302 100644 --- a/stdlib/test/test/lux/data/coll/tree/zipper.lux +++ b/stdlib/test/test/lux/data/coll/tree/zipper.lux @@ -14,7 +14,7 @@ (def: gen-tree (R;Random (rose;Tree Nat)) - (R;rec (lambda [gen-tree] + (R;rec (function [gen-tree] (do R;Monad<Random> ## Each branch can have, at most, 1 child. [size (|> R;nat (:: @ map (n.% +2)))] diff --git a/stdlib/test/test/lux/data/error/exception.lux b/stdlib/test/test/lux/data/error/exception.lux index bc84df7f5..2a297a587 100644 --- a/stdlib/test/test/lux/data/error/exception.lux +++ b/stdlib/test/test/lux/data/error/exception.lux @@ -40,8 +40,8 @@ (if should-throw? (&;throw this-ex "Uh-oh...") (&;return default-val))) - (&;catch Some-Exception (lambda [ex] some-val)) - (&;catch Another-Exception (lambda [ex] another-val)) - (&;otherwise (lambda [ex] otherwise-val)))]] + (&;catch Some-Exception (function [ex] some-val)) + (&;catch Another-Exception (function [ex] another-val)) + (&;otherwise (function [ex] otherwise-val)))]] (assert "Catch and otherwhise handlers can properly handle the flow of exception-handling." (n.= expected actual))) diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index 37fe49786..6328533bc 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -27,7 +27,7 @@ (def: gen-json (R;Random &;JSON) - (R;rec (lambda [gen-json] + (R;rec (function [gen-json] (do R;Monad<Random> [size (:: @ map (n.% +2) R;nat)] ($_ R;alt @@ -95,7 +95,7 @@ (struct: _ (Eq Record) (def: (= recL recR) - (let [variant/= (lambda [left right] + (let [variant/= (function [left right] (case [left right] [(#Case0 left') (#Case0 right')] (:: bool;Eq<Bool> = left' right') diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux index 0479cb561..16c586d63 100644 --- a/stdlib/test/test/lux/data/format/xml.lux +++ b/stdlib/test/test/lux/data/format/xml.lux @@ -39,7 +39,7 @@ (def: gen-xml (R;Random &;XML) - (R;rec (lambda [gen-xml] + (R;rec (function [gen-xml] (R;alt (xml-text^ +1 +10) (do R;Monad<Random> [size (size^ +0 +2)] diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 131db1441..dbae41674 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -73,11 +73,11 @@ (assert "" (and (<= x (:: <Interval> bottom)) (>= x (:: <Interval> top)))))] - ["Nat" R;nat Number<Nat> Order<Nat> Interval<Nat> (lambda [_] true)] - ["Int" R;int Number<Int> Order<Int> Interval<Int> (lambda [_] true)] + ["Nat" R;nat Number<Nat> Order<Nat> Interval<Nat> (function [_] true)] + ["Int" R;int Number<Int> Order<Int> Interval<Int> (function [_] true)] ## Both min and max values will be positive (thus, greater than zero) ["Real" R;real Number<Real> Order<Real> Interval<Real> (r.> 0.0)] - ["Deg" R;deg Number<Deg> Order<Deg> Interval<Deg> (lambda [_] true)] + ["Deg" R;deg Number<Deg> Order<Deg> Interval<Deg> (function [_] true)] ) (do-template [category rand-gen <Number> <Order> <Monoid> <cap> <test>] @@ -91,22 +91,22 @@ (= x (append x unit)) (= unit (append unit unit)))))] - ["Nat/Add" R;nat Number<Nat> Order<Nat> Add@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Mul" R;nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Min" R;nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Nat/Max" R;nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n.% +1000) (lambda [_] true)] - ["Int/Add" R;int Number<Int> Order<Int> Add@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Mul" R;int Number<Int> Order<Int> Mul@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Min" R;int Number<Int> Order<Int> Min@Monoid<Int> (i.% 1000) (lambda [_] true)] - ["Int/Max" R;int Number<Int> Order<Int> Max@Monoid<Int> (i.% 1000) (lambda [_] true)] + ["Nat/Add" R;nat Number<Nat> Order<Nat> Add@Monoid<Nat> (n.% +1000) (function [_] true)] + ["Nat/Mul" R;nat Number<Nat> Order<Nat> Mul@Monoid<Nat> (n.% +1000) (function [_] true)] + ["Nat/Min" R;nat Number<Nat> Order<Nat> Min@Monoid<Nat> (n.% +1000) (function [_] true)] + ["Nat/Max" R;nat Number<Nat> Order<Nat> Max@Monoid<Nat> (n.% +1000) (function [_] true)] + ["Int/Add" R;int Number<Int> Order<Int> Add@Monoid<Int> (i.% 1000) (function [_] true)] + ["Int/Mul" R;int Number<Int> Order<Int> Mul@Monoid<Int> (i.% 1000) (function [_] true)] + ["Int/Min" R;int Number<Int> Order<Int> Min@Monoid<Int> (i.% 1000) (function [_] true)] + ["Int/Max" R;int Number<Int> Order<Int> Max@Monoid<Int> (i.% 1000) (function [_] true)] ["Real/Add" R;real Number<Real> Order<Real> Add@Monoid<Real> (r.% 1000.0) (r.> 0.0)] ["Real/Mul" R;real Number<Real> Order<Real> Mul@Monoid<Real> (r.% 1000.0) (r.> 0.0)] ["Real/Min" R;real Number<Real> Order<Real> Min@Monoid<Real> (r.% 1000.0) (r.> 0.0)] ["Real/Max" R;real Number<Real> Order<Real> Max@Monoid<Real> (r.% 1000.0) (r.> 0.0)] - ["Deg/Add" R;deg Number<Deg> Order<Deg> Add@Monoid<Deg> (d.% .125) (lambda [_] true)] - ## ["Deg/Mul" R;deg Number<Deg> Order<Deg> Mul@Monoid<Deg> (d.% .125) (lambda [_] true)] - ["Deg/Min" R;deg Number<Deg> Order<Deg> Min@Monoid<Deg> (d.% .125) (lambda [_] true)] - ["Deg/Max" R;deg Number<Deg> Order<Deg> Max@Monoid<Deg> (d.% .125) (lambda [_] true)] + ["Deg/Add" R;deg Number<Deg> Order<Deg> Add@Monoid<Deg> (d.% .125) (function [_] true)] + ## ["Deg/Mul" R;deg Number<Deg> Order<Deg> Mul@Monoid<Deg> (d.% .125) (function [_] true)] + ["Deg/Min" R;deg Number<Deg> Order<Deg> Min@Monoid<Deg> (d.% .125) (function [_] true)] + ["Deg/Max" R;deg Number<Deg> Order<Deg> Max@Monoid<Deg> (d.% .125) (function [_] true)] ) (do-template [<category> <rand-gen> <Eq> <Codec>] diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index 389ff1b9e..6e88e6b07 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -28,6 +28,10 @@ (list (+0 "0") (+1 "1") (+0 "2")))))))) (assert "Can apply a function to an Either value depending on the case." - (and (i.= 10 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+0 "")))) - (i.= 20 (either (lambda [_] 10) (lambda [_] 20) (: (| Text Text) (+1 "")))))) + (and (i.= 10 (either (function [_] 10) + (function [_] 20) + (: (| Text Text) (+0 "")))) + (i.= 20 (either (function [_] 10) + (function [_] 20) + (: (| Text Text) (+1 "")))))) ))) diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index 92aeca0d8..8a63cf573 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -221,9 +221,9 @@ (assert "Can lex using arbitrary predicates." (and (should-passC #"D" (&;run "D" - (&;satisfies (lambda [c] true)))) + (&;satisfies (function [c] true)))) (should-fail (&;run "C" - (&;satisfies (lambda [c] false)))))) + (&;satisfies (function [c] false)))))) (assert "Can apply a lexer multiple times." (and (should-passT "0123456789ABCDEF" (&;run "0123456789ABCDEF yolo" diff --git a/stdlib/test/test/lux/function/cont.lux b/stdlib/test/test/lux/function/cont.lux index eda75833e..4362f5a75 100644 --- a/stdlib/test/test/lux/function/cont.lux +++ b/stdlib/test/test/lux/function/cont.lux @@ -35,7 +35,7 @@ (n.= (n.* +2 sample) (&;run (do &;Monad<Cont> [value (&;call/cc - (lambda [k] + (function [k] (do @ [temp (k sample)] ## If this code where to run, @@ -57,14 +57,14 @@ (^open "L/") (list;Eq<List> number;Eq<Nat>) visit (: (-> (List Nat) (&;Cont (List Nat) (List Nat))) - (lambda visit [xs] + (function visit [xs] (case xs #;Nil (&/wrap #;Nil) (#;Cons x xs') (do &;Monad<Cont> - [output (&;shift (lambda [k] + [output (&;shift (function [k] (do @ [tail (k xs')] (wrap (#;Cons x tail)))))] diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux index d1098b960..0ebc23489 100644 --- a/stdlib/test/test/lux/type.lux +++ b/stdlib/test/test/lux/type.lux @@ -26,7 +26,7 @@ (def: gen-type (R;Random Type) (let [(^open "R/") R;Monad<Random>] - (R;rec (lambda [gen-type] + (R;rec (function [gen-type] ($_ R;alt (R;seq gen-name (R/wrap (list))) (R/wrap []) @@ -81,7 +81,7 @@ (test: "Type construction [structs]" [size (|> R;nat (:: @ map (n.% +3))) members (|> gen-type - (R;filter (lambda [type] + (R;filter (function [type] (case type (^or (#;SumT _) (#;ProdT _)) false @@ -110,7 +110,7 @@ [size (|> R;nat (:: @ map (n.% +3))) members (seqM @ (list;repeat size gen-type)) extra (|> gen-type - (R;filter (lambda [type] + (R;filter (function [type] (case type (^or (#;LambdaT _) (#;AppT _)) false @@ -133,7 +133,7 @@ (test: "Type construction [higher order]" [size (|> R;nat (:: @ map (n.% +3))) extra (|> gen-type - (R;filter (lambda [type] + (R;filter (function [type] (case type (^or (#;UnivQ _) (#;ExQ _)) false diff --git a/stdlib/test/test/lux/type/check.lux b/stdlib/test/test/lux/type/check.lux index d76a53622..8235ff808 100644 --- a/stdlib/test/test/lux/type/check.lux +++ b/stdlib/test/test/lux/type/check.lux @@ -26,7 +26,7 @@ (def: gen-type (R;Random Type) (let [(^open "R/") R;Monad<Random>] - (R;rec (lambda [gen-type] + (R;rec (function [gen-type] ($_ R;alt (R;seq gen-name (R/wrap (list))) (R/wrap []) @@ -150,26 +150,26 @@ (test: "Type-vars" ($_ seq (assert "Type-vars check against themselves." - (type-checks? (&;with-var (lambda [[id var]] (&;check var var))))) + (type-checks? (&;with-var (function [[id var]] (&;check var var))))) (assert "Can bind unbound type-vars by type-checking against them." - (and (type-checks? (&;with-var (lambda [[id var]] (&;check var #;UnitT)))) - (type-checks? (&;with-var (lambda [[id var]] (&;check #;UnitT var)))))) + (and (type-checks? (&;with-var (function [[id var]] (&;check var #;UnitT)))) + (type-checks? (&;with-var (function [[id var]] (&;check #;UnitT var)))))) (assert "Can't rebind already bound type-vars." - (not (type-checks? (&;with-var (lambda [[id var]] + (not (type-checks? (&;with-var (function [[id var]] (do &;Monad<Check> [_ (&;check var #;UnitT)] (&;check var #;VoidT))))))) (assert "If the type bound to a var is a super-type to another, then the var is also a super-type." - (type-checks? (&;with-var (lambda [[id var]] + (type-checks? (&;with-var (function [[id var]] (do &;Monad<Check> [_ (&;check var Top)] (&;check var #;UnitT)))))) (assert "If the type bound to a var is a sub-type of another, then the var is also a sub-type." - (type-checks? (&;with-var (lambda [[id var]] + (type-checks? (&;with-var (function [[id var]] (do &;Monad<Check> [_ (&;check var Bottom)] (&;check #;UnitT var)))))) diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux index 08d73a430..931a89e28 100644 --- a/stdlib/test/tests.lux +++ b/stdlib/test/tests.lux @@ -10,9 +10,9 @@ ["_;" host] ["_;" io] (function ["_;" cont] - ["_;" reader] - ["_;" state] - ["_;" thunk]) + ["_;" reader] + ["_;" state] + ["_;" thunk]) (concurrency ["_;" actor] ["_;" atom] ["_;" frp] @@ -72,7 +72,8 @@ [trace] [store]) [macro] - (math [random]))) + (math [random])) + ) ## [Program] (program: args |