From 435771d3c4d4ffa791805e7006ee3bde488a4090 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Apr 2018 07:48:25 -0400 Subject: - Improved the syntax for the "lux.function" macro. --- stdlib/source/lux.lux | 204 +++++++++++----------- stdlib/source/lux/cli.lux | 12 +- stdlib/source/lux/concurrency/actor.lux | 20 ++- stdlib/source/lux/concurrency/frp.lux | 6 +- stdlib/source/lux/concurrency/promise.lux | 16 +- stdlib/source/lux/concurrency/stm.lux | 24 +-- stdlib/source/lux/concurrency/task.lux | 2 +- stdlib/source/lux/control/comonad.lux | 9 +- stdlib/source/lux/control/concatenative.lux | 54 +++--- stdlib/source/lux/control/cont.lux | 30 ++-- stdlib/source/lux/control/exception.lux | 2 +- stdlib/source/lux/control/monad.lux | 13 +- stdlib/source/lux/control/monad/indexed.lux | 6 +- stdlib/source/lux/control/parser.lux | 32 ++-- stdlib/source/lux/control/pipe.lux | 6 +- stdlib/source/lux/control/predicate.lux | 4 +- stdlib/source/lux/control/reader.lux | 12 +- stdlib/source/lux/control/region.lux | 24 +-- stdlib/source/lux/control/state.lux | 30 ++-- stdlib/source/lux/control/thread.lux | 18 +- stdlib/source/lux/control/writer.lux | 6 +- stdlib/source/lux/data/coll/array.lux | 14 +- stdlib/source/lux/data/coll/bits.lux | 2 +- stdlib/source/lux/data/coll/dict.lux | 24 +-- stdlib/source/lux/data/coll/list.lux | 22 +-- stdlib/source/lux/data/coll/ordered/dict.lux | 2 +- stdlib/source/lux/data/coll/sequence.lux | 15 +- stdlib/source/lux/data/coll/set.lux | 2 +- stdlib/source/lux/data/coll/stream.lux | 2 +- stdlib/source/lux/data/coll/tree/parser.lux | 4 +- stdlib/source/lux/data/coll/tree/rose.lux | 2 +- stdlib/source/lux/data/coll/tree/zipper.lux | 41 +++-- stdlib/source/lux/data/color.lux | 6 +- stdlib/source/lux/data/format/context.lux | 2 +- stdlib/source/lux/data/format/css.lux | 6 +- stdlib/source/lux/data/format/html.lux | 2 +- stdlib/source/lux/data/format/json.lux | 20 +-- stdlib/source/lux/data/format/xml.lux | 14 +- stdlib/source/lux/data/lazy.lux | 4 +- stdlib/source/lux/data/number/complex.lux | 2 +- stdlib/source/lux/data/product.lux | 8 +- stdlib/source/lux/data/store.lux | 4 +- stdlib/source/lux/data/sum.lux | 4 +- stdlib/source/lux/data/text/format.lux | 2 +- stdlib/source/lux/data/text/lexer.lux | 24 +-- stdlib/source/lux/data/text/regex.lux | 8 +- stdlib/source/lux/data/trace.lux | 4 +- stdlib/source/lux/function.lux | 4 +- stdlib/source/lux/host.js.lux | 2 +- stdlib/source/lux/host.jvm.lux | 29 +-- stdlib/source/lux/lang/syntax.lux | 4 +- stdlib/source/lux/lang/type.lux | 4 +- stdlib/source/lux/lang/type/check.lux | 54 +++--- stdlib/source/lux/macro.lux | 58 +++--- stdlib/source/lux/macro/code.lux | 8 +- stdlib/source/lux/macro/poly.lux | 16 +- stdlib/source/lux/macro/poly/eq.lux | 29 +-- stdlib/source/lux/macro/poly/functor.lux | 21 +-- stdlib/source/lux/macro/poly/json.lux | 52 +++--- stdlib/source/lux/macro/syntax.lux | 24 +-- stdlib/source/lux/math.lux | 6 +- stdlib/source/lux/math/constructive.lux | 7 +- stdlib/source/lux/math/logic/fuzzy.lux | 22 +-- stdlib/source/lux/math/modular.lux | 2 +- stdlib/source/lux/math/random.lux | 26 +-- stdlib/source/lux/test.lux | 12 +- stdlib/source/lux/time/duration.lux | 2 +- stdlib/source/lux/time/instant.lux | 4 +- stdlib/source/lux/type/abstract.lux | 8 +- stdlib/source/lux/type/implicit.lux | 16 +- stdlib/source/lux/type/object/interface.lux | 10 +- stdlib/source/lux/type/object/protocol.lux | 4 +- stdlib/source/lux/type/refinement.lux | 4 +- stdlib/source/lux/type/resource.lux | 22 +-- stdlib/source/lux/type/unit.lux | 4 +- stdlib/source/lux/world/net/tcp.jvm.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 2 +- stdlib/test/test/lux/concurrency/semaphore.lux | 4 +- stdlib/test/test/lux/concurrency/stm.lux | 6 +- stdlib/test/test/lux/control/cont.lux | 6 +- stdlib/test/test/lux/control/exception.lux | 6 +- stdlib/test/test/lux/control/region.lux | 6 +- stdlib/test/test/lux/data/coll/array.lux | 4 +- stdlib/test/test/lux/data/coll/dict.lux | 16 +- stdlib/test/test/lux/data/coll/list.lux | 25 +-- stdlib/test/test/lux/data/coll/ordered/dict.lux | 6 +- stdlib/test/test/lux/data/coll/priority-queue.lux | 2 +- stdlib/test/test/lux/data/coll/stream.lux | 2 +- stdlib/test/test/lux/data/coll/tree/rose.lux | 4 +- stdlib/test/test/lux/data/coll/tree/zipper.lux | 2 +- stdlib/test/test/lux/data/color.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 9 +- stdlib/test/test/lux/data/format/xml.lux | 2 +- stdlib/test/test/lux/data/number.lux | 30 ++-- stdlib/test/test/lux/data/sum.lux | 8 +- stdlib/test/test/lux/data/text/lexer.lux | 4 +- stdlib/test/test/lux/lang/syntax.lux | 10 +- stdlib/test/test/lux/lang/type.lux | 8 +- stdlib/test/test/lux/lang/type/check.lux | 6 +- stdlib/test/test/lux/macro/poly/eq.lux | 2 +- stdlib/test/test/lux/math/modular.lux | 4 +- stdlib/test/test/lux/type/object/protocol.lux | 2 +- stdlib/test/test/lux/world/net/tcp.lux | 2 +- 103 files changed, 725 insertions(+), 685 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index ec9ac013e..10e188769 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2003,7 +2003,7 @@ (text$ "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms. ## All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used. (` (def: (~ name) - (function [(~+ args)] + (function ((~' _) (~+ args)) (~ body))))")]) ("lux case" tokens {(#Cons template #Nil) @@ -2021,7 +2021,7 @@ (list [(tag$ ["lux" "doc"]) (text$ "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms. (`' (def: (~ name) - (function [(~+ args)] + (function (_ (~+ args)) (~ body))))")]) ("lux case" tokens {(#Cons template #Nil) @@ -3034,23 +3034,20 @@ (text$ "## Syntax for creating functions. ## Allows for giving the function itself a name, for the sake of recursion. (: (All [a b] (-> a b a)) - (function [x y] x)) + (function (_ x y) x)) (: (All [a b] (-> a b a)) - (function const [x y] x))")]) - (case (: (Maybe [Ident Code (List Code) Code]) + (function (const x y) x))")]) + (case (: (Maybe [Text Code (List Code) Code]) (case tokens - (^ (list [_ (#Tuple (#Cons head tail))] body)) - (#Some ["" ""] head tail body) - - (^ (list [_ (#Symbol ["" name])] [_ (#Tuple (#Cons head tail))] body)) - (#Some ["" name] head tail body) + (^ (list [_ (#Form (list& [_ (#Symbol ["" name])] head tail))] body)) + (#Some name head tail body) _ #None)) (#Some g!name head tail body) (let [g!blank (symbol$ ["" ""]) - g!name (symbol$ g!name) + g!name (symbol$ ["" g!name]) body+ (list/fold (: (-> Code Code Code) (function' [arg body'] (if (symbol? arg) @@ -3102,7 +3099,7 @@ [_ (#Record kvs)] (|> kvs (list/map (: (-> [Code Code] Code) - (function [[k v]] + (function (_ [k v]) (` [(~ (process-def-meta-value k)) (~ (process-def-meta-value v))])))) untemplate-list @@ -3112,7 +3109,7 @@ (def:' (process-def-meta kvs) (-> (List [Code Code]) Code) (untemplate-list (list/map (: (-> [Code Code] Code) - (function [[k v]] + (function (_ [k v]) (` [(~ (process-def-meta-value k)) (~ (process-def-meta-value v))]))) kvs))) @@ -3125,14 +3122,14 @@ _ (` (#.Cons [[(~ cursor-code) (#.Tag ["lux" "func-args"])] - [(~ cursor-code) (#.Tuple (.list (~+ (list/map (function [arg] + [(~ cursor-code) (#.Tuple (.list (~+ (list/map (function (_ arg) (` [(~ cursor-code) (#.Text (~ (text$ (code-to-text arg))))])) args))))]] (~ meta))))) (def:' (with-type-args args) (-> (List Code) Code) - (` {#.type-args [(~+ (list/map (function [arg] (text$ (code-to-text arg))) + (` {#.type-args [(~+ (list/map (function (_ arg) (text$ (code-to-text arg))) args))]})) (def:' (export^ tokens) @@ -3197,7 +3194,7 @@ body _ - (` (function (~ name) [(~+ args)] (~ body)))) + (` (function ((~ name) (~+ args)) (~ body)))) body (case ?type (#Some type) (` (: (~ type) (~ body))) @@ -3320,7 +3317,7 @@ members (: (Meta (List [Text Code])) (monad/map Monad (: (-> Code (Meta [Text Code])) - (function [token] + (function (_ token) (case token (^ [_ (#Form (list [_ (#Text "lux check")] type [_ (#Symbol ["" name])]))]) (wrap [name type]) @@ -3331,7 +3328,7 @@ #let [[_module _name] name+ def-name (symbol$ name) sig-type (record$ (list/map (: (-> [Text Code] [Code Code]) - (function [[m-name m-type]] + (function (_ [m-name m-type]) [(tag$ ["" m-name]) m-type])) members)) sig-meta (meta-code-merge (` {#.sig? true}) @@ -3368,7 +3365,7 @@ (case (list/reverse tokens) (^ (list& last init)) (return (list (list/fold (: (-> Code Code Code) - (function [pre post] (`
))) + (function (_ pre post) (` ))) last init))) @@ -3579,7 +3576,7 @@ (def: (find-module name) (-> Text (Meta Module)) - (function [state] + (function (_ state) (let [{#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #extensions extensions @@ -3642,7 +3639,7 @@ (def: get-expected-type (Meta Type) - (function [state] + (function (_ state) (let [{#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #extensions extensions @@ -3668,11 +3665,11 @@ _ (fail "No tags available for type."))) #let [tag-mappings (: (List [Text Code]) - (list/map (function [tag] [(second tag) (tag$ tag)]) + (list/map (function (_ tag) [(second tag) (tag$ tag)]) tags))] members (monad/map Monad (: (-> Code (Meta [Code Code])) - (function [token] + (function (_ token) (case token (^ [_ (#Form (list [_ (#Text "lux def")] [_ (#Symbol "" tag-name)] value meta))]) (case (get tag-name tag-mappings) @@ -3730,7 +3727,7 @@ (^ [_ (#Form (list& [_ (#Symbol [_ sig-name])] sig-args))]) (case (: (Maybe (List Text)) (monad/map Monad - (function [sa] + (function (_ sa) (case sa [_ (#Symbol [_ arg-name])] (#Some arg-name) @@ -3881,7 +3878,7 @@ (-> (List Code) (Meta (List Text))) (monad/map Monad (: (-> Code (Meta Text)) - (function [def] + (function (_ def) (case def [_ (#Symbol ["" name])] (return name) @@ -3977,16 +3974,16 @@ (^ (list& [_ (#Tag "" "open")] [_ (#Form parts)] tokens')) (if (|> parts (list/map (: (-> Code Bool) - (function [part] + (function (_ part) (case part (^or [_ (#Text _)] [_ (#Symbol _)]) true _ false)))) - (list/fold (function [r l] (and l r)) true)) + (list/fold (function (_ r l) (and l r)) true)) (let [openings (list/fold (: (-> Code (List Openings) (List Openings)) - (function [part openings] + (function (_ part openings) (case part [_ (#Text prefix)] (list& [prefix (list)] openings) @@ -4013,16 +4010,16 @@ (-> (List Code) (Meta [(List Openings) (List Code)])) (if (|> parts (list/map (: (-> Code Bool) - (function [part] + (function (_ part) (case part (^or [_ (#Text _)] [_ (#Symbol _)]) true _ false)))) - (list/fold (function [r l] (and l r)) true)) + (list/fold (function (_ r l) (and l r)) true)) (let [openings (list/fold (: (-> Code (List Openings) (List Openings)) - (function [part openings] + (function (_ part openings) (case part [_ (#Text prefix)] (list& [prefix (list)] openings) @@ -4045,7 +4042,7 @@ (def: (decorate-sub-importations super-name) (-> Text (List Importation) (List Importation)) (list/map (: (-> Importation Importation) - (function [importation] + (function (_ importation) (let [{#import-name _name #import-alias _alias #import-refer {#refer-defs _referrals @@ -4109,7 +4106,7 @@ (do Monad [imports' (monad/map Monad (: (-> Code (Meta (List Importation))) - (function [token] + (function (_ token) (case token [_ (#Symbol "" m-name)] (do Monad @@ -4179,7 +4176,7 @@ (#Some =module) (let [to-alias (list/map (: (-> [Text Definition] (List Text)) - (function [[name [def-type def-meta def-value]]] + (function (_ [name [def-type def-meta def-value]]) (case (get-meta ["lux" "export?"] def-meta) (#Some [_ (#Bool true)]) (list name) @@ -4207,7 +4204,7 @@ (def: (is-member? cases name) (-> (List Text) Text Bool) - (let [output (list/fold (function [case prev] + (let [output (list/fold (function (_ case prev) (or prev (text/= case name))) false @@ -4229,14 +4226,14 @@ #seed seed #expected expected #cursor cursor #extensions extensions #scope-type-vars scope-type-vars} (find (: (-> Scope (Maybe Type)) - (function [env] + (function (_ env) (case env {#name _ #inner _ #locals {#counter _ #mappings locals} #captured {#counter _ #mappings closure}} (try-both (find (: (-> [Text [Type Top]] (Maybe Type)) - (function [[bname [type _]]] + (function (_ [bname [type _]]) (if (text/= name bname) (#Some type) #None)))) @@ -4298,7 +4295,7 @@ (do Monad [#let [[module name] ident] current-module current-module-name] - (function [compiler] + (function (_ compiler) (let [temp (if (text/= "" module) (case (find-in-env name compiler) (#Some struct-type) @@ -4429,14 +4426,14 @@ (#Some tags&members) (do Monad [full-body ((: (-> Ident [(List Ident) (List Type)] Code (Meta Code)) - (function recur [source [tags members] target] - (let [pattern (record$ (list/map (function [[t-module t-name]] + (function (recur source [tags members] target) + (let [pattern (record$ (list/map (function (_ [t-module t-name]) [(tag$ [t-module t-name]) (symbol$ ["" (text/compose prefix t-name)])]) tags))] (do Monad [enhanced-target (monad/fold Monad - (function [[[_ m-name] m-type] enhanced-target] + (function (_ [[_ m-name] m-type] enhanced-target) (do Monad [m-structure (resolve-type-tags m-type)] (case m-structure @@ -4467,7 +4464,7 @@ (case (list/reverse tokens) (^ (list& else branches')) (return (list (list/fold (: (-> [Code Code] Code Code) - (function [branch else] + (function (_ branch else) (let [[right left] branch] (` (if (~ left) (~ right) (~ else)))))) else @@ -4511,7 +4508,7 @@ (case (resolve-struct-type type) (#Some members) (let [pattern (record$ (list/map (: (-> [Ident [Nat Type]] [Code Code]) - (function [[[r-prefix r-name] [r-idx r-type]]] + (function (_ [[r-prefix r-name] [r-idx r-type]]) [(tag$ [r-prefix r-name]) (if (n/= idx r-idx) g!output @@ -4524,15 +4521,16 @@ (^ (list [_ (#Tuple slots)] record)) (return (list (list/fold (: (-> Code Code Code) - (function [slot inner] + (function (_ slot inner) (` (..get@ (~ slot) (~ inner))))) record slots))) (^ (list selector)) (do Monad - [g!record (gensym "record")] - (wrap (list (` (function [(~ g!record)] (..get@ (~ selector) (~ g!record))))))) + [g!_ (gensym "_") + g!record (gensym "record")] + (wrap (list (` (function ((~ g!_) (~ g!record)) (..get@ (~ selector) (~ g!record))))))) _ (fail "Wrong syntax for get@"))) @@ -4547,7 +4545,7 @@ (do Monad [decls' (monad/map Monad (: (-> [Ident Type] (Meta (List Code))) - (function [[sname stype]] (open-field prefix sname source+ stype))) + (function (_ [sname stype]) (open-field prefix sname source+ stype))) (zip2 tags members))] (return (list/join decls'))) @@ -4581,7 +4579,7 @@ (#Some [tags members]) (do Monad [decls' (monad/map Monad (: (-> [Ident Type] (Meta (List Code))) - (function [[sname stype]] (open-field prefix sname source stype))) + (function (_ [sname stype]) (open-field prefix sname source stype))) (zip2 tags members))] (return (list/join decls'))) @@ -4595,25 +4593,27 @@ {#.doc "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it. (|>> (list/map int/encode) (interpose \" \") (fold text/compose \"\")) ## => - (function [] + (function (_ ) (fold text/compose \"\" (interpose \" \" (list/map int/encode ))))"} (do Monad - [g!arg (gensym "arg")] - (return (list (` (function [(~ g!arg)] (|> (~ g!arg) (~+ tokens)))))))) + [g!_ (gensym "_") + g!arg (gensym "arg")] + (return (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens)))))))) (macro: #export (<<| tokens) {#.doc "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it. (<<| (fold text/compose \"\") (interpose \" \") (list/map int/encode)) ## => - (function [] + (function (_ ) (fold text/compose \"\" (interpose \" \" (list/map int/encode ))))"} (do Monad - [g!arg (gensym "arg")] - (return (list (` (function [(~ g!arg)] (<| (~+ tokens) (~ g!arg)))))))) + [g!_ (gensym "_") + g!arg (gensym "arg")] + (return (list (` (function ((~ g!_) (~ g!arg)) (<| (~+ tokens) (~ g!arg)))))))) (def: (imported-by? import-name module-name) (-> Text Text (Meta Bool)) @@ -4631,10 +4631,10 @@ #let [[openings options] openings+options] current-module current-module-name #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit))) - (function [module-name all-defs referred-defs] + (function (_ module-name all-defs referred-defs) (monad/map Monad (: (-> Text (Meta Unit)) - (function [_def] + (function (_ _def) (if (is-member? all-defs _def) (return []) (fail ($_ text/compose _def " is not defined in module " module-name " @ " current-module))))) @@ -4656,10 +4656,10 @@ (do Monad [current-module current-module-name #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit))) - (function [module-name all-defs referred-defs] + (function (_ module-name all-defs referred-defs) (monad/map Monad (: (-> Text (Meta Unit)) - (function [_def] + (function (_ _def) (if (is-member? all-defs _def) (return []) (fail ($_ text/compose _def " is not defined in module " module-name " @ " current-module))))) @@ -4683,7 +4683,7 @@ #Nothing (wrap (list))) #let [defs (list/map (: (-> Text Code) - (function [def] + (function (_ def) (` ("lux def" (~ (symbol$ ["" def])) (~ (symbol$ [module-name def])) [(~ cursor-code) @@ -4692,8 +4692,8 @@ #Nil))])))) defs') openings (join-map (: (-> Openings (List Code)) - (function [[prefix structs]] - (list/map (function [[_ name]] (` (open (~ (symbol$ [module-name name])) (~ (text$ prefix))))) + (function (_ [prefix structs]) + (list/map (function (_ [_ name]) (` (open (~ (symbol$ [module-name name])) (~ (text$ prefix))))) structs))) r-opens)]] (wrap (list/compose defs openings)) @@ -4726,7 +4726,7 @@ #Nothing (list))) - =opens (join-map (function [[prefix structs]] + =opens (join-map (function (_ [prefix structs]) (list& (text$ prefix) (list/map symbol$ structs))) r-opens)] (` (..refer (~ (text$ module-name)) @@ -4771,11 +4771,11 @@ current-module current-module-name imports (parse-imports current-module _imports) #let [=imports (list/map (: (-> Importation Code) - (function [[m-name m-alias =refer]] + (function (_ [m-name m-alias =refer]) (` [(~ (text$ m-name)) (~ (text$ (default "" m-alias)))]))) imports) =refers (list/map (: (-> Importation Code) - (function [[m-name m-alias =refer]] + (function (_ [m-name m-alias =refer]) (refer-to-code m-name =refer))) imports) =meta (process-def-meta (list& [(` #.imports) (` [(~+ =imports)])] @@ -4825,18 +4825,18 @@ (do Monad [pattern' (monad/map Monad (: (-> [Ident [Nat Type]] (Meta [Ident Nat Code])) - (function [[r-slot-name [r-idx r-type]]] + (function (_ [r-slot-name [r-idx r-type]]) (do Monad [g!slot (gensym "")] (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] (let [pattern (record$ (list/map (: (-> [Ident Nat Code] [Code Code]) - (function [[r-slot-name r-idx r-var]] + (function (_ [r-slot-name r-idx r-var]) [(tag$ r-slot-name) r-var])) pattern')) output (record$ (list/map (: (-> [Ident Nat Code] [Code Code]) - (function [[r-slot-name r-idx r-var]] + (function (_ [r-slot-name r-idx r-var]) [(tag$ r-slot-name) (if (n/= idx r-idx) value @@ -4856,16 +4856,16 @@ (do Monad [bindings (monad/map Monad (: (-> Code (Meta Code)) - (function [_] (gensym "temp"))) + (function (_ _) (gensym "temp"))) slots) #let [pairs (zip2 slots bindings) update-expr (list/fold (: (-> [Code Code] Code Code) - (function [[s b] v] + (function (_ [s b] v) (` (..set@ (~ s) (~ v) (~ b))))) value (list/reverse pairs)) [_ accesses'] (list/fold (: (-> [Code Code] [Code (List (List Code))] [Code (List (List Code))]) - (function [[new-slot 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 Code)) #Nil)] @@ -4876,14 +4876,16 @@ (^ (list selector value)) (do Monad - [g!record (gensym "record")] - (wrap (list (` (function [(~ g!record)] (..set@ (~ selector) (~ value) (~ g!record))))))) + [g!_ (gensym "_") + g!record (gensym "record")] + (wrap (list (` (function ((~ g!_) (~ g!record)) (..set@ (~ selector) (~ value) (~ g!record))))))) (^ (list selector)) (do Monad - [g!value (gensym "value") + [g!_ (gensym "_") + g!value (gensym "value") g!record (gensym "record")] - (wrap (list (` (function [(~ g!value) (~ g!record)] (..set@ (~ selector) (~ g!value) (~ g!record))))))) + (wrap (list (` (function ((~ g!_) (~ g!value) (~ g!record)) (..set@ (~ selector) (~ g!value) (~ g!record))))))) _ (fail "Wrong syntax for set@"))) @@ -4913,18 +4915,18 @@ (do Monad [pattern' (monad/map Monad (: (-> [Ident [Nat Type]] (Meta [Ident Nat Code])) - (function [[r-slot-name [r-idx r-type]]] + (function (_ [r-slot-name [r-idx r-type]]) (do Monad [g!slot (gensym "")] (return [r-slot-name r-idx g!slot])))) (zip2 tags (enumerate members)))] (let [pattern (record$ (list/map (: (-> [Ident Nat Code] [Code Code]) - (function [[r-slot-name r-idx r-var]] + (function (_ [r-slot-name r-idx r-var]) [(tag$ r-slot-name) r-var])) pattern')) output (record$ (list/map (: (-> [Ident Nat Code] [Code Code]) - (function [[r-slot-name r-idx r-var]] + (function (_ [r-slot-name r-idx r-var]) [(tag$ r-slot-name) (if (n/= idx r-idx) (` ((~ fun) (~ r-var))) @@ -4950,14 +4952,16 @@ (^ (list selector fun)) (do Monad - [g!record (gensym "record")] - (wrap (list (` (function [(~ g!record)] (..update@ (~ selector) (~ fun) (~ g!record))))))) + [g!_ (gensym "_") + g!record (gensym "record")] + (wrap (list (` (function ((~ g!_) (~ g!record)) (..update@ (~ selector) (~ fun) (~ g!record))))))) (^ (list selector)) (do Monad - [g!fun (gensym "fun") + [g!_ (gensym "_") + g!fun (gensym "fun") g!record (gensym "record")] - (wrap (list (` (function [(~ g!fun) (~ g!record)] (..update@ (~ selector) (~ g!fun) (~ g!record))))))) + (wrap (list (` (function ((~ g!_) (~ g!fun) (~ g!record)) (..update@ (~ selector) (~ g!fun) (~ g!record))))))) _ (fail "Wrong syntax for update@"))) @@ -5008,7 +5012,7 @@ data' (monad/map Monad tuple->list data)] (if (every? (n/= (list/size bindings')) (list/map list/size data')) (let [apply (: (-> RepEnv (List Code)) - (function [env] (list/map (apply-template env) templates)))] + (function (_ env) (list/map (apply-template env) templates)))] (|> data' (join-map (compose apply (make-env bindings'))) wrap)) @@ -5164,7 +5168,7 @@ (^template [ ] [group-cursor ( parts)] - (let [[group-cursor' parts-text] (list/fold (function [part [last-cursor text-accum]] + (let [[group-cursor' parts-text] (list/fold (function (_ part [last-cursor text-accum]) (let [[part-cursor part-text] (doc-example->Text last-cursor baseline part)] [part-cursor (text/compose text-accum part-text)])) [(delim-update-cursor group-cursor) ""] @@ -5192,7 +5196,7 @@ (#Doc-Comment comment) (|> comment (text/split "\n") - (list/map (function [line] ($_ text/compose "## " line "\n"))) + (list/map (function (_ line) ($_ text/compose "## " line "\n"))) text/join) (#Doc-Example example) @@ -5299,13 +5303,13 @@ expected get-expected-type] (return (list (` (("lux check" (-> (~+ (list/map type-to-code init-types)) (~ (type-to-code expected))) - (function (~ (symbol$ ["" "recur"])) [(~+ vars)] + (function ((~ (symbol$ ["" "recur"])) (~+ vars)) (~ body))) (~+ inits)))))) (do Monad [aliases (monad/map Monad (: (-> Code (Meta Code)) - (function [_] (gensym ""))) + (function (_ _) (gensym ""))) inits)] (return (list (` (let [(~+ (interleave aliases inits))] (.loop [(~+ (interleave vars aliases))] @@ -5340,10 +5344,10 @@ g!_ (gensym "_") #let [[idx tags exported? type] output slot-pairings (list/map (: (-> Ident [Text Code]) - (function [[module name]] [name (symbol$ ["" name])])) + (function (_ [module name]) [name (symbol$ ["" name])])) (list& hslot tslots)) pattern (record$ (list/map (: (-> Ident [Code Code]) - (function [[module name]] + (function (_ [module name]) (let [tag (tag$ [module name])] (case (get name slot-pairings) (#Some binding) [tag binding] @@ -5378,7 +5382,7 @@ (do Monad [=pairs (monad/map Monad (: (-> [Code Code] (Maybe [Code Code])) - (function [[slot value]] + (function (_ [slot value]) (do Monad [slot' (place-tokens label tokens slot) value' (place-tokens label tokens value)] @@ -5499,7 +5503,7 @@ (do Monad [=pairs (monad/map Monad (: (-> [Code Code] (Meta [Code Code])) - (function [[slot value]] + (function (_ [slot value]) (do Monad [=value (anti-quote value)] (wrap [slot =value])))) @@ -5564,7 +5568,7 @@ (def: (multi-level-case$ g!_ [[init-pattern levels] body]) (-> Code [Multi-Level-Case Code] (List Code)) - (let [inner-pattern-body (list/fold (function [[calculation pattern] success] + (let [inner-pattern-body (list/fold (function (_ [calculation pattern] success) (` (case (~ calculation) (~ pattern) (~ success) @@ -5702,7 +5706,7 @@ (macro: #export (^@ tokens) {#.doc (doc "Allows you to simultaneously bind and de-structure a value." (def: (hash (^@ set [Hash _])) - (list/fold (function [elem acc] (n/+ (:: Hash hash elem) acc)) + (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) +0 (to-list set))))} (case tokens @@ -5778,7 +5782,7 @@ (^ (list& [_ (#Form (list& [_ (#Symbol ["" name])] args'))] tokens')) (do Monad [args (monad/map Monad - (function [arg'] + (function (_ arg') (case arg' [_ (#Symbol ["" arg-name])] (wrap arg-name) @@ -5849,7 +5853,7 @@ g!tokens (gensym "tokens") g!compiler (gensym "compiler") g!_ (gensym "_") - #let [rep-env (list/map (function [arg] + #let [rep-env (list/map (function (_ arg) [arg (` ((~' ~) (~ (symbol$ ["" arg]))))]) args)]] (wrap (list (` (macro: (~+ (export export?)) @@ -5858,7 +5862,7 @@ (case (~ g!tokens) (^ (list (~+ (list/map (|>> [""] symbol$) args)))) (#.Right [(~ g!compiler) - (list (~+ (list/map (function [template] + (list (~+ (list/map (function (_ template) (` (` (~ (replace-syntax rep-env template))))) input-templates)))]) @@ -5884,7 +5888,7 @@ (def: #export (when test f) (All [a] (-> Bool (-> a a) (-> a a))) - (function [value] + (function (_ value) (if test (f value) value))) @@ -5895,7 +5899,7 @@ (def: target (Meta Text) - (function [compiler] + (function (_ compiler) (#Right [compiler (get@ [#info #target] compiler)]))) (def: (pick-for-target target options) @@ -5960,7 +5964,7 @@ [ann (#Record kvs)] (do Monad [=kvs (monad/map Monad - (function [[key val]] + (function (_ [key val]) (do Monad [=key (label-code key) =val (label-code val) @@ -5981,7 +5985,7 @@ [=raw (label-code raw) #let [[labels labelled] =raw]] (wrap (list (` (with-expansions [(~+ (|> labels - (list/map (function [[label expansion]] (list label expansion))) + (list/map (function (_ [label expansion]) (list label expansion))) list/join))] (~ labelled)))))) @@ -6022,7 +6026,7 @@ [_ (#Record fields)] (do Monad [=fields (monad/map Monad - (function [[key value]] + (function (_ [key value]) (do Monad [=key (untemplate-pattern key) =value (untemplate-pattern value)] diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index b0f1285fa..51c020812 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -34,7 +34,7 @@ (def: #export any {#.doc "Just returns the next input without applying any logic."} (CLI Text) - (function [inputs] + (function (_ inputs) (case inputs (#.Cons arg inputs') (#E.Success [inputs' arg]) @@ -45,7 +45,7 @@ (def: #export (parse parser) {#.doc "Parses the next input with a parsing function."} (All [a] (-> (-> Text (E.Error a)) (CLI a))) - (function [inputs] + (function (_ inputs) (do E.Monad [[remaining raw] (any inputs) output (parser raw)] @@ -54,7 +54,7 @@ (def: #export (this reference) {#.doc "Checks that a token is in the inputs."} (-> Text (CLI Unit)) - (function [inputs] + (function (_ inputs) (do E.Monad [[remaining raw] (any inputs)] (if (text/= reference raw) @@ -64,7 +64,7 @@ (def: #export (somewhere cli) {#.doc "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."} (All [a] (-> (CLI a) (CLI a))) - (function [inputs] + (function (_ inputs) (loop [immediate inputs] (case (p.run immediate cli) (#E.Success [remaining output]) @@ -84,7 +84,7 @@ (def: #export end {#.doc "Ensures there are no more inputs."} (CLI Unit) - (function [inputs] + (function (_ inputs) (case inputs #.Nil (#E.Success [inputs []]) _ (#E.Error (format "Unknown parameters: " (text.join-with " " inputs)))))) @@ -131,7 +131,7 @@ (case ((: (~! (..CLI (io.IO Unit))) ((~! do) (~! p.Monad) [(~+ (|> args - (list/map (function [[binding parser]] + (list/map (function (_ [binding parser]) (list binding parser))) list/join)) (~ g!_) ..end] diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index c5bcc8a0d..ed62332a8 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -136,7 +136,7 @@ {#.doc "Kills the actor by sending a message that will kill it upon processing, but allows the actor to handle previous messages."} (All [s] (-> (Actor s) (IO Bool))) - (send (function [state self] + (send (function (_ state self) (task.throw Poisoned [])) actor)) @@ -219,7 +219,7 @@ output (message state self) #let [_ (log! "AFTER")]] (wrap output)))))} - (with-gensyms [g!init] + (with-gensyms [g!_ g!init] (do @ [module macro.current-module-name #let [g!type (code.local-symbol (state-name _name)) @@ -242,9 +242,10 @@ (` (~! ..default-handle)) (#.Some [[messageN stateN selfN] bodyC]) - (` (function [(~ (code.local-symbol messageN)) + (` (function ((~ g!_) + (~ (code.local-symbol messageN)) (~ (code.local-symbol stateN)) - (~ (code.local-symbol selfN))] + (~ (code.local-symbol selfN))) (do task.Monad [] (~ bodyC)))))) @@ -253,8 +254,9 @@ (` (~! ..default-end)) (#.Some [[causeN stateN] bodyC]) - (` (function [(~ (code.local-symbol causeN)) - (~ (code.local-symbol stateN))] + (` (function ((~ g!_) + (~ (code.local-symbol causeN)) + (~ (code.local-symbol stateN))) (do promise.Monad [] (~ bodyC))))))})) @@ -305,7 +307,7 @@ (push [value a] state self (List a)) (let [state' (#.Cons value state)] (task.return [state' state']))))} - (with-gensyms [g!return g!error g!task g!sent?] + (with-gensyms [g!_ g!return g!error g!task g!sent?] (do @ [current-module macro.current-module-name actor-name (resolve-actor actor-name) @@ -331,7 +333,7 @@ (: (List Code)) (list.zip2 g!all-vars) (: (List [Code Code]))) - g!outputT (list/fold (function [[g!var g!ref] outputT] + g!outputT (list/fold (function (_ [g!var g!ref] outputT) (code.replace g!var g!ref outputT)) (get@ #output signature) ref-replacements)]] @@ -342,7 +344,7 @@ (All [(~+ g!all-vars)] (-> (~+ g!inputsT) (~ actorC) (Task (~ (get@ #output signature))))) (let [(~ g!task) (task.task (~ g!outputT))] (io.run (do io.Monad - [(~ g!sent?) (..send (function [(~ g!state) (~ g!self)] + [(~ g!sent?) (..send (function ((~ g!_) (~ g!state) (~ g!self)) (do promise.Monad [(~ g!return) (: (Task [((~ g!type) (~+ g!actor-refs)) (~ g!outputT)]) diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index 98de28d39..a8c017a90 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -30,14 +30,14 @@ (All [a] (-> (Channel a) a (IO Top))) (do io.Monad [listeners (atom.read channel)] - (monad.map @ (function [listener] (listener value)) listeners))) + (monad.map @ (function (_ listener) (listener value)) listeners))) ) ## [Values] (def: #export (filter predicate input) (All [a] (-> (-> a Bool) (Channel a) (Channel a))) (let [output (channel [])] - (exec (io.run (listen (function [value] + (exec (io.run (listen (function (_ value) (if (predicate value) (publish output value) (io []))) @@ -113,7 +113,7 @@ (def: (apply ff fa) (let [output (channel [])] - (exec (io.run (listen (function [f] + (exec (io.run (listen (function (_ f) (listen (|>> f (publish output)) fa)) ff)) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index e1084d9a9..8b7849c93 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -43,7 +43,7 @@ succeeded? (atom.compare-and-swap old new promise)] (if succeeded? (do @ - [_ (monad.map @ (function [f] (f value)) + [_ (monad.map @ (function (_ f) (f value)) _observers)] (wrap true)) (resolve value (@abstraction promise))))))) @@ -75,7 +75,7 @@ (struct: #export _ (Functor Promise) (def: (map f fa) (let [fb (promise #.None)] - (exec (await (function [a] (resolve (f a) fb)) + (exec (await (function (_ a) (resolve (f a) fb)) fa) fb)))) @@ -87,8 +87,8 @@ (def: (apply ff fa) (let [fb (promise #.None)] - (exec (await (function [f] - (io (await (function [a] (resolve (f a) fb)) + (exec (await (function (_ f) + (io (await (function (_ a) (resolve (f a) fb)) fa))) ff) fb)) @@ -99,8 +99,8 @@ (def: (join mma) (let [ma (promise #.None)] - (exec (await (function [ma'] - (io (await (function [a'] (resolve a' ma)) + (exec (await (function (_ ma') + (io (await (function (_ a') (resolve a' ma)) ma'))) mma) ma)))) @@ -119,7 +119,7 @@ (let [a|b (promise #.None)] (with-expansions [ (do-template [ ] - [(await (function [value] (resolve ( value) a|b)) + [(await (function (_ value) (resolve ( value) a|b)) )] [left #.Left] @@ -133,7 +133,7 @@ (All [a] (-> (Promise a) (Promise a) (Promise a))) (let [left||right (promise #.None)] (`` (exec (~~ (do-template [] - [(await (function [value] (resolve value left||right)) + [(await (function (_ value) (resolve value left||right)) )] [left] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index a62a35677..cdafbc686 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -40,7 +40,7 @@ succeeded? (atom.compare-and-swap old [new-value _observers] var)] (if succeeded? (do @ - [_ (monad.map @ (function [f] (f new-value)) _observers)] + [_ (monad.map @ (function (_ f) (f new-value)) _observers)] (wrap [])) (write! new-value (@abstraction var))))) @@ -54,7 +54,7 @@ (do io.Monad [#let [channel (helper|follow target) target (@representation target)] - _ (atom.update (function [[value observers]] + _ (atom.update (function (_ [value observers]) [value (#.Cons (frp.publish channel) observers)]) target)] (wrap channel))) @@ -75,17 +75,17 @@ (def: (find-var-value var tx) (All [a] (-> (Var a) Tx (Maybe a))) (|> tx - (list.find (function [[_var _original _current]] + (list.find (function (_ [_var _original _current]) (is? (:! (Var Unit) var) (:! (Var Unit) _var)))) - (:: maybe.Monad map (function [[_var _original _current]] + (:: maybe.Monad map (function (_ [_var _original _current]) _current)) (:!!) )) (def: #export (read var) (All [a] (-> (Var a) (STM a))) - (function [tx] + (function (_ tx) (case (find-var-value var tx) (#.Some value) [tx value] @@ -117,7 +117,7 @@ (def: #export (write value var) {#.doc "Writes value to var."} (All [a] (-> a (Var a) (STM Unit))) - (function [tx] + (function (_ tx) (case (find-var-value var tx) (#.Some _) [(update-tx-value var value tx) @@ -129,7 +129,7 @@ (struct: #export _ (Functor STM) (def: (map f fa) - (function [tx] + (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)])))) @@ -137,10 +137,10 @@ (def: functor Functor) (def: (wrap a) - (function [tx] [tx a])) + (function (_ tx) [tx a])) (def: (apply ff fa) - (function [tx] + (function (_ tx) (let [[tx' f] (ff tx) [tx'' a] (fa tx')] [tx'' (f a)])))) @@ -149,7 +149,7 @@ (def: applicative Applicative) (def: (join mma) - (function [tx] + (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx'))))) @@ -164,7 +164,7 @@ (def: (can-commit? tx) (-> Tx Bool) - (list.every? (function [[_var _original _current]] + (list.every? (function (_ [_var _original _current]) (is? _original (read!! _var))) tx)) @@ -219,7 +219,7 @@ [was-first? (atom.compare-and-swap flag true commit-processor-flag)] (if was-first? (exec (|> (io.run (atom.read pending-commits)) - (promise.await (function recur [[head tail]] + (promise.await (function (recur [head tail]) (io (exec (process-commit (:! [(STM Unit) (Promise Unit)] head)) (promise.await recur tail)))))) (wrap [])) diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux index 603dfc808..edb72ca6f 100644 --- a/stdlib/source/lux/concurrency/task.lux +++ b/stdlib/source/lux/concurrency/task.lux @@ -33,7 +33,7 @@ (struct: #export _ (F.Functor Task) (def: (map f fa) (:: P.Functor map - (function [fa'] + (function (_ fa') (case fa' (#E.Error error) (#E.Error error) diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index 69e891219..471c6bd2b 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -27,24 +27,25 @@ (macro: #export (be tokens state) {#.doc (doc "A co-monadic parallel to the \"do\" macro." - (let [square (function [n] (i/* n n))] + (let [square (function (_ n) (i/* n n))] (be CoMonad [inputs (iterate i/inc 2)] (square (head inputs)))))} (case tokens (#.Cons comonad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) (if (|> bindings list.size (n/% +2) (n/= +0)) - (let [g!map (: Code [_cursor (#.Symbol ["" " map "])]) + (let [g!_ (: Code [_cursor (#.Symbol ["" " _ "])]) + g!map (: Code [_cursor (#.Symbol ["" " map "])]) g!split (: Code [_cursor (#.Symbol ["" " split "])]) body' (list/fold (: (-> [Code Code] Code Code) - (function [binding body'] + (function (_ binding body') (let [[var value] binding] (case var [_ (#.Tag ["" "let"])] (` (let (~ value) (~ body'))) _ - (` (|> (~ value) (~ g!split) ((~ g!map) (function [(~ var)] (~ body'))))) + (` (|> (~ value) (~ g!split) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))))) )))) body (list.reverse (list.as-pairs bindings)))] diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index bfc51550b..ceda943e4 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -43,7 +43,7 @@ (def: (stack-fold tops bottom) (-> (List Code) Code Code) - (list/fold (function [top bottom] + (list/fold (function (_ top bottom) (` [(~ bottom) (~ top)])) bottom tops)) @@ -63,8 +63,8 @@ (syntax: #export (=> [aliases aliases^] [inputs stack^] [outputs stack^]) - (let [de-alias (function [aliased] - (list/fold (function [[from to] pre] + (let [de-alias (function (_ aliased) + (list/fold (function (_ [from to] pre) (code.replace (code.local-symbol from) to pre)) aliased aliases))] @@ -90,7 +90,7 @@ (def: end! (All [a] (-> [Unit a] a)) - (function [[_ top]] + (function (_ [_ top]) top)) (def: (prepare command) @@ -122,14 +122,14 @@ (|>> (~+ (list/map prepare commands)))))))) (syntax: #export (apply [arity (|> s.nat (p.filter (.n/> +0)))]) - (with-gensyms [g!func g!stack g!output] + (with-gensyms [g! g!func g!stack g!output] (monad.do @ [g!inputs (|> (macro.gensym "input") (list.repeat arity) (monad.seq @))] (wrap (list (` (: (All [(~+ g!inputs) (~ g!output)] (-> (-> (~+ g!inputs) (~ g!output)) (=> [(~+ g!inputs)] [(~ g!output)]))) - (function [(~ g!func)] - (function [(~ (stack-fold g!inputs g!stack))] + (function ((~ g!) (~ g!func)) + (function ((~ g!) (~ (stack-fold g!inputs g!stack))) [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) ## [Primitives] @@ -144,58 +144,58 @@ (def: #export (push x) (All [a] (-> a (=> [] [a]))) - (function [stack] + (function (_ stack) [stack x])) (def: #export drop (All [t] (=> [t] [])) - (function [[stack top]] + (function (_ [stack top]) stack)) (def: #export nip (All [_ a] (=> [_ a] [a])) - (function [[[stack _] top]] + (function (_ [[stack _] top]) [stack top])) (def: #export dup (All [a] (=> [a] [a a])) - (function [[stack top]] + (function (_ [stack top]) [[stack top] top])) (def: #export swap (All [a b] (=> [a b] [b a])) - (function [[[stack l] r]] + (function (_ [[stack l] r]) [[stack r] l])) (def: #export rotL (All [a b c] (=> [a b c] [b c a])) - (function [[[[stack a] b] c]] + (function (_ [[[stack a] b] c]) [[[stack b] c] a])) (def: #export rotR (All [a b c] (=> [a b c] [c a b])) - (function [[[[stack a] b] c]] + (function (_ [[[stack a] b] c]) [[[stack c] a] b])) (def: #export && (All [a b] (=> [a b] [(& a b)])) - (function [[[stack l] r]] + (function (_ [[stack l] r]) [stack [l r]])) (def: #export ||L (All [a b] (=> [a] [(| a b)])) - (function [[stack l]] + (function (_ [stack l]) [stack (+0 l)])) (def: #export ||R (All [a b] (=> [b] [(| a b)])) - (function [[stack r]] + (function (_ [stack r]) [stack (+1 r)])) (do-template [ ] [(def: #export (=> [ ] []) - (function [[[stack subject] param]] + (function (_ [[stack subject] param]) [stack ( param subject)]))] [Nat Nat n/+ .n/+] @@ -248,7 +248,7 @@ (=> {then (=> __a __b) else (=> __a __b)} __a [Bool then else] __b)) - (function [[[[stack test] then] else]] + (function (_ [[[stack test] then] else]) (.if test (then stack) (else stack)))) @@ -257,14 +257,14 @@ (All [__a __b] (=> {quote (=> __a __b)} __a [quote] __b)) - (function [[stack block]] + (function (_ [stack block]) (block stack))) (def: #export loop (All [___] (=> {test (=> ___ ___ [Bool])} ___ [test] ___)) - (function loop [[stack pred]] + (function (loop [stack pred]) (let [[stack' verdict] (pred stack)] (.if verdict (loop [stack' pred]) @@ -274,14 +274,14 @@ (All [___ a] (=> ___ [a (=> ___ ___)] ___ [a])) - (function [[[stack a] quote]] + (function (_ [[stack a] quote]) [(quote stack) a])) (def: #export dip2 (All [___ a b] (=> ___ [a b (=> ___ ___)] ___ [a b])) - (function [[[[stack a] b] quote]] + (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) (def: #export do @@ -290,7 +290,7 @@ body (=> __b __a)} __b [pred body] __a [pred body])) - (function [[[stack pred] body]] + (function (_ [[stack pred] body]) [[(body stack) pred] body])) (def: #export while @@ -299,7 +299,7 @@ body (=> __b __a)} __a [pred body] __b)) - (function while [[[stack pred] body]] + (function (while [[stack pred] body]) (let [[stack' verdict] (pred stack)] (.if verdict (while [[(body stack') pred] body]) @@ -309,14 +309,14 @@ (All [__a __b __c] (=> [(=> __a __b) (=> __b __c)] [(=> __a __c)])) - (function [[[stack f] g]] + (function (_ [[stack f] g]) [stack (|>> f g)])) (def: #export curry (All [__a __b a] (=> __a [a (=> __a [a] __b)] __a [(=> __a __b)])) - (function [[[stack arg] quote]] + (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) ## [Words] diff --git a/stdlib/source/lux/control/cont.lux b/stdlib/source/lux/control/cont.lux index c3be37b73..35f549ee7 100644 --- a/stdlib/source/lux/control/cont.lux +++ b/stdlib/source/lux/control/cont.lux @@ -24,25 +24,25 @@ (struct: #export Functor (All [o] (Functor (All [i] (Cont i o)))) (def: (map f fv) - (function [k] (fv (compose k f))))) + (function (_ k) (fv (compose k f))))) (struct: #export Applicative (All [o] (Applicative (All [i] (Cont i o)))) (def: functor Functor) (def: (wrap value) - (function [k] (k value))) + (function (_ k) (k value))) (def: (apply ff fv) - (function [k] + (function (_ k) (|> (k (f v)) - (function [v]) fv - (function [f]) ff)))) + (function (_ v)) fv + (function (_ f)) ff)))) (struct: #export Monad (All [o] (Monad (All [i] (Cont i o)))) (def: applicative Applicative) (def: (join ffa) - (function [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))) - (function [k] - (f (function [a] (function [_] (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-function some-input)))} - (with-gensyms [g!k] - (wrap (list (` (.function [(~ g!k)] ((~ g!k) (~ expr)))))))) + (with-gensyms [g!_ g!k] + (wrap (list (` (.function ((~ g!_) (~ 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 (function [k] + (call/cc (function (_ k) (do Monad - [#let [nexus (function 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))) - (function [k] + (function (_ k) (k (run scope)))) (def: #export (shift f) @@ -84,6 +84,6 @@ (-> (-> (-> a (Cont a a)) (Cont a a)) (Cont a a))) - (function [oc] - (f (function [a] (function [ic] (ic (oc a)))) + (function (_ oc) + (f (function (_ a) (function (_ ic) (ic (oc a)))) id))) diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 8a959b6c8..2b5c40713 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -95,7 +95,7 @@ (..Exception [(~+ (list/map (get@ #cs.input-type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) - #..constructor (function (~ g!self) [[(~+ (list/map (get@ #cs.input-binding) inputs))]] + #..constructor (function ((~ g!self) [(~+ (list/map (get@ #cs.input-binding) inputs))]) ((~! text/compose) (~ g!descriptor) (~ (maybe.default (' "") body))))}))))) ))) diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux index fd940ea83..2e4045f3a 100644 --- a/stdlib/source/lux/control/monad.lux +++ b/stdlib/source/lux/control/monad.lux @@ -28,7 +28,7 @@ (def: (reverse xs) (All [a] (-> (List a) (List a))) - (list/fold (function [head tail] (#.Cons head tail)) + (list/fold (function (_ head tail) (#.Cons head tail)) #.Nil xs)) @@ -61,18 +61,19 @@ (case tokens (#.Cons monad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) (if (|> bindings list/size (n/% +2) (n/= +0)) - (let [g!map (: Code [_cursor (#.Symbol ["" " map "])]) + (let [g!_ (: Code [_cursor (#.Symbol ["" " _ "])]) + g!map (: Code [_cursor (#.Symbol ["" " map "])]) g!join (: Code [_cursor (#.Symbol ["" " join "])]) g!apply (: Code [_cursor (#.Symbol ["" " apply "])]) body' (list/fold (: (-> [Code Code] Code Code) - (function [binding body'] + (function (_ binding body') (let [[var value] binding] (case var [_ (#.Tag ["" "let"])] (` (let (~ value) (~ body'))) _ - (` (|> (~ value) ((~ g!map) (function [(~ var)] (~ body'))) (~ g!join))) + (` (|> (~ value) ((~ g!map) (function ((~ g!_) (~ var)) (~ body'))) (~ g!join))) )))) body (reverse (as-pairs bindings)))] @@ -139,7 +140,7 @@ {#.doc "Lift a normal function into the space of monads."} (All [M a b] (-> (Monad M) (-> a b) (-> (M a) (M b)))) - (function [ma] + (function (_ ma) (do Monad [a ma] (wrap (f a))))) @@ -179,7 +180,7 @@ [(#Effect ff) _] (#Effect (:: dsl map - (function [f] (apply f ea)) + (function (_ f) (apply f ea)) ff)) ))) diff --git a/stdlib/source/lux/control/monad/indexed.lux b/stdlib/source/lux/control/monad/indexed.lux index dcc3b2067..1e03a4e7d 100644 --- a/stdlib/source/lux/control/monad/indexed.lux +++ b/stdlib/source/lux/control/monad/indexed.lux @@ -40,11 +40,11 @@ (syntax: #export (do monad [context (s.tuple (p.some context))] expression) - (macro.with-gensyms [g!bind] + (macro.with-gensyms [g!_ g!bind] (wrap (list (` (let [(~' @) (~ monad) {#..wrap (~' wrap) #..bind (~ g!bind)} (~' @)] - (~ (list/fold (function [context next] + (~ (list/fold (function (_ context next) (case context (#Let bindings) (` (let [(~+ (|> bindings @@ -54,7 +54,7 @@ (#Bind [binding value]) (` ((~ g!bind) - (.function [(~ binding)] + (.function ((~ g!_) (~ binding)) (~ next)) (~ value))))) expression diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux index 6ac2349ea..c33c17d72 100644 --- a/stdlib/source/lux/control/parser.lux +++ b/stdlib/source/lux/control/parser.lux @@ -15,7 +15,7 @@ ## [Structures] (struct: #export Functor (All [s] (Functor (Parser s))) (def: (map f ma) - (function [input] + (function (_ input) (case (ma input) (#e.Error msg) (#e.Error msg) @@ -27,11 +27,11 @@ (def: functor Functor) (def: (wrap x) - (function [input] + (function (_ input) (#e.Success [input x]))) (def: (apply ff fa) - (function [input] + (function (_ input) (case (ff input) (#e.Success [input' f]) (case (fa input') @@ -48,7 +48,7 @@ (def: applicative Applicative) (def: (join mma) - (function [input] + (function (_ input) (case (mma input) (#e.Error msg) (#e.Error msg) @@ -60,7 +60,7 @@ (def: #export (assert message test) {#.doc "Fails with the given message if the test is false."} (All [s] (-> Text Bool (Parser s Unit))) - (function [input] + (function (_ input) (if test (#e.Success [input []]) (#e.Error message)))) @@ -69,7 +69,7 @@ {#.doc "Optionality combinator."} (All [s a] (-> (Parser s a) (Parser s (Maybe a)))) - (function [input] + (function (_ input) (case (p input) (#e.Error _) (#e.Success [input #.None]) (#e.Success [input' x]) (#e.Success [input' (#.Some x)])))) @@ -83,7 +83,7 @@ {#.doc "0-or-more combinator."} (All [s a] (-> (Parser s a) (Parser s (List a)))) - (function [input] + (function (_ input) (case (p input) (#e.Error _) (#e.Success [input (list)]) (#e.Success [input' x]) (run input' @@ -114,7 +114,7 @@ {#.doc "Heterogeneous alternative combinator."} (All [s a b] (-> (Parser s a) (Parser s b) (Parser s (| a b)))) - (function [tokens] + (function (_ tokens) (case (p1 tokens) (#e.Success [tokens' x1]) (#e.Success [tokens' (+0 x1)]) (#e.Error _) (run tokens @@ -127,7 +127,7 @@ {#.doc "Homogeneous alternative combinator."} (All [s a] (-> (Parser s a) (Parser s a) (Parser s a))) - (function [tokens] + (function (_ tokens) (case (pl tokens) (#e.Error _) (pr tokens) output output @@ -155,7 +155,7 @@ {#.doc "Parse at most N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (if (n/> +0 n) - (function [input] + (function (_ input) (case (p input) (#e.Error msg) (#e.Success [input (list)]) @@ -193,7 +193,7 @@ (def: #export (not p) (All [s a] (-> (Parser s a) (Parser s Unit))) - (function [input] + (function (_ input) (case (p input) (#e.Error msg) (#e.Success [input []]) @@ -203,13 +203,13 @@ (def: #export (fail message) (All [s a] (-> Text (Parser s a))) - (function [input] + (function (_ input) (#e.Error message))) (def: #export (default value parser) {#.doc "If the given parser fails, returns the default value."} (All [s a] (-> a (Parser s a) (Parser s a))) - (function [input] + (function (_ input) (case (parser input) (#e.Error error) (#e.Success [input value]) @@ -219,13 +219,13 @@ (def: #export remaining (All [s] (Parser s s)) - (function [inputs] + (function (_ inputs) (#e.Success [inputs inputs]))) (def: #export (rec parser) {#.doc "Combinator for recursive parser."} (All [s a] (-> (-> (Parser s a) (Parser s a)) (Parser s a))) - (function [inputs] + (function (_ inputs) (run inputs (parser (rec parser))))) (def: #export (after param subject) @@ -250,7 +250,7 @@ (def: #export (codec Codec parser) (All [s a z] (-> (codec.Codec a z) (Parser s a) (Parser s z))) - (function [input] + (function (_ input) (case (parser input) (#e.Error error) (#e.Error error) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index a2d6ba5fc..54b04dcdc 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -36,7 +36,7 @@ (def: _reverse_ (Syntax Unit) - (function [tokens] + (function (_ tokens) (#e.Success [(list.reverse tokens) []]))) (syntax: #export (cond> [_ _reverse_] @@ -114,7 +114,7 @@ "Will become: [50 2 \"5\"]")} (with-gensyms [g!temp] (wrap (list (` (let [(~ g!temp) (~ prev)] - [(~+ (list/map (function [body] (` (|> (~ g!temp) (~+ body)))) + [(~+ (list/map (function (_ body) (` (|> (~ g!temp) (~+ body)))) paths))])))))) (syntax: #export (case> [branches (p.many (p.seq s.any s.any))] prev) @@ -133,5 +133,5 @@ 9 "nine" _ "???")))} (wrap (list (` (case (~ prev) - (~+ (list/join (list/map (function [[pattern body]] (list pattern body)) + (~+ (list/join (list/map (function (_ [pattern body]) (list pattern body)) branches)))))))) diff --git a/stdlib/source/lux/control/predicate.lux b/stdlib/source/lux/control/predicate.lux index f4ca17d70..641a90b28 100644 --- a/stdlib/source/lux/control/predicate.lux +++ b/stdlib/source/lux/control/predicate.lux @@ -8,7 +8,7 @@ (do-template [ ] [(def: #export ( left right) (All [a] (-> (Pred a) (Pred a) (Pred a))) - (function [value] + (function (_ value) ( (left value) (right value))))] @@ -22,7 +22,7 @@ (def: #export (difference sub base) (All [a] (-> (Pred a) (Pred a) (Pred a))) - (function [value] + (function (_ value) (and (base value) (not (sub value))))) diff --git a/stdlib/source/lux/control/reader.lux b/stdlib/source/lux/control/reader.lux index 74c96c5b2..ed974ee46 100644 --- a/stdlib/source/lux/control/reader.lux +++ b/stdlib/source/lux/control/reader.lux @@ -12,31 +12,31 @@ ## [Structures] (struct: #export Functor (All [r] (F.Functor (Reader r))) (def: (map f fa) - (function [env] + (function (_ env) (f (fa env))))) (struct: #export Applicative (All [r] (A.Applicative (Reader r))) (def: functor Functor) (def: (wrap x) - (function [env] x)) + (function (_ env) x)) (def: (apply ff fa) - (function [env] + (function (_ env) ((ff env) (fa env))))) (struct: #export Monad (All [r] (Monad (Reader r))) (def: applicative Applicative) (def: (join mma) - (function [env] + (function (_ env) (mma env env)))) ## [Values] (def: #export ask {#.doc "Get the environment."} (All [r] (Reader r r)) - (function [env] env)) + (function (_ env) env)) (def: #export (local change 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 (A.compose Applicative (get@ #monad.applicative Monad))) (def: (join eMeMa) - (function [env] + (function (_ env) (do Monad [eMa (run env eMeMa)] (run env eMa))))) diff --git a/stdlib/source/lux/control/region.lux b/stdlib/source/lux/control/region.lux index 2c8f6b795..83afbbdc6 100644 --- a/stdlib/source/lux/control/region.lux +++ b/stdlib/source/lux/control/region.lux @@ -50,15 +50,15 @@ (m (Error a)))) (do Monad [[cleaners output] (computation [[] (list)]) - results (monad.map @ (function [cleaner] (cleaner [])) + results (monad.map @ (function (_ cleaner) (cleaner [])) cleaners)] (wrap (list/fold combine-outcomes output results)))) (def: #export (acquire Monad cleaner value) (All [m a] (-> (Monad m) (-> a (m (Error Unit))) a (All [r] (Region r m a)))) - (function [[region cleaners]] - (:: Monad wrap [(#.Cons (function [region] (cleaner value)) + (function (_ [region cleaners]) + (:: Monad wrap [(#.Cons (function (_ region) (cleaner value)) cleaners) (#e.Success value)]))) @@ -68,10 +68,10 @@ (All [r] (Functor (Region r m))))) (def: (map f) - (function [fa] - (function [region+cleaners] + (function (_ fa) + (function (_ region+cleaners) (:: Functor map - (function [[cleaners' temp]] + (function (_ [cleaners' temp]) [cleaners' (case temp (#e.Success value) (#e.Success (f value)) @@ -90,11 +90,11 @@ Monad))) (def: (wrap value) - (function [[region cleaners]] + (function (_ [region cleaners]) (:: Monad wrap [cleaners (#e.Success value)]))) (def: (apply ff fa) - (function [[region cleaners]] + (function (_ [region cleaners]) (do Monad [[cleaners ef] (ff [region cleaners]) [cleaners ea] (fa [region cleaners])] @@ -114,7 +114,7 @@ (def: applicative (Applicative Monad)) (def: (join ffa) - (function [[region cleaners]] + (function (_ [region cleaners]) (do Monad [[cleaners efa] (ffa [region cleaners])] (case efa @@ -128,21 +128,21 @@ (All [m a] (-> (Monad m) Text (All [r] (Region r m a)))) - (function [[region cleaners]] + (function (_ [region cleaners]) (:: Monad wrap [cleaners (#e.Error error)]))) (def: #export (throw Monad exception message) (All [m e a] (-> (Monad m) (Exception e) e (All [r] (Region r m a)))) - (function [[region cleaners]] + (function (_ [region cleaners]) (:: Monad wrap [cleaners (ex.throw exception message)]))) (def: #export (lift Monad operation) (All [m a] (-> (Monad m) (m a) (All [r] (Region r m a)))) - (function [[region cleaners]] + (function (_ [region cleaners]) (do Monad [output operation] (wrap [cleaners (#e.Success output)])))) diff --git a/stdlib/source/lux/control/state.lux b/stdlib/source/lux/control/state.lux index 2a6ab5fb6..cf65ae6a7 100644 --- a/stdlib/source/lux/control/state.lux +++ b/stdlib/source/lux/control/state.lux @@ -12,7 +12,7 @@ ## [Structures] (struct: #export Functor (All [s] (F.Functor (State s))) (def: (map f ma) - (function [state] + (function (_ state) (let [[state' a] (ma state)] [state' (f a)])))) @@ -20,11 +20,11 @@ (def: functor Functor) (def: (wrap a) - (function [state] + (function (_ state) [state a])) (def: (apply ff fa) - (function [state] + (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)])))) @@ -33,7 +33,7 @@ (def: applicative Applicative) (def: (join mma) - (function [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)) - (function [state] + (function (_ state) [state state])) (def: #export (put new-state) {#.doc "Set the new state."} (All [s] (-> s (State s Unit))) - (function [state] + (function (_ state) [new-state []])) (def: #export (update change) {#.doc "Compute the new state."} (All [s] (-> (-> s s) (State s Unit))) - (function [state] + (function (_ state) [(change state) []])) (def: #export (use user) {#.doc "Run function on current state."} (All [s a] (-> (-> s a) (State s a))) - (function [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))) - (function [state] + (function (_ state) (let [[state' output] (action (change state))] [state output]))) @@ -77,8 +77,8 @@ (struct: (Functor Functor) (All [M s] (-> (F.Functor M) (F.Functor (All [a] (-> s (M [s a])))))) (def: (map f sfa) - (function [state] - (:: Functor map (function [[s a]] [s (f a)]) + (function (_ state) + (:: Functor map (function (_ [s a]) [s (f a)]) (sfa state))))) (struct: (Applicative Monad) @@ -86,11 +86,11 @@ (def: functor (Functor (:: Monad functor))) (def: (wrap a) - (function [state] + (function (_ state) (:: Monad wrap [state a]))) (def: (apply sFf sFa) - (function [state] + (function (_ state) (do Monad [[state f] (sFf state) [state a] (sFa state)] @@ -110,7 +110,7 @@ (All [M s] (-> (Monad M) (Monad (State' M s)))) (def: applicative (Applicative Monad)) (def: (join sMsMa) - (function [state] + (function (_ state) (do Monad [[state' sMa] (sMsMa state)] (sMa state'))))) @@ -118,7 +118,7 @@ (def: #export (lift Monad ma) {#.doc "Lift monadic values to the State' wrapper."} (All [M s a] (-> (Monad M) (M a) (State' M s a))) - (function [state] + (function (_ state) (do Monad [a ma] (wrap [state a])))) diff --git a/stdlib/source/lux/control/thread.lux b/stdlib/source/lux/control/thread.lux index daee09900..84bc33501 100644 --- a/stdlib/source/lux/control/thread.lux +++ b/stdlib/source/lux/control/thread.lux @@ -14,17 +14,17 @@ (def: #export (box init) (All [a] (-> a (All [!] (Thread ! (Box ! a))))) - (function [!] + (function (_ !) ("lux box new" init))) (def: #export (read box) (All [! a] (-> (Box ! a) (Thread ! a))) - (function [!] + (function (_ !) ("lux box read" box))) (def: #export (write value box) (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Unit))))) - (function [!] + (function (_ !) ("lux box write" value box))) (def: #export (run thread) @@ -37,8 +37,8 @@ (All [!] (Functor (Thread !))) (def: (map f) - (function [fa] - (function [!] + (function (_ fa) + (function (_ !) (f (fa !)))))) (struct: #export Applicative @@ -47,11 +47,11 @@ (def: functor Functor) (def: (wrap value) - (function [!] + (function (_ !) value)) (def: (apply ff fa) - (function [!] + (function (_ !) ((ff !) (fa !))))) (struct: #export Monad @@ -60,7 +60,7 @@ (def: applicative Applicative) (def: (join ffa) - (function [!] + (function (_ !) ((ffa !) !)))) (def: #export (update f box) @@ -74,5 +74,5 @@ (All [a] (-> (All [!] (Thread ! a)) (IO a))) - (function [void] + (function (_ void) (thread void))) diff --git a/stdlib/source/lux/control/writer.lux b/stdlib/source/lux/control/writer.lux index 29cec52e1..7f8299100 100644 --- a/stdlib/source/lux/control/writer.lux +++ b/stdlib/source/lux/control/writer.lux @@ -46,14 +46,16 @@ (def: applicative (A.compose (get@ #monad.applicative Monad) (Applicative Monoid))) (def: (join MlMla) (do Monad - [[l1 Mla] (: (($ +1) (Writer ($ +0) (($ +1) (Writer ($ +0) ($ +2))))) + [## TODO: Remove once new-luxc is the standard compiler. + [l1 Mla] (: (($ +1) (Writer ($ +0) (($ +1) (Writer ($ +0) ($ +2))))) MlMla) + ## [l1 Mla] MlMla [l2 a] Mla] (wrap [(:: Monoid compose l1 l2) a])))) (def: #export (lift Monoid Monad) (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) - (function [ma] + (function (_ ma) (do Monad [a ma] (wrap [(:: Monoid identity) a])))) diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux index 00f4173e0..855c35d8e 100644 --- a/stdlib/source/lux/data/coll/array.lux +++ b/stdlib/source/lux/data/coll/array.lux @@ -37,7 +37,7 @@ (Array a))) (if (n/= +0 length) dest-array - (list/fold (function [offset target] + (list/fold (function (_ offset target) (case (read (n/+ offset src-start) src-array) #.None target @@ -50,7 +50,7 @@ (def: #export (occupied array) {#.doc "Finds out how many cells in an array are occupied."} (All [a] (-> (Array a) Nat)) - (list/fold (function [idx count] + (list/fold (function (_ idx count) (case (read idx array) #.None count @@ -68,7 +68,7 @@ (def: #export (filter p xs) (All [a] (-> (-> a Bool) (Array a) (Array a))) - (list/fold (function [idx xs'] + (list/fold (function (_ idx xs') (case (read idx xs) #.None xs' @@ -116,7 +116,7 @@ (def: #export (clone xs) (All [a] (-> (Array a) (Array a))) (let [arr-size (size xs)] - (list/fold (function [idx ys] + (list/fold (function (_ idx ys) (case (read idx xs) #.None ys @@ -128,7 +128,7 @@ (def: #export (from-list xs) (All [a] (-> (List a) (Array a))) - (product.right (list/fold (function [x [idx arr]] + (product.right (list/fold (function (_ x [idx arr]) [(n/inc idx) (write idx x arr)]) [+0 (new (list.size xs))] xs))) @@ -155,7 +155,7 @@ (let [sxs (size xs) sxy (size ys)] (and (n/= sxy sxs) - (list/fold (function [idx prev] + (list/fold (function (_ idx prev) (and prev (case [(read idx xs) (read idx ys)] [#.None #.None] @@ -186,7 +186,7 @@ (let [arr-size (size ma)] (if (n/= +0 arr-size) (new arr-size) - (list/fold (function [idx mb] + (list/fold (function (_ idx mb) (case (read idx ma) #.None mb diff --git a/stdlib/source/lux/data/coll/bits.lux b/stdlib/source/lux/data/coll/bits.lux index 9a081c254..b2530627c 100644 --- a/stdlib/source/lux/data/coll/bits.lux +++ b/stdlib/source/lux/data/coll/bits.lux @@ -22,7 +22,7 @@ (def: #export (size bits) (-> Bits Nat) - (array/fold (function [chunk total] + (array/fold (function (_ chunk total) (n/+ total (bit.count chunk))) +0 bits)) diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux index 4c25216c4..97a119755 100644 --- a/stdlib/source/lux/data/coll/dict.lux +++ b/stdlib/source/lux/data/coll/dict.lux @@ -213,7 +213,7 @@ (def: (collision-index Hash key colls) (All [k v] (-> (Hash k) k (Collisions k v) (Maybe Index))) (:: maybe.Monad map product.left - (array.find+ (function [idx [key' val']] + (array.find+ (function (_ idx [key' val']) (:: Hash = key key')) colls))) @@ -221,7 +221,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 (function [idx [insertion-idx node]] + (product.right (list/fold (function (_ idx [insertion-idx node]) (let [[bitmap base] node] (case (array.read idx h-array) #.None [insertion-idx node] @@ -245,7 +245,7 @@ (Hash k) Level BitMap (Base k v) (Array (Node k v)))) - (product.right (list/fold (function [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) @@ -505,7 +505,7 @@ (array/fold n/+ +0 (array/map size' hierarchy)) (#Base _ base) - (array/fold n/+ +0 (array/map (function [sub-node'] + (array/fold n/+ +0 (array/map (function (_ sub-node') (case sub-node' (#.Left sub-node) (size' sub-node) (#.Right _) +1)) @@ -519,12 +519,12 @@ (All [k v] (-> (Node k v) (List [k v]))) (case node (#Hierarchy _size hierarchy) - (array/fold (function [sub-node tail] (list/compose (entries' sub-node) tail)) + (array/fold (function (_ sub-node tail) (list/compose (entries' sub-node) tail)) #.Nil hierarchy) (#Base bitmap base) - (array/fold (function [branch tail] + (array/fold (function (_ branch tail) (case branch (#.Left sub-node) (list/compose (entries' sub-node) tail) @@ -535,7 +535,7 @@ base) (#Collisions hash colls) - (array/fold (function [[key' val'] tail] (#.Cons [key' val'] tail)) + (array/fold (function (_ [key' val'] tail) (#.Cons [key' val'] tail)) #.Nil colls))) @@ -610,7 +610,7 @@ (def: #export (from-list Hash kvs) (All [k v] (-> (Hash k) (List [k v]) (Dict k v))) - (list/fold (function [[k v] dict] + (list/fold (function (_ [k v] dict) (put k v dict)) (new Hash) kvs)) @@ -629,7 +629,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 (function [[key val] dict] (put key val dict)) + (list/fold (function (_ [key val] dict) (put key val dict)) dict1 (entries dict2))) @@ -638,7 +638,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 (function [[key val2] dict] + (list/fold (function (_ [key val2] dict) (case (get key dict) #.None (put key val2 dict) @@ -663,7 +663,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 _] dict] - (list/fold (function [key new-dict] + (list/fold (function (_ key new-dict) (case (get key dict) #.None new-dict (#.Some val) (put key val new-dict))) @@ -675,7 +675,7 @@ (def: (= test subject) (and (n/= (size test) (size subject)) - (list.every? (function [k] + (list.every? (function (_ k) (case [(get k test) (get k subject)] [(#.Some tk) (#.Some sk)] (:: Eq = tk sk) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 9709db465..943743018 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 (function [head tail] (#.Cons head tail)) + (fold (function (_ head tail) (#.Cons head tail)) #.Nil xs)) @@ -198,7 +198,7 @@ (def: #export (size list) (All [a] (-> (List a) Nat)) - (fold (function [_ acc] (n/+ +1 acc)) +0 list)) + (fold (function (_ _ acc) (n/+ +1 acc)) +0 list)) (do-template [ ] [(def: #export ( p xs) @@ -295,7 +295,7 @@ (list) (#.Cons x xs') - (let [[pre post] (fold (function [x' [pre post]] + (let [[pre post] (fold (function (_ x' [pre post]) (if (< x x') [(#.Cons x' pre) post] [pre (#.Cons x' post)])) @@ -360,22 +360,22 @@ indices (n/range +0 (n/dec num-lists)) type-vars (: (List Code) (map (|>> nat/encode symbol$) indices)) zip-type (` (All [(~+ type-vars)] - (-> (~+ (map (: (-> Code Code) (function [var] (` (List (~ var))))) + (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) type-vars)) (List [(~+ type-vars)])))) vars+lists (|> indices (map n/inc) - (map (function [idx] + (map (function (_ idx) (let [base (nat/encode idx)] [(symbol$ base) (symbol$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function [[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) - (function (~ g!step) [(~+ list-vars)] + (function ((~ g!step) (~+ list-vars)) (case [(~+ list-vars)] (~ pattern) (#.Cons [(~+ (map product.left vars+lists))] @@ -407,22 +407,22 @@ type-vars (: (List Code) (map (|>> nat/encode symbol$) indices)) zip-type (` (All [(~+ type-vars) (~ g!return-type)] (-> (-> (~+ type-vars) (~ g!return-type)) - (~+ (map (: (-> Code Code) (function [var] (` (List (~ var))))) + (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) type-vars)) (List (~ g!return-type))))) vars+lists (|> indices (map n/inc) - (map (function [idx] + (map (function (_ idx) (let [base (nat/encode idx)] [(symbol$ base) (symbol$ ("lux text concat" base "'"))])))) - pattern (` [(~+ (map (function [[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) - (function (~ 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/ordered/dict.lux b/stdlib/source/lux/data/coll/ordered/dict.lux index 81e6a3be4..a099087f3 100644 --- a/stdlib/source/lux/data/coll/ordered/dict.lux +++ b/stdlib/source/lux/data/coll/ordered/dict.lux @@ -521,7 +521,7 @@ (def: #export (from-list Order list) (All [k v] (-> (Order k) (List [k v]) (Dict k v))) - (L/fold (function [[key value] dict] + (L/fold (function (_ [key value] dict) (put key value dict)) (new Order) list)) diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux index b65ea1252..b109e460c 100644 --- a/stdlib/source/lux/data/coll/sequence.lux +++ b/stdlib/source/lux/data/coll/sequence.lux @@ -109,11 +109,8 @@ (All [a] (-> a (Base a) (Base a))) (let [tail-size (array.size tail)] (|> (array.new (n/inc tail-size)) - ## (: (Base ($ +0)) - ## (array.new (n/inc tail-size))) (array.copy tail-size +0 tail +0) - (array.write tail-size val) - ))) + (array.write tail-size val)))) (def: (put' level idx val hierarchy) (All [a] (-> Level Index a (Hierarchy a) (Hierarchy a))) @@ -168,7 +165,7 @@ (|> hierarchy array.to-list list.reverse - (list/fold (function [sub acc] (list/compose (to-list' sub) acc)) + (list/fold (function (_ sub acc) (list/compose (to-list' sub) acc)) #.Nil)))) ## [Types] @@ -208,6 +205,7 @@ ## 1-level taller. (|> vec (set@ #root (|> ## (new-hierarchy []) + ## TODO: Remove once new-luxc becomes the standard compiler. (: (Hierarchy ($ +0)) (new-hierarchy [])) (array.write +0 (#Hierarchy (get@ #root vec))) @@ -260,6 +258,7 @@ (if (n/>= (tail-off vec-size) idx) (|> vec ## (update@ #tail (|>> array.clone (array.write (branch-idx idx) val))) + ## TODO: Remove once new-luxc becomes the standard compiler. (update@ #tail (: (-> (Base ($ +0)) (Base ($ +0))) (|>> array.clone (array.write (branch-idx idx) val)))) ) @@ -372,7 +371,7 @@ (array/fold f init base) (#Hierarchy hierarchy) - (array/fold (function [node init'] (fold f init' node)) + (array/fold (function (_ node init') (fold f init' node)) init hierarchy)) )) @@ -421,7 +420,7 @@ (let [(^open) Functor (^open) Fold (^open) Monoid - results (map (function [f] (map f fa)) + results (map (function (_ f) (map f fa)) ff)] (fold compose identity results))) ) @@ -432,7 +431,7 @@ (def: join (let [(^open) Fold (^open) Monoid] - (fold (function [post pre] (compose pre post)) identity))) + (fold (function (_ post pre) (compose pre post)) identity))) ) (def: #export (reverse xs) diff --git a/stdlib/source/lux/data/coll/set.lux b/stdlib/source/lux/data/coll/set.lux index a08b16d39..a09300a7a 100644 --- a/stdlib/source/lux/data/coll/set.lux +++ b/stdlib/source/lux/data/coll/set.lux @@ -71,6 +71,6 @@ (def: eq Eq) (def: (hash (^@ set [Hash _])) - (List/fold (function [elem acc] (n/+ (:: Hash hash elem) acc)) + (List/fold (function (_ elem acc) (n/+ (:: Hash 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 4bce6dd6b..3e76e9d5c 100644 --- a/stdlib/source/lux/data/coll/stream.lux +++ b/stdlib/source/lux/data/coll/stream.lux @@ -136,7 +136,7 @@ (let [(^stream& x y z _tail) (some-stream-func 1 2 3)] (func x y z)))} (with-gensyms [g!stream] - (let [body+ (` (let [(~+ (List/join (List/map (function [pattern] + (let [body+ (` (let [(~+ (List/join (List/map (function (_ pattern) (list (` [(~ pattern) (~ g!stream)]) (` ((~! cont.run) (~ g!stream))))) patterns)))] diff --git a/stdlib/source/lux/data/coll/tree/parser.lux b/stdlib/source/lux/data/coll/tree/parser.lux index c9bf542f3..e5881d097 100644 --- a/stdlib/source/lux/data/coll/tree/parser.lux +++ b/stdlib/source/lux/data/coll/tree/parser.lux @@ -24,7 +24,7 @@ (def: #export value (All [t] (Parser t t)) - (function [zipper] + (function (_ zipper) (#E.Success [zipper (Z.value zipper)]))) (exception: #export Cannot-Move-Further) @@ -32,7 +32,7 @@ (do-template [ ] [(def: #export (All [t] (Parser t [])) - (function [zipper] + (function (_ zipper) (let [next ( zipper)] (if (is? zipper next) (ex.throw Cannot-Move-Further []) diff --git a/stdlib/source/lux/data/coll/tree/rose.lux b/stdlib/source/lux/data/coll/tree/rose.lux index 76f4f1894..48a91c4fc 100644 --- a/stdlib/source/lux/data/coll/tree/rose.lux +++ b/stdlib/source/lux/data/coll/tree/rose.lux @@ -67,7 +67,7 @@ (struct: #export _ (Fold Tree) (def: (fold f init tree) - (L/fold (function [tree' init'] (fold f init' tree')) + (L/fold (function (_ tree' init') (fold f init' tree')) (f (get@ #value tree) init) (get@ #children tree)))) diff --git a/stdlib/source/lux/data/coll/tree/zipper.lux b/stdlib/source/lux/data/coll/tree/zipper.lux index 421c10fe9..845dd4c4c 100644 --- a/stdlib/source/lux/data/coll/tree/zipper.lux +++ b/stdlib/source/lux/data/coll/tree/zipper.lux @@ -82,12 +82,19 @@ (#.Some parent) (|> parent + ## TODO: Remove once new-luxc becomes the standard compiler. (update@ #node (: (-> (Tree ($ +0)) (Tree ($ +0))) - (function [node] + (function (_ node) (set@ #rose.children (L/compose (list.reverse (get@ #lefts zipper)) (#.Cons (get@ #node zipper) (get@ #rights zipper))) - node))))))) + node)))) + ## (update@ #node (function (_ node) + ## (set@ #rose.children (L/compose (list.reverse (get@ #lefts zipper)) + ## (#.Cons (get@ #node zipper) + ## (get@ #rights zipper))) + ## node))) + ))) (def: #export (root zipper) (All [a] (-> (Zipper a) (Zipper a))) @@ -105,14 +112,14 @@ (#.Cons next side') (|> zipper - (update@ (function [op-side] + (update@ (function (_ op-side) (#.Cons (get@ #node zipper) op-side))) (set@ side') (set@ #node next)))) (def: #export ( zipper) (All [a] (-> (Zipper a) (Zipper a))) - (L/fold (function [_] ) zipper (get@ zipper)))] + (L/fold (function (_ _) ) zipper (get@ zipper)))] [right rightmost #rights #lefts] [left leftmost #lefts #rights] @@ -143,19 +150,26 @@ (def: #export (prepend-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #rose.children] - (function [children] + (function (_ children) + ## TODO: Remove once new-luxc becomes the standard compiler. (list& (: (Tree ($ +0)) (rose.tree [value {}])) - children)) + children) + ## (list& (rose.tree [value {}]) + ## children) + ) zipper)) (def: #export (append-child value zipper) (All [a] (-> a (Zipper a) (Zipper a))) (update@ [#node #rose.children] - (function [children] + (function (_ children) (L/compose children + ## TODO: Remove once new-luxc becomes the standard compiler. (list (: (Tree ($ +0)) - (rose.tree [value {}]))))) + (rose.tree [value {}]))) + ## (list (rose.tree [value {}])) + )) zipper)) (def: #export (remove zipper) @@ -184,10 +198,14 @@ _ (#.Some (|> zipper - (update@ (function [side] + (update@ (function (_ side) + ## TODO: Remove once new-luxc becomes the standard compiler. (#.Cons (: (Tree ($ +0)) (rose.tree [value {}])) - side)))))))] + side) + ## (#.Cons (rose.tree [value {}]) + ## side) + ))))))] [insert-left #lefts] [insert-right #rights] @@ -200,13 +218,14 @@ #rights (|> fa (get@ #rights) (L/map (T/map f))) #node (T/map f (get@ #node fa))})) +## TODO: Add again once new-luxc becomes the standard compiler. ## (struct: #export _ (CoMonad Zipper) ## (def: functor Functor) ## (def: unwrap (get@ [#node #rose.value])) ## (def: (split wa) -## (let [tree-splitter (function tree-splitter [tree] +## (let [tree-splitter (function (tree-splitter tree) ## {#rose.value (zip tree) ## #rose.children (L/map tree-splitter ## (get@ #rose.children tree))})] diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 081d94674..dc15c8a6b 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -202,7 +202,7 @@ (let [dS (normalize ratio) dE (|> 1.0 (f/- dS)) interpolate' (: (-> Nat Nat Nat) - (function [end start] + (function (_ end start) (frac-to-nat (f/+ (f/* dE (nat-to-frac end)) (f/* dS (nat-to-frac start)))))) [redS greenS blueS] (unpack start) @@ -226,7 +226,7 @@ (def: #export (complement color) (-> Color Color) (let [[red green blue] (unpack color) - adjust (function [value] (|> top (n/- value)))] + adjust (function (_ value) (|> top (n/- value)))] (..color [(adjust red) (adjust green) (adjust blue)]))) @@ -282,7 +282,7 @@ (list) (let [[hue saturation luminance] (to-hsl color) slice (normalize slice)] - (L/map (function [idx] + (L/map (function (_ idx) (from-hsl [(|> idx nat-to-frac (f/* slice) (f/+ hue) normalize) saturation luminance])) diff --git a/stdlib/source/lux/data/format/context.lux b/stdlib/source/lux/data/format/context.lux index 83105137f..9f58e9ede 100644 --- a/stdlib/source/lux/data/format/context.lux +++ b/stdlib/source/lux/data/format/context.lux @@ -17,7 +17,7 @@ (def: #export (property name) (-> Text (Property Text)) - (function [context] + (function (_ context) (case (d.get name context) (#.Some value) (ex.return [context value]) diff --git a/stdlib/source/lux/data/format/css.lux b/stdlib/source/lux/data/format/css.lux index 4f148110f..5a203440d 100644 --- a/stdlib/source/lux/data/format/css.lux +++ b/stdlib/source/lux/data/format/css.lux @@ -25,13 +25,13 @@ (def: #export (inline style) (-> Style Text) (|> style - (L/map (function [[key val]] (format key ": " val))) + (L/map (function (_ [key val]) (format key ": " val))) (text.join-with "; "))) (def: #export (css sheet) (-> Sheet CSS) (|> sheet - (L/map (function [[selector style]] + (L/map (function (_ [selector style]) (if (list.empty? style) "" (format selector "{" (inline style) "}")))) @@ -59,7 +59,7 @@ (def: #export (rule selector style children) (-> Selector Style Sheet Sheet) (list& [selector style] - (L/map (function [[sub-selector sub-style]] + (L/map (function (_ [sub-selector sub-style]) [(format selector sub-selector) sub-style]) children))) diff --git a/stdlib/source/lux/data/format/html.lux b/stdlib/source/lux/data/format/html.lux index 0c6b1bf0e..ef2e0abf0 100644 --- a/stdlib/source/lux/data/format/html.lux +++ b/stdlib/source/lux/data/format/html.lux @@ -27,7 +27,7 @@ (def: attrs-to-text (-> Attributes Text) - (|>> (L/map (function [[key val]] (format key "=" "\"" (text val) "\""))) + (|>> (L/map (function (_ [key val]) (format key "=" "\"" (text val) "\""))) (text.join-with " "))) (def: #export (tag name attrs children) diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 49a739b4f..86faa0509 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -62,7 +62,7 @@ (json {"this" "is" "an" "object"}))} (let [(^open) Monad - wrapper (function [x] (` (..json (~ x))))] + wrapper (function (_ x) (` (..json (~ x))))] (case token (^template [ ] [_ ( value)] @@ -80,7 +80,7 @@ [_ (#.Record pairs)] (do Monad [pairs' (monad.map @ - (function [[slot value]] + (function (_ [slot value]) (case slot [_ (#.Text key-name)] (wrap (` [(~ (code.text key-name)) (~ (wrapper value))])) @@ -165,7 +165,7 @@ [(#Array xs) (#Array ys)] (and (n/= (sequence.size xs) (sequence.size ys)) - (list/fold (function [idx prev] + (list/fold (function (_ idx prev) (and prev (maybe.default false (do maybe.Monad @@ -177,7 +177,7 @@ [(#Object xs) (#Object ys)] (and (n/= (dict.size xs) (dict.size ys)) - (list/fold (function [[xk xv] prev] + (list/fold (function (_ [xk xv] prev) (and prev (case (dict.get xk ys) #.None false @@ -210,13 +210,13 @@ (def: #export (fail error) (All [a] (-> Text (Reader a))) - (function [inputs] + (function (_ inputs) (#e.Error error))) (def: #export any {#.doc "Just returns the JSON input without applying any logic."} (Reader JSON) - (<| (function [inputs]) + (<| (function (_ inputs)) (case inputs #.Nil (#e.Error "Empty JSON stream.") @@ -313,7 +313,7 @@ (case (do e.Monad [] (|> (dict.entries object) - (monad.map @ (function [[key val]] + (monad.map @ (function (_ [key val]) (do @ [val (run val parser)] (wrap [key val])))) @@ -338,7 +338,7 @@ (#.Some value) (case (run value parser) (#e.Success output) - (function [tail] + (function (_ tail) (#e.Success [(#.Cons (#Object (dict.remove field-name object)) tail) output])) @@ -375,7 +375,7 @@ ($_ text/compose "{" (|> object dict.entries - (list/map (function [[key value]] ($_ text/compose (show-string key) ":" (show-json value)))) + (list/map (function (_ [key value]) ($_ text/compose (show-string key) ":" (show-json value)))) (text.join-with ",")) "}")) @@ -500,4 +500,4 @@ (struct: #export _ (Codec Text JSON) (def: encode show-json) - (def: decode (function [input] (l.run input (json~' []))))) + (def: decode (function (_ input) (l.run input (json~' []))))) diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux index bd047b2f8..29a4410fd 100644 --- a/stdlib/source/lux/data/format/xml.lux +++ b/stdlib/source/lux/data/format/xml.lux @@ -144,7 +144,7 @@ (def: xml^ (l.Lexer XML) (|> (p.rec - (function [node^] + (function (_ node^) (p.either text^ (spaced^ (do p.Monad @@ -191,7 +191,7 @@ (-> Attrs Text) (|> attrs d.entries - (L/map (function [[key value]] + (L/map (function (_ [key value]) ($_ text/compose (write-tag key) "=" "\""(sanitize-value value) "\""))) (text.join-with " "))) @@ -259,7 +259,7 @@ (def: #export text (Reader Text) - (function [docs] + (function (_ docs) (case docs #.Nil (ex.throw Empty-Input []) @@ -274,7 +274,7 @@ (def: #export (attr name) (-> Ident (Reader Text)) - (function [docs] + (function (_ docs) (case docs #.Nil (ex.throw Empty-Input []) @@ -305,7 +305,7 @@ (def: #export (node tag) (-> Ident (Reader Unit)) - (function [docs] + (function (_ docs) (case docs #.Nil (ex.throw Empty-Input []) @@ -322,7 +322,7 @@ (def: #export (children reader) (All [a] (-> (Reader a) (Reader a))) - (function [docs] + (function (_ docs) (case docs #.Nil (ex.throw Empty-Input []) @@ -339,7 +339,7 @@ (def: #export ignore (Reader Unit) - (function [docs] + (function (_ docs) (case docs #.Nil (ex.throw Empty-Input []) diff --git a/stdlib/source/lux/data/lazy.lux b/stdlib/source/lux/data/lazy.lux index 7d5fbb417..8b4a75d1d 100644 --- a/stdlib/source/lux/data/lazy.lux +++ b/stdlib/source/lux/data/lazy.lux @@ -15,7 +15,7 @@ (def: (freeze' generator) (All [a] (-> (-> [] a) (Lazy a))) (let [cache (atom.atom #.None)] - (@abstraction (function [_] + (@abstraction (function (_ _) (case (io.run (atom.read cache)) (#.Some value) value @@ -31,7 +31,7 @@ (syntax: #export (freeze expr) (with-gensyms [g!_] - (wrap (list (` ((~! freeze') (function [(~ g!_)] (~ expr)))))))) + (wrap (list (` ((~! freeze') (function ((~ g!_) (~ g!_)) (~ expr)))))))) (struct: #export _ (Functor Lazy) (def: (map f fa) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index 243723766..5fb1360b5 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -295,7 +295,7 @@ nth-phi (|> input argument (f// r-nth)) slice (|> math.pi (f/* 2.0) (f// r-nth))] (|> (list.n/range +0 (n/dec nth)) - (L/map (function [nth'] + (L/map (function (_ nth') (let [inner (|> nth' nat-to-int int-to-frac (f/* slice) (f/+ nth-phi)) diff --git a/stdlib/source/lux/data/product.lux b/stdlib/source/lux/data/product.lux index 09915b11e..257ac8ec2 100644 --- a/stdlib/source/lux/data/product.lux +++ b/stdlib/source/lux/data/product.lux @@ -16,13 +16,13 @@ (All [a b c] (-> (-> [a b] c) (-> a b c))) - (function [x y] + (function (_ x y) (f [x y]))) (def: #export (uncurry f) (All [a b c] (-> (-> a b c) (-> [a b] c))) - (function [xy] + (function (_ xy) (let [[x y] xy] (f x y)))) @@ -35,12 +35,12 @@ (All [a b c d] (-> (-> a c) (-> b d) (-> [a b] [c d]))) - (function [[x y]] + (function (_ [x y]) [(f x) (g y)])) (def: #export (fork f g) (All [a l r] (-> (-> a l) (-> a r) (-> a [l r]))) - (function [x] + (function (_ x) [(f x) (g x)])) diff --git a/stdlib/source/lux/data/store.lux b/stdlib/source/lux/data/store.lux index 70fd022f4..06b1315a2 100644 --- a/stdlib/source/lux/data/store.lux +++ b/stdlib/source/lux/data/store.lux @@ -11,11 +11,11 @@ (def: (extend f wa) (All [s a b] (-> (-> (Store s a) b) (Store s a) (Store s b))) {#cursor (get@ #cursor wa) - #peek (function [s] (f (set@ #cursor s wa)))}) + #peek (function (_ s) (f (set@ #cursor s wa)))}) (struct: #export Functor (All [s] (F.Functor (Store s))) (def: (map f fa) - (extend (function [store] + (extend (function (_ store) (f (:: store peek (:: store cursor)))) fa))) diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux index 1a58127c1..670951182 100644 --- a/stdlib/source/lux/data/sum.lux +++ b/stdlib/source/lux/data/sum.lux @@ -14,7 +14,7 @@ (All [a b c] (-> (-> a c) (-> b c) (-> (| a b) c))) - (function [input] + (function (_ input) (case input (+0 l) (fl l) (+1 r) (fr r)))) @@ -23,7 +23,7 @@ (All [l l' r r'] (-> (-> l l') (-> r r') (-> (| l r) (| l' r')))) - (function [input] + (function (_ input) (case input (+0 l) (+0 (fl l)) (+1 r) (+1 (fr r))))) diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux index c511d194d..81c2e2fac 100644 --- a/stdlib/source/lux/data/text/format.lux +++ b/stdlib/source/lux/data/text/format.lux @@ -63,7 +63,7 @@ (def: #export (%list formatter) (All [a] (-> (Format a) (Format (List a)))) - (function [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 1cf6c3630..338e2b5ac 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -41,7 +41,7 @@ (def: #export any {#.doc "Just returns the next character without applying any logic."} (Lexer Text) - (function [[offset tape]] + (function (_ [offset tape]) (case (text.nth offset tape) (#.Some output) (#e.Success [[(n/inc offset) tape] (text.from-code output)]) @@ -53,7 +53,7 @@ (def: #export (not p) {#.doc "Produce a character if the lexer fails."} (All [a] (-> (Lexer a) (Lexer Text))) - (function [input] + (function (_ input) (case (p input) (#e.Error msg) (any input) @@ -64,7 +64,7 @@ (def: #export (this reference) {#.doc "Lex a text if it matches the given sample."} (-> Text (Lexer Unit)) - (function [[offset tape]] + (function (_ [offset tape]) (case (text.index-of' reference offset tape) (#.Some where) (if (n/= offset where) @@ -77,7 +77,7 @@ (def: #export (this? reference) {#.doc "Lex a text if it matches the given sample."} (-> Text (Lexer Bool)) - (function [(^@ input [offset tape])] + (function (_ (^@ input [offset tape])) (case (text.index-of' reference offset tape) (^multi (#.Some where) (n/= offset where)) (#e.Success [[(n/+ (text.size reference) offset) tape] true]) @@ -88,7 +88,7 @@ (def: #export end {#.doc "Ensure the lexer's input is empty."} (Lexer Unit) - (function [(^@ input [offset tape])] + (function (_ (^@ input [offset tape])) (if (n/= offset (text.size tape)) (#e.Success [input []]) (#e.Error (unconsumed-input-error offset tape))))) @@ -96,13 +96,13 @@ (def: #export end? {#.doc "Ask if the lexer's input is empty."} (Lexer Bool) - (function [(^@ input [offset tape])] + (function (_ (^@ input [offset tape])) (#e.Success [input (n/= offset (text.size tape))]))) (def: #export peek {#.doc "Lex the next character (without consuming it from the input)."} (Lexer Text) - (function [(^@ input [offset tape])] + (function (_ (^@ input [offset tape])) (case (text.nth offset tape) (#.Some output) (#e.Success [input (text.from-code output)]) @@ -114,7 +114,7 @@ (def: #export get-input {#.doc "Get all of the remaining input (without consuming it)."} (Lexer Text) - (function [(^@ input [offset tape])] + (function (_ (^@ input [offset tape])) (#e.Success [input (remaining offset tape)]))) (def: #export (range bottom top) @@ -161,7 +161,7 @@ (def: #export (one-of options) {#.doc "Only lex characters that are part of a piece of text."} (-> Text (Lexer Text)) - (function [[offset tape]] + (function (_ [offset tape]) (case (text.nth offset tape) (#.Some output) (let [output (text.from-code output)] @@ -175,7 +175,7 @@ (def: #export (none-of options) {#.doc "Only lex characters that are not part of a piece of text."} (-> Text (Lexer Text)) - (function [[offset tape]] + (function (_ [offset tape]) (case (text.nth offset tape) (#.Some output) (let [output (text.from-code output)] @@ -189,7 +189,7 @@ (def: #export (satisfies p) {#.doc "Only lex characters that satisfy a predicate."} (-> (-> Nat Bool) (Lexer Text)) - (function [[offset tape]] + (function (_ [offset tape]) (case (text.nth offset tape) (#.Some output) (if (p output) @@ -248,7 +248,7 @@ (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))) - (function [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 b7c2e613f..91f603af7 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -112,7 +112,7 @@ [_ (wrap []) init re-user-class^' rest (p.some (p.after (l.this "&&") (l.enclosed ["[" "]"] re-user-class^')))] - (wrap (list/fold (function [refinement base] + (wrap (list/fold (function (_ refinement base) (` ((~! refine^) (~ refinement) (~ base)))) init rest)))) @@ -270,7 +270,7 @@ [_ names steps] (list/fold (: (-> (Either Code [Re-Group Code]) [Int (List Code) (List (List Code))] [Int (List Code) (List (List Code))]) - (function [part [idx names steps]] + (function (_ part [idx names steps]) (case part (^or (#.Left complex) (#.Right [#Non-Capturing complex])) [idx @@ -314,7 +314,7 @@ (def: (|||^ left right) (All [l r] (-> (l.Lexer [Text l]) (l.Lexer [Text r]) (l.Lexer [Text (| l r)]))) - (function [input] + (function (_ input) (case (left input) (#e.Success [input' [lt lv]]) (#e.Success [input' [lt (+0 lv)]]) @@ -329,7 +329,7 @@ (def: (|||_^ left right) (All [l r] (-> (l.Lexer [Text l]) (l.Lexer [Text r]) (l.Lexer Text))) - (function [input] + (function (_ input) (case (left input) (#e.Success [input' [lt lv]]) (#e.Success [input' lt]) diff --git a/stdlib/source/lux/data/trace.lux b/stdlib/source/lux/data/trace.lux index a0eee684d..5bd37bbca 100644 --- a/stdlib/source/lux/data/trace.lux +++ b/stdlib/source/lux/data/trace.lux @@ -23,9 +23,9 @@ (def: (split wa) (let [monoid (get@ #monoid wa)] {#monoid monoid - #trace (function [t1] + #trace (function (_ t1) {#monoid monoid - #trace (function [t2] + #trace (function (_ t2) ((get@ #trace wa) (:: monoid compose t1 t2)))})}))) diff --git a/stdlib/source/lux/function.lux b/stdlib/source/lux/function.lux index 977886551..f687f6fd5 100644 --- a/stdlib/source/lux/function.lux +++ b/stdlib/source/lux/function.lux @@ -11,13 +11,13 @@ (def: #export (const c) {#.doc "Create constant functions."} (All [a b] (-> a (-> b a))) - (function [_] 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))) - (function [x y] (f y x))) + (function (_ x y) (f y x))) (struct: #export Monoid (All [a] (Monoid (-> a a))) (def: identity id) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index fafaa81c7..7b96971cd 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -47,7 +47,7 @@ {#.doc (doc "A way to create JavaScript objects." (object) (object "foo" foo "bar" (inc bar)))} - (wrap (list (L/fold (function [[k v] object] + (wrap (list (L/fold (function (_ [k v] object) (` (set! (~ k) (~ v) (~ object)))) (` ("js object")) kvs)))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index edf361067..78f418eb6 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -296,7 +296,7 @@ (-> Primitive-Mode (List Type-Paramameter) Bool GenericType Code) (case class (#GenericTypeVar name) - (case (list.find (function [[pname pbounds]] + (case (list.find (function (_ [pname pbounds]) (and (text/= name pname) (not (list.empty? pbounds)))) type-params) @@ -332,7 +332,7 @@ (def: (class-decl-type$ (^slots [#class-name #class-params])) (-> Class-Declaration Code) (let [=params (list/map (: (-> Type-Paramameter Code) - (function [[pname pbounds]] + (function (_ [pname pbounds]) (case pbounds #.Nil (code.symbol ["" pname]) @@ -365,7 +365,7 @@ [current-module macro.current-module-name definitions (macro.definitions current-module)] (wrap (list/fold (: (-> [Text Definition] Class-Imports Class-Imports) - (function [[short-name [_ meta _]] imports] + (function (_ [short-name [_ meta _]] imports) (case (macro.get-text-ann (ident-for #..jvm-class) meta) (#.Some full-class-name) (add-import [short-name full-class-name] imports) @@ -472,7 +472,7 @@ (-> (List Type-Paramameter) GenericType Text) (case class (#GenericTypeVar name) - (case (list.find (function [[pname pbounds]] + (case (list.find (function (_ [pname pbounds]) (and (text/= name pname) (not (list.empty? pbounds)))) env) @@ -545,7 +545,7 @@ [meta (#.Record pairs)] [meta (#.Record (list/map (: (-> [Code Code] [Code Code]) - (function [[key val]] + (function (_ [key val]) [(pre-walk-replace f key) (pre-walk-replace f val)])) pairs))] @@ -1433,7 +1433,7 @@ "If it fails, you get (#.Left error+stack-traces-as-text)." (try (risky-computation input)))} (with-gensyms [g!_] - (wrap (list (`' ("lux try" (.function [(~ g!_)] (~ expr)))))))) + (wrap (list (`' ("lux try" (.function ((~ g!_) (~ g!_)) (~ expr)))))))) (syntax: #export (instance? [#let [imports (class-imports *compiler*)]] [class (generic-type^ imports (list))] @@ -1447,9 +1447,10 @@ #.None (do @ - [g!obj (macro.gensym "obj")] + [g!_ (macro.gensym "_") + g!obj (macro.gensym "obj")] (wrap (list (` (: (-> (primitive "java.lang.Object") Bool) - (function [(~ g!obj)] + (function ((~ g!_) (~ g!obj)) ((~ (code.text (format "jvm instanceof" ":" (simple-class$ (list) class)))) (~ g!obj)))))))) )) @@ -1510,7 +1511,7 @@ (do Monad [arg-inputs (monad.map @ (: (-> [Bool GenericType] (Meta [Code Code])) - (function [[maybe? _]] + (function (_ [maybe? _]) (with-gensyms [arg-name] (wrap [arg-name (if maybe? (` (!!! (~ arg-name))) @@ -1520,7 +1521,7 @@ (list/map (|>> product.right (simple-class$ (list/compose type-params import-member-tvars))) import-member-args)) arg-types (list/map (: (-> [Bool GenericType] Code) - (function [[maybe? arg]] + (function (_ [maybe? arg]) (let [arg-type (class->type (get@ #import-member-mode commons) type-params arg)] (if maybe? (` (Maybe (~ arg-type))) @@ -1691,7 +1692,7 @@ (list/map type-param->type-arg))] (` (All [(~+ =class-tvars)] (primitive (~ (code.text full-name)) [(~+ =class-tvars)])))))) getter-interop (: (-> Text Code) - (function [name] + (function (_ name) (let [getter-name (code.symbol ["" (format method-prefix member-separator name)])] (` (def: (~ getter-name) (~ enum-type) @@ -2029,10 +2030,10 @@ bar (do-something-else my-res2)] (do-one-last-thing foo bar))))} (with-gensyms [g!output g!_] - (let [inits (list/join (list/map (function [[res-name res-ctor]] + (let [inits (list/join (list/map (function (_ [res-name res-ctor]) (list (code.symbol ["" res-name]) res-ctor)) bindings)) - closes (list/map (function [res] + closes (list/map (function (_ res) (` (try ("jvm invokevirtual:java.io.Closeable:close:" (~ (code.symbol ["" (product.left res)])))))) bindings)] (wrap (list (` (do Monad @@ -2049,7 +2050,7 @@ (def: get-compiler (Meta Compiler) - (function [compiler] + (function (_ compiler) (#.Right [compiler compiler]))) (def: #export (resolve class) diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux index 60bf3c11a..88a784980 100644 --- a/stdlib/source/lux/lang/syntax.lux +++ b/stdlib/source/lux/lang/syntax.lux @@ -304,7 +304,7 @@ (def: frac-ratio-fragment (l.Lexer Frac) (<| (p.codec number.Codec) - (:: p.Monad map (function [digits] + (:: p.Monad map (function (_ digits) (format digits ".0"))) rich-digits^)) @@ -600,7 +600,7 @@ (def: (ast current-module aliases) (-> Text Aliases Cursor (l.Lexer [Cursor Code])) (: (-> Cursor (l.Lexer [Cursor Code])) - (function ast' [where] + (function (ast' where) (do p.Monad [where (left-padding^ where)] ($_ p.either diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux index 33cb2a033..35c2cd29c 100644 --- a/stdlib/source/lux/lang/type.lux +++ b/stdlib/source/lux/lang/type.lux @@ -49,7 +49,7 @@ [(#.Primitive xname xparams) (#.Primitive yname yparams)] (and (text/= xname yname) (n/= (list.size yparams) (list.size xparams)) - (list/fold (.function [[x y] prev] (and prev (= x y))) + (list/fold (.function (_ [x y] prev) (and prev (= x y))) true (list.zip2 xparams yparams))) @@ -81,7 +81,7 @@ [(#.ExQ xenv xbody) (#.ExQ yenv ybody)]) (and (n/= (list.size yenv) (list.size xenv)) (= xbody ybody) - (list/fold (.function [[x y] prev] (and prev (= x y))) + (list/fold (.function (_ [x y] prev) (and prev (= x y))) true (list.zip2 xenv yenv))) diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux index ccb7780e2..7b7c1e3ee 100644 --- a/stdlib/source/lux/lang/type/check.lux +++ b/stdlib/source/lux/lang/type/check.lux @@ -48,7 +48,7 @@ (struct: #export _ (Functor Check) (def: (map f fa) - (function [context] + (function (_ context) (case (fa context) (#e.Error error) (#e.Error error) @@ -61,11 +61,11 @@ (def: functor Functor) (def: (wrap x) - (function [context] + (function (_ context) (#e.Success [context x]))) (def: (apply ff fa) - (function [context] + (function (_ context) (case (ff context) (#e.Success [context' f]) (case (fa context') @@ -84,7 +84,7 @@ (def: applicative Applicative) (def: (join ffa) - (function [context] + (function (_ context) (case (ffa context) (#e.Success [context' fa]) (case (fa context') @@ -155,13 +155,13 @@ (def: #export (throw exception message) (All [e a] (-> (ex.Exception e) e (Check a))) - (function [context] + (function (_ context) (ex.throw exception message))) (def: #export existential {#.doc "A producer of existential types."} (Check [Nat Type]) - (function [context] + (function (_ context) (let [id (get@ #.ex-counter context)] (#e.Success [(update@ #.ex-counter n/inc context) [id (#.Ex id)]])))) @@ -169,7 +169,7 @@ (do-template [ ] [(def: #export ( id) (-> Var (Check )) - (function [context] + (function (_ context) (case (|> context (get@ #.var-bindings) (var::get id)) (^or (#.Some (#.Some (#.Var _))) (#.Some #.None)) @@ -187,7 +187,7 @@ (def: (peek id) (-> Var (Check Type)) - (function [context] + (function (_ context) (case (|> context (get@ #.var-bindings) (var::get id)) (#.Some (#.Some bound)) (#e.Success [context bound]) @@ -200,7 +200,7 @@ (def: #export (write type id) (-> Type Var (Check Unit)) - (function [context] + (function (_ context) (case (|> context (get@ #.var-bindings) (var::get id)) (#.Some (#.Some bound)) (ex.throw Cannot-Rebind-Var [id type bound]) @@ -214,7 +214,7 @@ (def: (update type id) (-> Type Var (Check Unit)) - (function [context] + (function (_ context) (case (|> context (get@ #.var-bindings) (var::get id)) (#.Some _) (#e.Success [(update@ #.var-bindings (var::put id (#.Some type)) context) @@ -225,7 +225,7 @@ (def: #export var (Check [Var Type]) - (function [context] + (function (_ context) (let [id (get@ #.var-counter context)] (#e.Success [(|> context (update@ #.var-counter n/inc) @@ -234,13 +234,13 @@ (def: get-bindings (Check (List [Var (Maybe Type)])) - (function [context] + (function (_ context) (#e.Success [context (get@ #.var-bindings context)]))) (def: (set-bindings value) (-> (List [Var (Maybe Type)]) (Check Unit)) - (function [context] + (function (_ context) (#e.Success [(set@ #.var-bindings value context) []]))) @@ -258,7 +258,7 @@ (apply-type! funcT' argT))) _ - (function [context] + (function (_ context) (case (type.apply (list argT) funcT) #.None (ex.throw Invalid-Type-Application [funcT argT]) @@ -272,7 +272,7 @@ (def: #export (ring id) (-> Var (Check Ring)) - (function [context] + (function (_ context) (loop [current id output (set.add id empty-ring)] (case (|> context (get@ #.var-bindings) (var::get current)) @@ -301,7 +301,7 @@ (def: (attempt op) (All [a] (-> (Check a) (Check (Maybe a)))) - (function [context] + (function (_ context) (case (op context) (#e.Success [context' output]) (#e.Success [context' (#.Some output)]) @@ -311,19 +311,19 @@ (def: #export (fail message) (All [a] (-> Text (Check a))) - (function [context] + (function (_ context) (#e.Error message))) (def: #export (assert message test) (-> Text Bool (Check Unit)) - (function [context] + (function (_ context) (if test (#e.Success [context []]) (#e.Error message)))) (def: (either left right) (All [a] (-> (Check a) (Check a) (Check a))) - (function [context] + (function (_ context) (case (left context) (#e.Success [context' output]) (#e.Success [context' output]) @@ -334,7 +334,7 @@ (def: (assumed? [e a] assumptions) (-> [Type Type] (List Assumption) (Maybe Bool)) (:: maybe.Monad map product.right - (list.find (function [[[fe fa] status]] + (list.find (function (_ [[fe fa] status]) (and (type/= e fe) (type/= a fa))) assumptions))) @@ -421,7 +421,7 @@ (wrap assumptions) ## Fuse 2 rings (do @ - [_ (monad.fold @ (function [interpose to] + [_ (monad.fold @ (function (_ interpose to) (do @ [_ (link-3 interpose to idE)] (wrap interpose))) @@ -446,7 +446,7 @@ (def: (with-error-stack on-error check) (All [a] (-> (-> Unit Text) (Check a) (Check a))) - (function [context] + (function (_ context) (case (check context) (#e.Error error) (#e.Error (case error @@ -519,7 +519,7 @@ (if (is? expected actual) (check/wrap assumptions) (with-error-stack - (function [_] (ex.construct Type-Check-Failed [expected actual])) + (function (_ _) (ex.construct Type-Check-Failed [expected actual])) (case [expected actual] [(#.Var idE) (#.Var idA)] (check-vars check' assumptions idE idA) @@ -527,13 +527,13 @@ [(#.Var id) _] (on id actual (check/wrap assumptions) - (function [bound] + (function (_ bound) (check' bound actual assumptions))) [_ (#.Var id)] (on id expected (check/wrap assumptions) - (function [bound] + (function (_ bound) (check' expected bound assumptions))) (^template [ ] @@ -586,7 +586,7 @@ (list.size a-params))) (do Monad [assumptions (monad.fold Monad - (function [[e a] assumptions] (check' e a assumptions)) + (function (_ [e a] assumptions) (check' e a assumptions)) assumptions (list.zip2 e-params a-params))] (check/wrap assumptions)) @@ -641,7 +641,7 @@ (def: #export get-context (Check Type-Context) - (function [context] + (function (_ context) (#e.Success [context context]))) (def: #export (clean inputT) diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux index 01f1806c4..0e2c60959 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/macro.lux @@ -18,7 +18,7 @@ (struct: #export _ (Functor Meta) (def: (map f fa) - (function [compiler] + (function (_ compiler) (case (fa compiler) (#e.Error msg) (#e.Error msg) @@ -30,11 +30,11 @@ (def: functor Functor) (def: (wrap x) - (function [compiler] + (function (_ compiler) (#e.Success [compiler x]))) (def: (apply ff fa) - (function [compiler] + (function (_ compiler) (case (ff compiler) (#e.Success [compiler' f]) (case (fa compiler') @@ -51,7 +51,7 @@ (def: applicative Applicative) (def: (join mma) - (function [compiler] + (function (_ compiler) (case (mma compiler) (#e.Error msg) (#e.Error msg) @@ -87,7 +87,7 @@ (def: #export (either left right) {#.doc "Pick whichever computation succeeds."} (All [a] (-> (Meta a) (Meta a) (Meta a))) - (function [compiler] + (function (_ compiler) (case (left compiler) (#e.Error error) (right compiler) @@ -98,7 +98,7 @@ (def: #export (assert message test) {#.doc "Fails with the given message if the test is false."} (-> Text Bool (Meta Unit)) - (function [compiler] + (function (_ compiler) (if test (#e.Success [compiler []]) (#e.Error message)))) @@ -107,12 +107,12 @@ {#.doc "Fails with the given message."} (All [a] (-> Text (Meta a))) - (function [_] + (function (_ _) (#e.Error msg))) (def: #export (find-module name) (-> Text (Meta Module)) - (function [compiler] + (function (_ compiler) (case (get name (get@ #.modules compiler)) (#.Some module) (#e.Success [compiler module]) @@ -122,7 +122,7 @@ (def: #export current-module-name (Meta Text) - (function [compiler] + (function (_ compiler) (case (get@ #.current-module compiler) (#.Some current-module) (#e.Success [compiler current-module]) @@ -280,7 +280,7 @@ this-module current-module-name] (let [[module name] ident] (: (Meta (Maybe Macro)) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (find-macro' (get@ #.modules compiler) this-module module name)])))))) (def: #export (expand-once syntax) @@ -362,7 +362,7 @@ A prefix can be given (or just be empty text \"\") to better identify the code for debugging purposes."} (-> Text (Meta Code)) - (function [compiler] + (function (_ compiler) (#e.Success [(update@ #.seed n/inc compiler) (code.symbol ["" ($_ text/compose "__gensym__" prefix (:: number.Codec encode (get@ #.seed compiler)))])]))) @@ -390,7 +390,7 @@ (do Monad [symbol-names (monad.map @ get-local-symbol symbols) #let [symbol-defs (list/join (list/map (: (-> Text (List Code)) - (function [name] (list (code.symbol ["" name]) (` (gensym (~ (code.text name))))))) + (function (_ name) (list (code.symbol ["" name]) (` (gensym (~ (code.text name))))))) symbol-names))]] (wrap (list (` ((~! do) (~! Monad) [(~+ symbol-defs)] @@ -413,7 +413,7 @@ (def: #export (module-exists? module) (-> Text (Meta Bool)) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (case (get module (get@ #.modules compiler)) (#.Some _) true @@ -443,7 +443,7 @@ (-> Type (Meta Type)) (case type (#.Var var) - (function [compiler] + (function (_ compiler) (case (|> compiler (get@ [#.type-context #.var-bindings]) (find-type-var var)) @@ -459,11 +459,11 @@ (def: #export (find-var-type name) {#.doc "Looks-up the type of a local variable somewhere in the environment."} (-> Text (Meta Type)) - (function [compiler] + (function (_ compiler) (let [test (: (-> [Text [Type Top]] Bool) (|>> product.left (text/= name)))] (case (do maybe.Monad - [scope (list.find (function [env] + [scope (list.find (function (_ env) (or (list.any? test (: (List [Text [Type Top]]) (get@ [#.locals #.mappings] env))) (list.any? test (: (List [Text [Type Top]]) @@ -486,7 +486,7 @@ (-> Ident (Meta Definition)) (do Monad [name (normalize name)] - (function [compiler] + (function (_ compiler) (case (: (Maybe Definition) (do maybe.Monad [#let [[v-prefix v-name] name] @@ -504,7 +504,7 @@ (#.Some this-module) ($_ text/compose " Imports: " (|> this-module (get@ #.imports) (text.join-with ", ")) "\n" - " Aliases: " (|> this-module (get@ #.module-aliases) (list/map (function [[alias real]] ($_ text/compose alias " => " real))) (text.join-with ", ")) "\n") + " Aliases: " (|> this-module (get@ #.module-aliases) (list/map (function (_ [alias real]) ($_ text/compose alias " => " real))) (text.join-with ", ")) "\n") _ "") @@ -540,7 +540,7 @@ (def: #export (definitions module-name) {#.doc "The entire list of definitions in a module (including the unexported/private ones)."} (-> Text (Meta (List [Text Definition]))) - (function [compiler] + (function (_ compiler) (case (get module-name (get@ #.modules compiler)) #.None (#e.Error ($_ text/compose "Unknown module: " module-name)) (#.Some module) (#e.Success [compiler (get@ #.definitions module)]) @@ -551,14 +551,14 @@ (-> Text (Meta (List [Text Definition]))) (do Monad [definitions (definitions module-name)] - (wrap (list.filter (function [[name [def-type def-anns def-value]]] + (wrap (list.filter (function (_ [name [def-type def-anns def-value]]) (export? def-anns)) definitions)))) (def: #export modules {#.doc "All the available modules (including the current one)."} (Meta (List [Text Module])) - (function [compiler] + (function (_ compiler) (|> compiler (get@ #.modules) [compiler] @@ -580,13 +580,13 @@ (def: #export cursor {#.doc "The cursor of the current expression being analyzed."} (Meta Cursor) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (get@ #.cursor compiler)]))) (def: #export expected-type {#.doc "The expected type of the current expression being analyzed."} (Meta Type) - (function [compiler] + (function (_ compiler) (case (get@ #.expected compiler) (#.Some type) (#e.Success [compiler type]) @@ -625,16 +625,16 @@ [=module (find-module module) this-module-name current-module-name] (wrap (|> (get@ #.types =module) - (list.filter (function [[type-name [tag-list exported? type]]] + (list.filter (function (_ [type-name [tag-list exported? type]]) (or exported? (text/= this-module-name module)))) - (list/map (function [[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."} (Meta (List (List [Text Type]))) - (function [compiler] + (function (_ compiler) (case (list.inits (get@ #.scopes compiler)) #.None (#e.Error "No local environment") @@ -642,7 +642,7 @@ (#.Some scopes) (#e.Success [compiler (list/map (|>> (get@ [#.locals #.mappings]) - (list/map (function [[name [type _]]] + (list/map (function (_ [name [type _]]) [name type]))) scopes)])))) @@ -661,12 +661,12 @@ (def: #export get-compiler {#.doc "Obtains the current state of the compiler."} (Meta Compiler) - (function [compiler] + (function (_ compiler) (#e.Success [compiler compiler]))) (def: #export type-context (Meta Type-Context) - (function [compiler] + (function (_ compiler) (#e.Success [compiler (get@ #.type-context compiler)]))) (do-template [ ] diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index 73b6bbf5a..10bfed3ef 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -74,7 +74,7 @@ (^template [] [[_ ( xs')] [_ ( ys')]] (and (:: Eq = (size xs') (size ys')) - (fold (function [[x' y'] old] + (fold (function (_ [x' y'] old) (and old (= x' y'))) true (zip2 xs' ys')))) @@ -83,7 +83,7 @@ [[_ (#.Record xs')] [_ (#.Record ys')]] (and (:: Eq = (size xs') (size ys')) - (fold (function [[[xl' xr'] [yl' yr']] old] + (fold (function (_ [[xl' xr'] [yl' yr']] old) (and old (= xl' yl') (= xr' yr'))) true (zip2 xs' ys'))) @@ -118,7 +118,7 @@ [#.Tuple "[" "]"]) [_ (#.Record pairs)] - ($_ Text/compose "{" (|> pairs (map (function [[left right]] ($_ Text/compose (to-text left) " " (to-text right)))) (interpose " ") (text.join-with "")) "}") + ($_ Text/compose "{" (|> pairs (map (function (_ [left right]) ($_ Text/compose (to-text left) " " (to-text right)))) (interpose " ") (text.join-with "")) "}") )) (def: #export (replace original substitute ast) @@ -134,7 +134,7 @@ [#.Tuple]) [cursor (#.Record parts)] - [cursor (#.Record (map (function [[left right]] + [cursor (#.Record (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 636824d99..7582e8a62 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -54,12 +54,12 @@ (def: #export env (Poly Env) - (.function [[env inputs]] + (.function (_ [env inputs]) (#e.Success [[env inputs] env]))) (def: (with-env temp poly) (All [a] (-> Env (Poly a) (Poly a))) - (.function [[env inputs]] + (.function (_ [env inputs]) (case (p.run [temp inputs] poly) (#e.Error error) (#e.Error error) @@ -69,7 +69,7 @@ (def: #export peek (Poly Type) - (.function [[env inputs]] + (.function (_ [env inputs]) (case inputs #.Nil (#e.Error "Empty stream of types.") @@ -79,7 +79,7 @@ (def: #export any (Poly Type) - (.function [[env inputs]] + (.function (_ [env inputs]) (case inputs #.Nil (#e.Error "Empty stream of types.") @@ -89,7 +89,7 @@ (def: #export (local types poly) (All [a] (-> (List Type) (Poly a) (Poly a))) - (.function [[env pass-through]] + (.function (_ [env pass-through]) (case (run' env types poly) (#e.Error error) (#e.Error error) @@ -103,7 +103,7 @@ (def: #export (with-extension type poly) (All [a] (-> Type (Poly a) (Poly [Code a]))) - (.function [[env inputs]] + (.function (_ [env inputs]) (let [current-id (dict.size env) g!var (label current-id)] (case (p.run [(dict.put current-id [type g!var] env) @@ -366,13 +366,13 @@ (syntax: #export (poly: [export csr.export] [name s.local-symbol] body) - (with-gensyms [g!type g!output] + (with-gensyms [g!_ g!type g!output] (let [g!name (code.symbol ["" name])] (wrap (.list (` (syntax: (~+ (csw.export export)) ((~ g!name) [(~ g!type) s.symbol]) (do macro.Monad [(~ g!type) (macro.find-type-def (~ g!type))] (case (|> (~ body) - (.function [(~ g!name)]) + (.function ((~ g!_) (~ g!name))) p.rec (do p.Monad []) (..run (~ g!type)) diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux index 1da35d91e..c1566b6d3 100644 --- a/stdlib/source/lux/macro/poly/eq.lux +++ b/stdlib/source/lux/macro/poly/eq.lux @@ -31,11 +31,11 @@ ## [Derivers] (poly: #export Eq (`` (do @ - [#let [g!_ (code.local-symbol "\u0000_")] + [#let [g!_ (code.local-symbol "_____________")] *env* poly.env inputT poly.peek #let [@Eq (: (-> Type Code) - (function [type] + (function (_ type) (` (eq.Eq (~ (poly.to-code *env* type))))))]] ($_ p.either ## Basic types @@ -45,7 +45,7 @@ (wrap (` (: (~ (@Eq inputT)) ))))] - [poly.unit (function [(~ g!_) (~ g!_)] true)] + [poly.unit (function ((~ g!_) (~ g!_) (~ g!_)) true)] [poly.bool bool.Eq] [poly.nat number.Eq] [poly.int number.Eq] @@ -95,12 +95,13 @@ ## Variants (do @ [members (poly.variant (p.many Eq)) - #let [g!left (code.local-symbol "\u0000left") - g!right (code.local-symbol "\u0000right")]] + #let [g!_ (code.local-symbol "_____________") + g!left (code.local-symbol "_____________left") + g!right (code.local-symbol "_____________right")]] (wrap (` (: (~ (@Eq inputT)) - (function [(~ g!left) (~ g!right)] + (function ((~ g!_) (~ g!left) (~ g!right)) (case [(~ g!left) (~ g!right)] - (~+ (list/join (list/map (function [[tag g!eq]] + (~+ (list/join (list/map (function (_ [tag g!eq]) (list (` [((~ (code.nat tag)) (~ g!left)) ((~ (code.nat tag)) (~ g!right))]) (` ((~ g!eq) (~ g!left) (~ g!right))))) @@ -110,19 +111,21 @@ ## Tuples (do @ [g!eqs (poly.tuple (p.many Eq)) - #let [indices (|> (list.size g!eqs) n/dec (list.n/range +0)) + #let [g!_ (code.local-symbol "_____________") + indices (|> (list.size g!eqs) n/dec (list.n/range +0)) g!lefts (list/map (|>> nat/encode (text/compose "left") code.local-symbol) indices) g!rights (list/map (|>> nat/encode (text/compose "right") code.local-symbol) indices)]] (wrap (` (: (~ (@Eq inputT)) - (function [[(~+ g!lefts)] [(~+ g!rights)]] + (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) (and (~+ (|> (list.zip3 g!eqs g!lefts g!rights) - (list/map (function [[g!eq g!left g!right]] + (list/map (function (_ [g!eq g!left g!right]) (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) ## Type recursion (do @ - [[g!self bodyC] (poly.recursive Eq)] + [[g!self bodyC] (poly.recursive Eq) + #let [g!_ (code.local-symbol "_____________")]] (wrap (` (: (~ (@Eq inputT)) - (eq.rec (.function [(~ g!self)] + (eq.rec (.function ((~ g!_) (~ g!self)) (~ bodyC))))))) poly.recursive-self ## Type applications @@ -137,7 +140,7 @@ (wrap (` (: (All [(~+ varsC)] (-> (~+ (list/map (|>> (~) eq.Eq (`)) varsC)) (eq.Eq ((~ (poly.to-code *env* inputT)) (~+ varsC))))) - (function (~ funcC) [(~+ varsC)] + (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) poly.recursive-call ## If all else fails... diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index f3ed46041..91a325198 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -17,23 +17,23 @@ (poly: #export Functor (do @ - [#let [type-funcC (code.local-symbol "\u0000type-funcC") - funcC (code.local-symbol "\u0000funcC") - inputC (code.local-symbol "\u0000inputC")] + [#let [type-funcC (code.local-symbol "____________type-funcC") + funcC (code.local-symbol "____________funcC") + inputC (code.local-symbol "____________inputC")] *env* poly.env inputT poly.peek [polyC varsC non-functorT] (poly.local (list inputT) (poly.polymorphic poly.any)) #let [num-vars (list.size varsC)] #let [@Functor (: (-> Type Code) - (function [unwrappedT] + (function (_ unwrappedT) (if (n/= +1 num-vars) (` (functor.Functor (~ (poly.to-code *env* unwrappedT)))) (let [paramsC (|> num-vars n/dec list.indices (L/map (|>> %n code.local-symbol)))] (` (All [(~+ paramsC)] (functor.Functor ((~ (poly.to-code *env* unwrappedT)) (~+ paramsC))))))))) Arg (: (-> Code (poly.Poly Code)) - (function Arg [valueC] + (function (Arg valueC) ($_ p.either ## Type-var (do p.Monad @@ -45,7 +45,7 @@ [_ (wrap []) membersC (poly.variant (p.many (Arg valueC)))] (wrap (` (case (~ valueC) - (~+ (L/join (L/map (function [[tag memberC]] + (~+ (L/join (L/map (function (_ [tag memberC]) (list (` ((~ (code.nat tag)) (~ valueC))) (` ((~ (code.nat tag)) (~ memberC))))) (list.enumerate membersC)))))))) @@ -55,7 +55,7 @@ (poly.tuple (loop [idx +0 pairsCC (: (List [Code Code]) (list))] - (p.either (let [slotC (|> idx %n (format "\u0000slot") code.local-symbol)] + (p.either (let [slotC (|> idx %n (format "____________slot") code.local-symbol)] (do @ [_ (wrap []) memberC (Arg slotC)] @@ -68,13 +68,14 @@ ## Functions (do @ [_ (wrap []) - #let [outL (code.local-symbol "\u0000outL")] + #let [g! (code.local-symbol "____________") + outL (code.local-symbol "____________outL")] [inT+ outC] (poly.function (p.many poly.any) (Arg outL)) #let [inC+ (|> (list.size inT+) n/dec (list.n/range +0) - (L/map (|>> %n (format "\u0000inC") code.local-symbol)))]] - (wrap (` (function [(~+ inC+)] + (L/map (|>> %n (format "____________inC") code.local-symbol)))]] + (wrap (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) ## Recursion diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index cbe3877d7..d2e73d4a8 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -36,7 +36,7 @@ (All [a] (-> (-> (-> a JSON) (-> a JSON)) (-> a JSON))) - (function [input] + (function (_ input) (non-rec (rec-encode non-rec) input))) (def: low-mask Nat (|> +1 (bit.shift-left +32) n/dec)) @@ -65,7 +65,7 @@ (def: (nullable writer) {#.doc "Builds a JSON generator for potentially inexistent values."} (All [a] (-> (-> a JSON) (-> (Maybe a) JSON))) - (function [elem] + (function (_ elem) (case elem #.None #//.Null (#.Some value) (writer value)))) @@ -81,11 +81,12 @@ (with-expansions [ (do-template [ ] [(do @ - [_ ] + [#let [g!_ (code.local-symbol "_______")] + _ ] (wrap (` (: (~ (@JSON//encode inputT)) ))))] - [Unit poly.unit (function [(~ (code.symbol ["" "0"]))] #//.Null)] + [Unit poly.unit (function ((~ g!_) (~ (code.symbol ["" "0"]))) #//.Null)] [Bool poly.bool (|>> #//.Boolean)] [Nat poly.nat (:: (~! ..Codec) (~' encode))] [Int poly.int (:: (~! ..Codec) (~' encode))] @@ -105,7 +106,7 @@ (do @ [*env* poly.env #let [@JSON//encode (: (-> Type Code) - (function [type] + (function (_ type) (` (-> (~ (poly.to-code *env* type)) //.JSON))))] inputT poly.peek] ($_ p.either @@ -117,15 +118,16 @@ (wrap (` (: (~ (@JSON//encode inputT)) (:: (~! Codec) (~' encode)))))) (do @ - [#let [g!key (code.local-symbol "\u0000key") - g!val (code.local-symbol "\u0000val")] + [#let [g!_ (code.local-symbol "_______") + g!key (code.local-symbol "_______key") + g!val (code.local-symbol "_______val")] [_ _ =val=] (poly.apply ($_ p.seq (poly.this d.Dict) poly.text Codec//encode))] (wrap (` (: (~ (@JSON//encode inputT)) (|>> d.entries - ((~! list/map) (function [[(~ g!key) (~ g!val)]] + ((~! list/map) (function ((~ g!_) [(~ g!key) (~ g!val)]) [(~ g!key) ((~ =val=) (~ g!val))])) (d.from-list text.Hash) #//.Object))))) @@ -142,31 +144,34 @@ (wrap (` (: (~ (@JSON//encode inputT)) (|>> ((~! list/map) (~ =sub=)) sequence.from-list #//.Array))))) (do @ - [#let [g!input (code.local-symbol "\u0000input")] + [#let [g!_ (code.local-symbol "_______") + g!input (code.local-symbol "_______input")] members (poly.variant (p.many Codec//encode))] (wrap (` (: (~ (@JSON//encode inputT)) - (function [(~ g!input)] + (function ((~ g!_) (~ g!input)) (case (~ g!input) - (~+ (list/join (list/map (function [[tag g!encode]] + (~+ (list/join (list/map (function (_ [tag g!encode]) (list (` ((~ (code.nat tag)) (~ g!input))) (` (//.json [(~ (code.frac (..tag tag))) ((~ g!encode) (~ g!input))])))) (list.enumerate members)))))))))) (do @ [g!encoders (poly.tuple (p.many Codec//encode)) - #let [g!members (|> (list.size g!encoders) n/dec + #let [g!_ (code.local-symbol "_______") + g!members (|> (list.size g!encoders) n/dec (list.n/range +0) (list/map (|>> nat/encode code.local-symbol)))]] (wrap (` (: (~ (@JSON//encode inputT)) - (function [[(~+ g!members)]] - (//.json [(~+ (list/map (function [[g!member g!encode]] + (function ((~ g!_) [(~+ g!members)]) + (//.json [(~+ (list/map (function (_ [g!member g!encode]) (` ((~ g!encode) (~ g!member)))) (list.zip2 g!members g!encoders)))])))))) ## Type recursion (do @ - [[selfC non-recC] (poly.recursive Codec//encode)] + [[selfC non-recC] (poly.recursive Codec//encode) + #let [g! (code.local-symbol "____________")]] (wrap (` (: (~ (@JSON//encode inputT)) - ((~! ..rec-encode) (.function [(~ selfC)] + ((~! ..rec-encode) (.function ((~ g!) (~ selfC)) (~ non-recC))))))) poly.recursive-self ## Type applications @@ -177,11 +182,11 @@ (do @ [[funcC varsC bodyC] (poly.polymorphic Codec//encode)] (wrap (` (: (All [(~+ varsC)] - (-> (~+ (list/map (function [varC] (` (-> (~ varC) //.JSON))) + (-> (~+ (list/map (function (_ varC) (` (-> (~ varC) //.JSON))) varsC)) (-> ((~ (poly.to-code *env* inputT)) (~+ varsC)) //.JSON))) - (function (~ funcC) [(~+ varsC)] + (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) poly.bound poly.recursive-call @@ -217,7 +222,7 @@ (do @ [*env* poly.env #let [@JSON//decode (: (-> Type Code) - (function [type] + (function (_ type) (` (//.Reader (~ (poly.to-code *env* type))))))] inputT poly.peek] ($_ p.either @@ -249,7 +254,7 @@ [members (poly.variant (p.many Codec//decode))] (wrap (` (: (~ (@JSON//decode inputT)) ($_ p.alt - (~+ (list/map (function [[tag memberC]] + (~+ (list/map (function (_ [tag memberC]) (` (|> (~ memberC) (p.after (//.number! (~ (code.frac (..tag tag))))) //.array))) @@ -260,9 +265,10 @@ (//.array ($_ p.seq (~+ g!decoders))))))) ## Type recursion (do @ - [[selfC bodyC] (poly.recursive Codec//decode)] + [[selfC bodyC] (poly.recursive Codec//decode) + #let [g! (code.local-symbol "____________")]] (wrap (` (: (~ (@JSON//decode inputT)) - (p.rec (.function [(~ selfC)] + (p.rec (.function ((~ g!) (~ selfC)) (~ bodyC))))))) poly.recursive-self ## Type applications @@ -275,7 +281,7 @@ (wrap (` (: (All [(~+ varsC)] (-> (~+ (list/map (|>> (~) //.Reader (`)) varsC)) (//.Reader ((~ (poly.to-code *env* inputT)) (~+ varsC))))) - (function (~ funcC) [(~+ varsC)] + (function ((~ funcC) (~+ varsC)) (~ bodyC)))))) poly.bound poly.recursive-call diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 73eda1e8a..536366a8f 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -36,7 +36,7 @@ (def: #export any {#.doc "Just returns the next input without applying any logic."} (Syntax Code) - (function [tokens] + (function (_ tokens) (case tokens #.Nil (#e.Error "There are no tokens to parse!") (#.Cons [t tokens']) (#e.Success [tokens' t])))) @@ -45,7 +45,7 @@ [(def: #export {#.doc (code.text ($_ text/compose "Parses the next " " input Code."))} (Syntax ) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [[_ ( x)] tokens']) (#e.Success [tokens' x]) @@ -66,7 +66,7 @@ (def: #export (this? ast) {#.doc "Asks if the given Code is the next input."} (-> Code (Syntax Bool)) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [token tokens']) (let [is-it? (code/= ast token) @@ -81,7 +81,7 @@ (def: #export (this ast) {#.doc "Ensures the given Code is the next input."} (-> Code (Syntax Unit)) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [token tokens']) (if (code/= ast token) @@ -96,7 +96,7 @@ [(def: #export {#.doc (code.text ($_ text/compose "Parse a local " " (a " " that has no module prefix)."))} (Syntax Text) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [[_ ( ["" x])] tokens']) (#e.Success [tokens' x]) @@ -113,7 +113,7 @@ {#.doc (code.text ($_ text/compose "Parse inside the contents of a " " as if they were the input Codes."))} (All [a] (-> (Syntax a) (Syntax a))) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [[_ ( members)] tokens']) (case (p members) @@ -131,7 +131,7 @@ {#.doc (code.text ($_ text/compose "Parse inside the contents of a record as if they were the input Codes."))} (All [a] (-> (Syntax a) (Syntax a))) - (function [tokens] + (function (_ tokens) (case tokens (#.Cons [[_ (#.Record pairs)] tokens']) (case (p (join-pairs pairs)) @@ -144,7 +144,7 @@ (def: #export end! {#.doc "Ensures there are no more inputs."} (Syntax Unit) - (function [tokens] + (function (_ tokens) (case tokens #.Nil (#e.Success [tokens []]) _ (#e.Error ($_ text/compose "Expected list of tokens to be empty!" (remaining-inputs tokens)))))) @@ -152,7 +152,7 @@ (def: #export end? {#.doc "Checks whether there are no more inputs."} (Syntax Bool) - (function [tokens] + (function (_ tokens) (case tokens #.Nil (#e.Success [tokens true]) _ (#e.Success [tokens false])))) @@ -160,7 +160,7 @@ (def: #export (on compiler action) {#.doc "Run a Lux operation as if it was a Syntax parser."} (All [a] (-> Compiler (Meta a) (Syntax a))) - (function [input] + (function (_ input) (case (macro.run compiler action) (#e.Error error) (#e.Error error) @@ -188,7 +188,7 @@ (def: #export (local inputs syntax) {#.doc "Run a syntax parser with the given list of inputs, instead of the real ones."} (All [a] (-> (List Code) (Syntax a) (Syntax a))) - (function [real] + (function (_ real) (do e.Monad [value (run inputs syntax)] (wrap [real value])))) @@ -237,7 +237,7 @@ (do macro.Monad [vars+parsers (monad.map @ (: (-> Code (Meta [Code Code])) - (function [arg] + (function (_ arg) (case arg (^ [_ (#.Tuple (list var parser))]) (wrap [var parser]) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index 64ee13480..eea41c040 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -187,7 +187,7 @@ (def: infix^ (Syntax Infix) - (<| p.rec (function [infix^]) + (<| p.rec (function (_ infix^)) ($_ p.alt ($_ p.either (p/map code.bool s.bool) @@ -207,7 +207,7 @@ init-op s.any init-param infix^ steps (p.some (p.seq s.any infix^))] - (wrap (product.right (L/fold (function [[op param] [subject [_subject _op _param]]] + (wrap (product.right (L/fold (function (_ [op param] [subject [_subject _op _param]]) [param [(#Binary _subject _op _param) (` and) (#Binary subject op param)]]) @@ -218,7 +218,7 @@ init-op s.any init-param infix^ steps (p.some (p.seq s.any infix^))] - (wrap (L/fold (function [[op param] [_subject _op _param]] + (wrap (L/fold (function (_ [op param] [_subject _op _param]) [(#Binary _subject _op _param) op param]) [init-subject init-op init-param] steps))) diff --git a/stdlib/source/lux/math/constructive.lux b/stdlib/source/lux/math/constructive.lux index 762e15e31..c360a0552 100644 --- a/stdlib/source/lux/math/constructive.lux +++ b/stdlib/source/lux/math/constructive.lux @@ -133,7 +133,7 @@ g!identities (.|> inputs (list.filter identified?) (list/map (.|>> input-name code.local-symbol))) - g!requisites (list/map (.function [input] + g!requisites (list/map (.function (_ input) (.case input (#Identified input') (.` (..Witness (~ (.get@ #input-type input')) @@ -156,8 +156,7 @@ (.let [inputs-names (list/map (.|>> input-name code.local-symbol) inputs)] (wrap (.list (.` (.: (~ (theorem-type type-vars inputs outputT)) - (.function (~ (code.local-symbol name)) - [(~+ inputs-names)] + (.function ((~ (code.local-symbol name)) (~+ inputs-names)) (~ meaning)))))))) (.def: (input-code input) @@ -193,5 +192,5 @@ (.def: #export absurdity (.All [p] (-> p .Bottom)) - (.function [proof] + (.function (_ proof) (.error! (ex.construct Absurdity [])))) diff --git a/stdlib/source/lux/math/logic/fuzzy.lux b/stdlib/source/lux/math/logic/fuzzy.lux index ca1ad0512..58e716c55 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))) - (function [elem] + (function (_ elem) (&.~or (membership elem left) (membership elem right)))) (def: #export (intersection left right) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) - (function [elem] + (function (_ elem) (&.~and (membership elem left) (membership elem right)))) (def: #export (complement set) (All [a] (-> (Fuzzy a) (Fuzzy a))) - (function [elem] + (function (_ elem) (&.~not (membership elem set)))) (def: #export (difference sub base) (All [a] (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) - (function [elem] + (function (_ elem) (&.~and (membership elem base) (&.~not (membership elem sub))))) (def: #export (from-predicate predicate) (All [a] (-> (-> a Bool) (Fuzzy a))) - (function [elem] + (function (_ elem) (if (predicate elem) &.~true &.~false))) @@ -51,7 +51,7 @@ (do-template [
] [(def: ( from to) (-> (Fuzzy )) - (function [elem] + (function (_ elem) (cond ( from elem) &.~false @@ -64,7 +64,7 @@ (def: ( from to) (-> (Fuzzy )) - (function [elem] + (function (_ elem) (cond ( from elem) &.~true @@ -112,7 +112,7 @@ (def: #export (gaussian deviation center) (-> Frac Frac (Fuzzy Frac)) - (function [elem] + (function (_ elem) (let [scale (|> deviation (math.pow 2.0) (f/* 2.0)) membership (|> elem (f/- center) @@ -126,7 +126,7 @@ (def: #export (cut treshold set) (All [a] (-> Deg (Fuzzy a) (Fuzzy a))) - (function [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))) - (function [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))) - (function [elem] + (function (_ elem) (let [l-deg (lower elem) u-deg (upper elem)] [(d/min l-deg diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux index 71d22395e..050c3feaa 100644 --- a/stdlib/source/lux/math/modular.lux +++ b/stdlib/source/lux/math/modular.lux @@ -73,7 +73,7 @@ (def: #export (mod modulus) (All [m] (-> (Modulus m) (-> Int (Mod m)))) - (function [value] + (function (_ value) (@abstraction {#remainder (i/mod (to-int modulus) value) #modulus modulus}))) diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index e3c7fd751..f2f4d2e14 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -30,7 +30,7 @@ (struct: #export _ (Functor Random) (def: (map f fa) - (function [state] + (function (_ state) (let [[state' a] (fa state)] [state' (f a)])))) @@ -38,11 +38,11 @@ (def: functor Functor) (def: (wrap a) - (function [state] + (function (_ state) [state a])) (def: (apply ff fa) - (function [state] + (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)])))) @@ -51,7 +51,7 @@ (def: applicative Applicative) (def: (join ffa) - (function [state] + (function (_ state) (let [[state' fa] (ffa state)] (fa state'))))) @@ -66,7 +66,7 @@ (def: #export nat (Random Nat) - (function [prng] + (function (_ prng) (let [[prng left] (prng []) [prng right] (prng [])] [prng (n/+ (bit.shift-left +32 left) @@ -74,7 +74,7 @@ (def: #export int (Random Int) - (function [prng] + (function (_ prng) (let [[prng left] (prng []) [prng right] (prng [])] [prng (nat-to-int (n/+ (bit.shift-left +32 left) @@ -82,13 +82,13 @@ (def: #export bool (Random Bool) - (function [prng] + (function (_ prng) (let [[prng output] (prng [])] [prng (|> output (bit.and +1) (n/= +1))]))) (def: (bits n) (-> Nat (Random Nat)) - (function [prng] + (function (_ prng) (let [[prng output] (prng [])] [prng (bit.shift-right (n/- n +64) output)]))) @@ -143,7 +143,7 @@ (Random Nat) (|> ..nat (:: Monad map (n/% unicode-ceiling)) - (..filter (function [raw] + (..filter (function (_ raw) ## From "Basic Latin" to "Syriac" (or (n/<= (hex "+074F") raw) (within? Thaana raw) @@ -245,7 +245,7 @@ (def: #export (rec gen) {#.doc "A combinator for producing recursive random generators."} (All [a] (-> (-> (Random a) (Random a)) (Random a))) - (function [state] + (function (_ state) (let [gen' (gen (rec gen))] (gen' state)))) @@ -325,7 +325,7 @@ For more information, please see: http://www.pcg-random.org/"} (-> [Nat Nat] PRNG) - (function [_] + (function (_ _) (let [seed' (|> seed (n/* pcg-32-magic-mult) (n/+ inc)) xor-shifted (|> seed (bit.shift-right +18) (bit.xor seed) (bit.shift-right +27)) rot (|> seed (bit.shift-right +59))] @@ -337,7 +337,7 @@ For more information, please see: http://xoroshiro.di.unimi.it/"} (-> [Nat Nat] PRNG) - (function [_] + (function (_ _) (let [result (n/+ s0 s1) s01 (bit.xor s0 s1) s0' (|> (bit.rotate-left +55 s0) @@ -358,7 +358,7 @@ (All [a] (-> Nat (Sequence a) (Sequence a))) (let [_size (sequence.size sequence) _shuffle (monad.fold Monad - (function [idx vec] + (function (_ idx vec) (do Monad [rand nat] (wrap (swap idx (n/% _size rand) vec)))) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index d18c74df8..7a1877f68 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -71,7 +71,7 @@ (do promise.Monad [test-runs (|> tests (list/map (: (-> [Text (IO Test) Text] (Promise Counters)) - (function [[module test description]] + (function (_ [module test description]) (do @ [#let [pre (io.run instant.now) seed (int-to-nat (instant.to-millis pre))] @@ -94,7 +94,7 @@ (def: #export (seed value test) (-> Seed Test Test) - (function [prng] + (function (_ prng) (let [[_ result] (r.run (r.pcg-32 [pcg-32-magic-inc value]) test)] [prng result]))) @@ -110,7 +110,7 @@ ## else (do r.Monad [seed r.nat] - (function [prng] + (function (_ prng) (let [[prng' instance] (r.run (r.pcg-32 [pcg-32-magic-inc seed]) test)] [prng' (do promise.Monad [[counters documentation] instance] @@ -202,7 +202,7 @@ (do macro.Monad [defs (macro.exports module-name)] (wrap (|> defs - (list/map (function [[def-name [_ def-anns _]]] + (list/map (function (_ [def-name [_ def-anns _]]) (case (macro.get-text-ann (ident-for #..test) def-anns) (#.Some description) [true module-name def-name description] @@ -224,7 +224,7 @@ list.reverse (monad.map @ exported-tests) (:: @ map list/join))) - #let [tests+ (list/map (function [[module-name test desc]] + #let [tests+ (list/map (function (_ [module-name test desc]) (` [(~ (code.text module-name)) (~ (code.symbol [module-name test])) (~ (code.text desc))])) tests) num-tests (list.size tests+) @@ -233,7 +233,7 @@ ((~! io) (exec ((~! do) (~! promise.Monad) [(~' #let) [(~ g!total-successes) +0 (~ g!total-failures) +0] - (~+ (list/join (list/map (function [group] + (~+ (list/join (list/map (function (_ group) (list (` [(~ g!successes) (~ g!failures)]) (` ((~! run') (list (~+ group)))) (' #let) (` [(~ g!total-successes) (n/+ (~ g!successes) (~ g!total-successes)) (~ g!total-failures) (n/+ (~ g!failures) (~ g!total-failures))]))) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index c17c5693f..4537ba8d5 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -111,7 +111,7 @@ (l.Lexer Duration) (do p.Monad [signed? (l.this? "-") - #let [sign (function [raw] (if signed? (i/* -1 raw) raw))] + #let [sign (function (_ raw) (if signed? (i/* -1 raw) raw))] utc-day (lex-section "D") utc-hour (lex-section "h") utc-minute (lex-section "m") diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index 22d57a06e..018eeb936 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -115,14 +115,14 @@ (def: (find-month months time) (-> (Sequence Nat) duration.Duration [Nat duration.Duration]) (if (duration/>= duration.empty time) - (sequence/fold (function [month-days [current-month time-left]] + (sequence/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (nat-to-int month-days) duration.day)] (if (i/= 0 (duration.query month-duration time-left)) [current-month time-left] [(n/inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)]))) [+0 time] months) - (sequence/fold (function [month-days [current-month time-left]] + (sequence/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (nat-to-int month-days) duration.day)] (if (i/= 0 (duration.query month-duration time-left)) [current-month time-left] diff --git a/stdlib/source/lux/type/abstract.lux b/stdlib/source/lux/type/abstract.lux index d3f3eb118..e537d0b62 100644 --- a/stdlib/source/lux/type/abstract.lux +++ b/stdlib/source/lux/type/abstract.lux @@ -69,7 +69,7 @@ (update@ #.definitions (put down-cast (: Definition [Macro macro-anns (: Macro - (function [tokens] + (function (_ tokens) (case tokens (^ (list value)) (wrap (list (` ((: (All [(~+ type-varsC)] @@ -82,7 +82,7 @@ (update@ #.definitions (put up-cast (: Definition [Macro macro-anns (: Macro - (function [tokens] + (function (_ tokens) (case tokens (^ (list value)) (wrap (list (` ((: (All [(~+ type-varsC)] @@ -92,7 +92,7 @@ _ (macro.fail ($_ text/compose "Wrong syntax for " up-cast)))))]))))]] - (function [compiler] + (function (_ compiler) (#E.Success [(update@ #.modules (put this-module-name this-module) compiler) []])))) @@ -103,7 +103,7 @@ #let [this-module (|> this-module (update@ #.definitions (remove down-cast)) (update@ #.definitions (remove up-cast)))]] - (function [compiler] + (function (_ compiler) (#E.Success [(update@ #.modules (put this-module-name this-module) compiler) []])))) diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux index a28db6058..88a2db2b8 100644 --- a/stdlib/source/lux/type/implicit.lux +++ b/stdlib/source/lux/type/implicit.lux @@ -111,23 +111,23 @@ (def: (prepare-definitions this-module-name definitions) (-> Text (List [Text Definition]) (List [Ident Type])) (|> definitions - (list.filter (function [[name [def-type def-anns def-value]]] + (list.filter (function (_ [name [def-type def-anns def-value]]) (macro.struct? def-anns))) - (list/map (function [[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 (Meta (List [Ident Type])) (do Monad [local-batches macro.locals - #let [total-locals (list/fold (function [[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)) (list/join local-batches))]] (wrap (|> total-locals dict.entries - (list/map (function [[name type]] [["" name] type])))))) + (list/map (function (_ [name type]) [["" name] type])))))) (def: local-structs (Meta (List [Ident Type])) @@ -141,7 +141,7 @@ (do Monad [this-module-name macro.current-module-name imp-mods (macro.imported-modules this-module-name) - export-batches (monad.map @ (function [imp-mod] + export-batches (monad.map @ (function (_ imp-mod) (do @ [exports (macro.exports imp-mod)] (wrap (prepare-definitions imp-mod exports)))) @@ -185,7 +185,7 @@ (-> Type (List Type) Type (Check [])) (do tc.Monad [member-type' (monad.fold tc.Monad - (function [input member] + (function (_ input member) (apply-function-type member input)) member-type input-types)] @@ -202,7 +202,7 @@ (do Monad [compiler macro.get-compiler] (case (|> alts - (list/map (function [[alt-name alt-type]] + (list/map (function (_ [alt-name alt-type]) (case (tc.run context (do tc.Monad [[tvars alt-type] (concrete-type alt-type) @@ -251,7 +251,7 @@ [compiler macro.get-compiler context macro.type-context] (case (|> alts - (list/map (function [[alt-name alt-type]] + (list/map (function (_ [alt-name alt-type]) (case (tc.run context (do tc.Monad [[tvars alt-type] (concrete-type alt-type) diff --git a/stdlib/source/lux/type/object/interface.lux b/stdlib/source/lux/type/object/interface.lux index d7ebb1e8c..9e723548a 100644 --- a/stdlib/source/lux/type/object/interface.lux +++ b/stdlib/source/lux/type/object/interface.lux @@ -104,7 +104,7 @@ g!_extension (code.symbol ["" "_extension"]) g!_args (list/map (|>> product.left nat-to-int %i (format "_") code.local-symbol) (list.enumerate inputs)) - g!destructuring (list/fold (function [_ g!bottom] (` [(~ g!_temp) (~ g!_temp) (~ g!bottom)])) + g!destructuring (list/fold (function (_ _ g!bottom) (` [(~ g!_temp) (~ g!_temp) (~ g!bottom)])) (` [(~ g!_behavior) (~ g!_state) (~ g!_extension)]) (maybe.default g!states (list.tail g!states)))] (` (def: (~+ (csw.export export)) ((~ g!method) (~+ g!_args) (~ g!_object)) @@ -186,7 +186,7 @@ (list.n/range +0) (list/map (|>> (n/* +2) n/inc code.nat (~) #.Bound (`))) (list.zip2 (list.reverse mappings)) - (list/fold (function [[mappingC boundC] genericC] + (list/fold (function (_ [mappingC boundC] genericC) (code.replace boundC mappingC genericC)) typeC)))) @@ -211,7 +211,7 @@ ## Utils (def: (nest ancestors bottom) (-> (List Code) Code Code) - (list/fold (function [[level _] g!bottom] + (list/fold (function (_ [level _] g!bottom) (let [g!_behavior' (code.local-symbol (format "_behavior" (%n level))) g!_state' (code.local-symbol (format "_state" (%n level)))] (` [(~ g!_behavior') (~ g!_state') (~ g!bottom)]))) @@ -465,9 +465,9 @@ g!parent-structs (if (no-parent? parent) (list) (list/map (|>> (product.both id structN) code.symbol) (list& parent ancestors)))] - g!parent-inits (monad.map @ (function [_] (macro.gensym "parent-init")) + g!parent-inits (monad.map @ (function (_ _) (macro.gensym "parent-init")) g!parent-structs) - #let [g!full-init (list/fold (function [[parent-struct parent-state] child] + #let [g!full-init (list/fold (function (_ [parent-struct parent-state] child) (` [(~ parent-struct) (~ parent-state) (~ child)])) (` [(~ g!struct) (~ g!init) []]) (list.zip2 g!parent-structs g!parent-inits)) diff --git a/stdlib/source/lux/type/object/protocol.lux b/stdlib/source/lux/type/object/protocol.lux index b19c1b203..f9a5158da 100644 --- a/stdlib/source/lux/type/object/protocol.lux +++ b/stdlib/source/lux/type/object/protocol.lux @@ -32,7 +32,7 @@ (-> (Class s lp) (Class s rp) (Class s (Alt lp rp)))) - (function [input state] + (function (_ input state) (case input (#.Left input) (left input state) @@ -46,7 +46,7 @@ (def: #export (object class init) (All [s p] (-> (Class s p) s (Object p))) (loop [state init] - (function [input] + (function (_ input) (let [[output state'] (class input state)] [output (recur state')])))) diff --git a/stdlib/source/lux/type/refinement.lux b/stdlib/source/lux/type/refinement.lux index 55aa3cdd7..a2058d229 100644 --- a/stdlib/source/lux/type/refinement.lux +++ b/stdlib/source/lux/type/refinement.lux @@ -20,7 +20,7 @@ (All [t] (Ex [r] (-> (Pred t) (-> t (Maybe (Ref t r)))))) - (function [un-refined] + (function (_ un-refined) (if (predicate un-refined) (#.Some (@abstraction {#value un-refined #predicate predicate})) @@ -39,7 +39,7 @@ (All [t r] (-> (-> t t) (-> (Ref t r) (Maybe (Ref t r))))) - (function [refined] + (function (_ refined) (let [[value predicate] (@representation refined) value' (transform value)] (if (predicate value') diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux index 9045b2291..7de8fddf5 100644 --- a/stdlib/source/lux/type/resource.lux +++ b/stdlib/source/lux/type/resource.lux @@ -37,11 +37,11 @@ (All [m] (-> (Monad m) (IxMonad (Procedure m)))) (def: (wrap value) - (function [keys] + (function (_ keys) (:: Monad wrap [keys value]))) (def: (bind f input) - (function [keysI] + (function (_ keysI) (do Monad [[keysT value] (input keysI)] ((f value) keysT))))) @@ -59,7 +59,7 @@ (def: #export ( procedure) (All [v] (-> ( v) (Linear v))) - (function [keys] + (function (_ keys) (do [output procedure] (wrap [keys output]))))] @@ -94,7 +94,7 @@ (do-template [ ] [(def: #export ( value) (All [v] (Ex [k] (-> v (Affine (Key k) (Res k v))))) - (function [keys] + (function (_ keys) (:: wrap [[( []) keys] (@abstraction value)])))] [ordered IO io.Monad Ordered ordered-key] @@ -106,7 +106,7 @@ [(def: #export ( resource) (All [v k m] (-> (Res k v) (Relevant (Key m k) v))) - (function [[key keys]] + (function (_ [key keys]) (:: wrap [keys (@representation resource)])))] [read IO io.Monad] @@ -133,11 +133,11 @@ (def: (no-op Monad) (All [m] (-> (Monad m) (Linear m Unit))) - (function [context] (:: Monad wrap [context []]))) + (function (_ context) (:: Monad wrap [context []]))) (do-template [ ] [(syntax: #export ( [swaps ..indices]) - (macro.with-gensyms [g!context] + (macro.with-gensyms [g!_ g!context] (case swaps #.Nil (wrap (list (` ((~! no-op) )))) @@ -147,7 +147,7 @@ [#let [max-idx (list/fold n/max head tail)] g!inputs (<| (monad.seq @) (list.repeat (n/inc max-idx)) (macro.gensym "input")) #let [g!outputs (|> (monad.fold maybe.Monad - (function [from to] + (function (_ from to) (do maybe.Monad [input (list.nth from g!inputs)] (wrap (sequence.add input to)))) @@ -162,7 +162,7 @@ [(~+ g!inputsT+) (~ g!context)] [(~+ g!outputsT+) (~ g!context)] Unit)) - (function [[(~+ g!inputs) (~ g!context)]] + (function ((~ g!_) [(~+ g!inputs) (~ g!context)]) (:: (~! ) (~' wrap) [[(~+ g!outputs) (~ g!context)] []]))))))))))] [exchange IO io.Monad] @@ -178,7 +178,7 @@ (do-template [ ] [(syntax: #export ( [amount amount]) - (macro.with-gensyms [g!context] + (macro.with-gensyms [g!_ g!context] (do macro.Monad [g!keys (<| (monad.seq @) (list.repeat amount) (macro.gensym "keys"))] (wrap (list (` (: (All [(~+ g!keys) (~ g!context)] @@ -186,7 +186,7 @@ [ (~ g!context)] [ (~ g!context)] Unit)) - (function [[ (~ g!context)]] + (function ((~ g!_) [ (~ g!context)]) (:: (~! ) (~' wrap) [[ (~ g!context)] []])))))))))] [group IO io.Monad (~+ g!keys) [(~+ g!keys)]] diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux index e8092a4e6..7bbaf93b4 100644 --- a/stdlib/source/lux/type/unit.lux +++ b/stdlib/source/lux/type/unit.lux @@ -118,7 +118,7 @@ (def: #export (u// param subject) (All [p s] (-> (Qty p) (Qty s) (|> (Qty s) (Per (Qty p))))) - (function [input] + (function (_ input) (|> (out subject) (i/* (out input)) (i// (out param)) @@ -126,7 +126,7 @@ (def: #export (u/* param subject) (All [p s] (-> (Qty p) (Qty s) (Product (Qty p) (Qty s)))) - (function [input] + (function (_ input) (|> subject out (i/* (out (input param))) diff --git a/stdlib/source/lux/world/net/tcp.jvm.lux b/stdlib/source/lux/world/net/tcp.jvm.lux index e551e995d..e32502e87 100644 --- a/stdlib/source/lux/world/net/tcp.jvm.lux +++ b/stdlib/source/lux/world/net/tcp.jvm.lux @@ -92,7 +92,7 @@ [server (ServerSocket::new [(nat-to-int port)]) #let [signal (: (Promise Unit) (promise #.None)) - _ (promise.await (function [_] + _ (promise.await (function (_ _) (AutoCloseable::close [] server)) signal) output (: (frp.Channel TCP) diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index 5f7245d0f..48af98a6f 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -20,7 +20,7 @@ (All [a] (-> (Channel a) (IO (Atom (List a))))) (do io.Monad [#let [output (atom (list))] - _ (frp.listen (function [value] + _ (frp.listen (function (_ value) ## TODO: Simplify when possible. (do @ [_ (atom.update (|>> (#.Cons value)) output)] diff --git a/stdlib/test/test/lux/concurrency/semaphore.lux b/stdlib/test/test/lux/concurrency/semaphore.lux index 59a9618fa..a41f06096 100644 --- a/stdlib/test/test/lux/concurrency/semaphore.lux +++ b/stdlib/test/test/lux/concurrency/semaphore.lux @@ -123,7 +123,7 @@ ($_ seq (wrap (do promise.Monad [#let [ids (list.n/range +0 (n/dec limit)) - waiters (list/map (function [id] + waiters (list/map (function (_ id) (let [process (waiter resource barrier id)] (exec (io.run (atom.update (|>> (format "_")) resource)) process))) @@ -132,7 +132,7 @@ #let [outcome (io.run (atom.read resource))]] (assert "A barrier can stop all processes from acting, until an amount of waiting processes is reached, and then the barrier is un-blocked for all." (and (text.ends-with? "__________" outcome) - (list.every? (function [id] + (list.every? (function (_ id) (text.contains? (%n id) outcome)) ids) ))))))) diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux index d7764dfa2..58c0d7ef3 100644 --- a/stdlib/test/test/lux/concurrency/stm.lux +++ b/stdlib/test/test/lux/concurrency/stm.lux @@ -17,7 +17,7 @@ (All [a] (-> (Channel a) (IO (Atom (List a))))) (do io.Monad [#let [output (atom (list))] - _ (frp.listen (function [value] + _ (frp.listen (function (_ value) ## TODO: Simplify when possible. (do @ [_ (atom.update (|>> (#.Cons value)) output)] @@ -60,8 +60,8 @@ (wrap (let [_concurrency-var (&.var 0)] (do promise.Monad [_ (M.seq @ - (map (function [_] - (M.map @ (function [_] (&.commit (&.update i/inc _concurrency-var))) + (map (function (_ _) + (M.map @ (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/control/cont.lux b/stdlib/test/test/lux/control/cont.lux index 1b9a165ff..7afc84fc2 100644 --- a/stdlib/test/test/lux/control/cont.lux +++ b/stdlib/test/test/lux/control/cont.lux @@ -37,7 +37,7 @@ (n/= (n/* +2 sample) (&.run (do &.Monad [value (&.call/cc - (function [k] + (function (_ k) (do @ [temp (k sample)] ## If this code where to run, @@ -59,14 +59,14 @@ (^open "L/") (list.Eq number.Eq) visit (: (-> (List Nat) (&.Cont (List Nat) (List Nat))) - (function visit [xs] + (function (visit xs) (case xs #.Nil (&/wrap #.Nil) (#.Cons x xs') (do &.Monad - [output (&.shift (function [k] + [output (&.shift (function (_ k) (do @ [tail (k xs')] (wrap (#.Cons x tail)))))] diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux index 0da875e29..d6a879d75 100644 --- a/stdlib/test/test/lux/control/exception.lux +++ b/stdlib/test/test/lux/control/exception.lux @@ -42,8 +42,8 @@ (if should-throw? (&.throw this-ex []) (&.return default-val))) - (&.catch Some-Exception (function [ex] some-val)) - (&.catch Another-Exception (function [ex] another-val)) - (&.otherwise (function [ex] otherwise-val)))]] + (&.catch Some-Exception (function (_ ex) some-val)) + (&.catch Another-Exception (function (_ ex) another-val)) + (&.otherwise (function (_ ex) otherwise-val)))]] (test "Catch and otherwhise handlers can properly handle the flow of exception-handling." (n/= expected actual))))) diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux index 98344fac9..b0c9c14ac 100644 --- a/stdlib/test/test/lux/control/region.lux +++ b/stdlib/test/test/lux/control/region.lux @@ -33,7 +33,7 @@ (do thread.Monad [clean-up-counter (thread.box +0) #let [@@ @ - count-clean-up (function [value] + count-clean-up (function (_ value) (do @ [_ (thread.update n/inc clean-up-counter)] (wrap (#e.Success []))))] @@ -51,7 +51,7 @@ (do thread.Monad [clean-up-counter (thread.box +0) #let [@@ @ - count-clean-up (function [value] + count-clean-up (function (_ value) (do @ [_ (thread.update n/inc clean-up-counter)] (wrap (#e.Success []))))] @@ -70,7 +70,7 @@ (do thread.Monad [clean-up-counter (thread.box +0) #let [@@ @ - count-clean-up (function [value] + count-clean-up (function (_ value) (do @ [_ (thread.update n/inc clean-up-counter)] (wrap (: (Error Unit) (ex.throw Oops [])))))] diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux index 289e7e988..729f84221 100644 --- a/stdlib/test/test/lux/data/coll/array.lux +++ b/stdlib/test/test/lux/data/coll/array.lux @@ -37,7 +37,7 @@ (not (is? original copy))))) (test "Array folding should go over all values." (exec (:: @.Fold fold - (function [x idx] + (function (_ x idx) (exec (@.write idx x manual-copy) (n/inc idx))) +0 @@ -89,7 +89,7 @@ (case> (#.Some _) true #.None false))) (test "Can find values inside arrays (with access to indices)." - (|> (@.find+ (function [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 d2dcd93a1..01074b6fc 100644 --- a/stdlib/test/test/lux/data/coll/dict.lux +++ b/stdlib/test/test/lux/data/coll/dict.lux @@ -18,8 +18,8 @@ [#let [capped-nat (:: r.Monad map (n/% +100) r.nat)] size capped-nat dict (r.dict number.Hash size r.nat capped-nat) - non-key (|> r.nat (r.filter (function [key] (not (&.contains? key dict))))) - test-val (|> r.nat (r.filter (function [val] (not (list.member? number.Eq (&.values dict) val)))))] + non-key (|> r.nat (r.filter (function (_ key) (not (&.contains? key dict))))) + test-val (|> r.nat (r.filter (function (_ val) (not (list.member? number.Eq (&.values dict) val)))))] ($_ seq (test "Size function should correctly represent Dict size." (n/= size (&.size dict))) @@ -36,13 +36,13 @@ (&.values dict)))) (test "Dict should be able to recognize it's own keys." - (list.every? (function [key] (&.contains? key dict)) + (list.every? (function (_ key) (&.contains? key dict)) (&.keys dict))) (test "Should be able to get every key." - (list.every? (function [key] (case (&.get key dict) - (#.Some _) true - _ false)) + (list.every? (function (_ key) (case (&.get key dict) + (#.Some _) true + _ false)) (&.keys dict))) (test "Shouldn't be able to access non-existant keys." @@ -99,13 +99,13 @@ (test "If you merge, and the second dict has overlapping keys, it should overwrite yours." (let [dict' (|> dict &.entries - (list/map (function [[k v]] [k (n/inc v)])) + (list/map (function (_ [k v]) [k (n/inc v)])) (&.from-list number.Hash)) (^open) (&.Eq number.Eq)] (= dict' (&.merge dict' dict)))) (test "Can merge values in such a way that they become combined." - (list.every? (function [[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 281f8b459..ebc650df6 100644 --- a/stdlib/test/test/lux/data/coll/list.lux +++ b/stdlib/test/test/lux/data/coll/list.lux @@ -199,7 +199,7 @@ (test "You can iteratively construct a list, generating values until you're done." (= (&.n/range +0 (n/dec size)) - (&.iterate (function [n] (if (n/< size n) (#.Some (n/inc n)) #.None)) + (&.iterate (function (_ n) (if (n/< size n) (#.Some (n/inc n)) #.None)) +0))) (test "Can enumerate all elements in a list." @@ -210,14 +210,15 @@ (&/map product.right enum-sample))))) )))) -(context: "Monad transformer" - (let [lift (&.lift io.Monad) - (^open "io/") io.Monad] - (test "Can add list functionality to any monad." - (|> (io.run (do (&.ListT io.Monad) - [a (lift (io/wrap 123)) - b (wrap 456)] - (wrap (i/+ a b)))) - (case> (^ (list 579)) true - _ false))) - )) +## TODO: Add again once new-luxc becomes the standard compiler. +## (context: "Monad transformer" +## (let [lift (&.lift io.Monad) +## (^open "io/") io.Monad] +## (test "Can add list functionality to any monad." +## (|> (io.run (do (&.ListT io.Monad) +## [a (lift (io/wrap 123)) +## b (wrap 456)] +## (wrap (i/+ a b)))) +## (case> (^ (list 579)) true +## _ false))) +## )) diff --git a/stdlib/test/test/lux/data/coll/ordered/dict.lux b/stdlib/test/test/lux/data/coll/ordered/dict.lux index dc4adca7c..975b26dd2 100644 --- a/stdlib/test/test/lux/data/coll/ordered/dict.lux +++ b/stdlib/test/test/lux/data/coll/ordered/dict.lux @@ -23,7 +23,7 @@ #let [pairs (list.zip2 (s.to-list keys) (s.to-list values)) sample (&.from-list number.Order pairs) - sorted-pairs (list.sort (function [[left _] [right _]] + sorted-pairs (list.sort (function (_ [left _] [right _]) (n/< left right)) pairs) sorted-values (L/map product.right sorted-pairs) @@ -61,14 +61,14 @@ (test "Order is preserved." (let [(^open "L/") (list.Eq (: (Eq [Nat Nat]) - (function [[kr vr] [ks vs]] + (function (_ [kr vr] [ks vs]) (and (n/= kr ks) (n/= vr vs)))))] (L/= (&.entries sample) sorted-pairs))) (test "Every key in a dictionary must be identifiable." - (list.every? (function [key] (&.contains? key sample)) + (list.every? (function (_ key) (&.contains? key sample)) (&.keys sample))) (test "Can add and remove elements in a dictionary." diff --git a/stdlib/test/test/lux/data/coll/priority-queue.lux b/stdlib/test/test/lux/data/coll/priority-queue.lux index 6c7fac180..00238dc63 100644 --- a/stdlib/test/test/lux/data/coll/priority-queue.lux +++ b/stdlib/test/test/lux/data/coll/priority-queue.lux @@ -12,7 +12,7 @@ (-> Nat (r.Random (&.Queue Nat))) (do r.Monad [inputs (r.list size r.nat)] - (monad.fold @ (function [head tail] + (monad.fold @ (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 f7beb55bf..1fe325782 100644 --- a/stdlib/test/test/lux/data/coll/stream.lux +++ b/stdlib/test/test/lux/data/coll/stream.lux @@ -89,7 +89,7 @@ (List/= (&.take size (&/map Nat/encode (&.iterate n/inc offset))) (&.take size - (&.unfold (function [n] [(n/inc n) (Nat/encode n)]) + (&.unfold (function (_ n) [(n/inc n) (Nat/encode n)]) offset))))) (test "Can cycle over the same elements as an infinite stream." diff --git a/stdlib/test/test/lux/data/coll/tree/rose.lux b/stdlib/test/test/lux/data/coll/tree/rose.lux index 4ff1c9ea3..1bf29d533 100644 --- a/stdlib/test/test/lux/data/coll/tree/rose.lux +++ b/stdlib/test/test/lux/data/coll/tree/rose.lux @@ -14,7 +14,7 @@ (def: gen-tree (r.Random [Nat (&.Tree Nat)]) (r.rec - (function [gen-tree] + (function (_ gen-tree) (r.either (:: r.Monad map (|>> &.leaf [+1]) r.nat) (do r.Monad [value r.nat @@ -32,7 +32,7 @@ [[size sample] gen-tree #let [(^open "&/") (&.Eq number.Eq) (^open "&/") &.Fold - concat (function [addition partial] (format partial (%n addition)))]] + concat (function (_ addition partial) (format partial (%n addition)))]] ($_ seq (test "Can compare trees for equality." (&/= sample sample)) diff --git a/stdlib/test/test/lux/data/coll/tree/zipper.lux b/stdlib/test/test/lux/data/coll/tree/zipper.lux index 831cc9573..7b182a918 100644 --- a/stdlib/test/test/lux/data/coll/tree/zipper.lux +++ b/stdlib/test/test/lux/data/coll/tree/zipper.lux @@ -15,7 +15,7 @@ (def: gen-tree (r.Random (rose.Tree Nat)) - (r.rec (function [gen-tree] + (r.rec (function (_ gen-tree) (do r.Monad ## Each branch can have, at most, 1 child. [size (|> r.nat (:: @ map (n/% +2)))] diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux index 29081715b..b9290ed19 100644 --- a/stdlib/test/test/lux/data/color.lux +++ b/stdlib/test/test/lux/data/color.lux @@ -48,11 +48,11 @@ (do @ [any color colorful (|> color - (r.filter (function [color] (|> (distance color black) (f/>= 100.0)))) - (r.filter (function [color] (|> (distance color white) (f/>= 100.0))))) + (r.filter (function (_ color) (|> (distance color black) (f/>= 100.0)))) + (r.filter (function (_ color) (|> (distance color white) (f/>= 100.0))))) mediocre (|> color (r.filter (|>> saturation - ((function [saturation] + ((function (_ saturation) (and (f/>= 0.25 saturation) (f/<= 0.75 saturation))))))) ratio (|> r.frac (r.filter (f/>= 0.5)))] diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index d5d863514..eec53b9cc 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -35,7 +35,7 @@ (def: gen-json (r.Random @.JSON) - (r.rec (function [gen-json] + (r.rec (function (_ gen-json) (do r.Monad [size (:: @ map (n/% +2) r.nat)] ($_ r.alt @@ -94,7 +94,7 @@ (def: gen-recursive (r.Random Recursive) - (r.rec (function [gen-recursive] + (r.rec (function (_ gen-recursive) (r.alt r.frac (r.seq r.frac gen-recursive))))) @@ -129,7 +129,7 @@ (struct: _ (Eq Record) (def: (= recL recR) - (let [variant/= (function [left right] + (let [variant/= (function (_ left right) (case [left right] [(#Case0 left') (#Case0 right')] (:: bool.Eq = left' right') @@ -162,7 +162,8 @@ )))) (context: "Polytypism" - (<| (times +100) + (<| (seed +14562075782602945288) + ## (times +100) (do @ [sample gen-record #let [(^open "@/") Eq diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux index fa8b719ca..ed337a0b7 100644 --- a/stdlib/test/test/lux/data/format/xml.lux +++ b/stdlib/test/test/lux/data/format/xml.lux @@ -46,7 +46,7 @@ (def: gen-xml (r.Random &.XML) - (r.rec (function [gen-xml] + (r.rec (function (_ gen-xml) (r.alt (xml-text^ +1 +10) (do r.Monad [size (size^ +0 +2)] diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 0f14bee64..3ba7db2c2 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -81,11 +81,11 @@ (test "" (and (<= x (:: bottom)) (>= x (:: top)))))))] - ["Nat" r.nat Number Order Interval (function [_] true)] - ["Int" r.int Number Order Interval (function [_] true)] + ["Nat" r.nat Number Order Interval (function (_ _) true)] + ["Int" r.int Number Order Interval (function (_ _) true)] ## Both min and max values will be positive (thus, greater than zero) ["Frac" r.frac Number Order Interval (f/> 0.0)] - ["Deg" r.deg Number Order Interval (function [_] true)] + ["Deg" r.deg Number Order Interval (function (_ _) true)] ) (do-template [category rand-gen ] @@ -101,22 +101,22 @@ (= x (compose x identity)) (= identity (compose identity identity)))))))] - ["Nat/Add" r.nat Number Order Add@Monoid (n/% +1000) (function [_] true)] - ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% +1000) (function [_] true)] - ["Nat/Min" r.nat Number Order Min@Monoid (n/% +1000) (function [_] true)] - ["Nat/Max" r.nat Number Order Max@Monoid (n/% +1000) (function [_] true)] - ["Int/Add" r.int Number Order Add@Monoid (i/% 1000) (function [_] true)] - ["Int/Mul" r.int Number Order Mul@Monoid (i/% 1000) (function [_] true)] - ["Int/Min" r.int Number Order Min@Monoid (i/% 1000) (function [_] true)] - ["Int/Max" r.int Number Order Max@Monoid (i/% 1000) (function [_] true)] + ["Nat/Add" r.nat Number Order Add@Monoid (n/% +1000) (function (_ _) true)] + ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% +1000) (function (_ _) true)] + ["Nat/Min" r.nat Number Order Min@Monoid (n/% +1000) (function (_ _) true)] + ["Nat/Max" r.nat Number Order Max@Monoid (n/% +1000) (function (_ _) true)] + ["Int/Add" r.int Number Order Add@Monoid (i/% 1000) (function (_ _) true)] + ["Int/Mul" r.int Number Order Mul@Monoid (i/% 1000) (function (_ _) true)] + ["Int/Min" r.int Number Order Min@Monoid (i/% 1000) (function (_ _) true)] + ["Int/Max" r.int Number Order Max@Monoid (i/% 1000) (function (_ _) true)] ["Frac/Add" r.frac Number Order Add@Monoid (f/% 1000.0) (f/> 0.0)] ["Frac/Mul" r.frac Number Order Mul@Monoid (f/% 1000.0) (f/> 0.0)] ["Frac/Min" r.frac Number Order Min@Monoid (f/% 1000.0) (f/> 0.0)] ["Frac/Max" r.frac Number Order Max@Monoid (f/% 1000.0) (f/> 0.0)] - ["Deg/Add" r.deg Number Order Add@Monoid (d/% .125) (function [_] true)] - ## ["Deg/Mul" r.deg Number Order Mul@Monoid (d/% .125) (function [_] true)] - ["Deg/Min" r.deg Number Order Min@Monoid (d/% .125) (function [_] true)] - ["Deg/Max" r.deg Number Order Max@Monoid (d/% .125) (function [_] true)] + ["Deg/Add" r.deg Number Order Add@Monoid (d/% .125) (function (_ _) true)] + ## ["Deg/Mul" r.deg Number Order Mul@Monoid (d/% .125) (function (_ _) true)] + ["Deg/Min" r.deg Number Order Min@Monoid (d/% .125) (function (_ _) true)] + ["Deg/Max" r.deg Number Order Max@Monoid (d/% .125) (function (_ _) true)] ) (do-template [ ] diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index 367c010de..de33a9f64 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -28,10 +28,10 @@ (list (+0 "0") (+1 "1") (+0 "2")))))))) (test "Can apply a function to an Either value depending on the case." - (and (i/= 10 (either (function [_] 10) - (function [_] 20) + (and (i/= 10 (either (function (_ _) 10) + (function (_ _) 20) (: (| Text Text) (+0 "")))) - (i/= 20 (either (function [_] 10) - (function [_] 20) + (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 7cf084158..8706e2f2e 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -187,9 +187,9 @@ (test "Can lex using arbitrary predicates." (and (should-passT "D" (&.run "D" - (&.satisfies (function [c] true)))) + (&.satisfies (function (_ c) true)))) (should-fail (&.run "C" - (&.satisfies (function [c] false)))))) + (&.satisfies (function (_ c) false)))))) (test "Can apply a lexer multiple times." (and (should-passT "0123456789ABCDEF" (&.run "0123456789ABCDEF" diff --git a/stdlib/test/test/lux/lang/syntax.lux b/stdlib/test/test/lux/lang/syntax.lux index 47d46f0b4..2b4d6789f 100644 --- a/stdlib/test/test/lux/lang/syntax.lux +++ b/stdlib/test/test/lux/lang/syntax.lux @@ -29,7 +29,7 @@ invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% +256) (n/max +1))) - (r.filter (function [sample] + (r.filter (function (_ sample) (not (text.contains? (text.from-code sample) invalid-range)))))] size (|> r.nat (:: @ map (|>> (n/% +20) (n/max +1))))] @@ -60,7 +60,7 @@ numeric^ textual^))] (r.rec - (function [code^] + (function (_ code^) (let [multi^ (do r.Monad [size (|> r.nat (r/map (n/% +3)))] (r.list size code^)) @@ -145,7 +145,7 @@ (def: comment-text^ (r.Random Text) - (let [char-gen (|> r.nat (r.filter (function [value] + (let [char-gen (|> r.nat (r.filter (function (_ value) (not (or (text.space? value) (n/= (char "#") value) (n/= (char "(") value) @@ -159,7 +159,7 @@ (r.either (do r.Monad [comment comment-text^] (wrap (format "## " comment "\n"))) - (r.rec (function [nested^] + (r.rec (function (_ nested^) (do r.Monad [comment (r.either comment-text^ nested^)] @@ -168,7 +168,7 @@ (context: "Multi-line text & comments." (<| (times +100) (do @ - [#let [char-gen (|> r.nat (r.filter (function [value] + [#let [char-gen (|> r.nat (r.filter (function (_ value) (not (or (text.space? value) (n/= (char "\"") value))))))] x char-gen diff --git a/stdlib/test/test/lux/lang/type.lux b/stdlib/test/test/lux/lang/type.lux index 3adc4d43d..113d279ee 100644 --- a/stdlib/test/test/lux/lang/type.lux +++ b/stdlib/test/test/lux/lang/type.lux @@ -26,7 +26,7 @@ (def: gen-type (r.Random Type) (let [(^open "R/") r.Monad] - (r.rec (function [gen-type] + (r.rec (function (_ gen-type) ($_ r.alt (r.seq gen-name (R/wrap (list))) (R/wrap []) @@ -85,7 +85,7 @@ (do @ [size (|> r.nat (:: @ map (n/% +3))) members (|> gen-type - (r.filter (function [type] + (r.filter (function (_ type) (case type (^or (#.Sum _) (#.Product _)) false @@ -117,7 +117,7 @@ [size (|> r.nat (:: @ map (n/% +3))) members (M.seq @ (list.repeat size gen-type)) extra (|> gen-type - (r.filter (function [type] + (r.filter (function (_ type) (case type (^or (#.Function _) (#.Apply _)) false @@ -142,7 +142,7 @@ (do @ [size (|> r.nat (:: @ map (n/% +3))) extra (|> gen-type - (r.filter (function [type] + (r.filter (function (_ type) (case type (^or (#.UnivQ _) (#.ExQ _)) false diff --git a/stdlib/test/test/lux/lang/type/check.lux b/stdlib/test/test/lux/lang/type/check.lux index d63444b52..dd42ceaf4 100644 --- a/stdlib/test/test/lux/lang/type/check.lux +++ b/stdlib/test/test/lux/lang/type/check.lux @@ -29,7 +29,7 @@ (def: gen-type (r.Random Type) (let [(^open "r/") r.Monad] - (r.rec (function [gen-type] + (r.rec (function (_ gen-type) ($_ r.alt (r.seq gen-name (r/wrap (list))) (r/wrap []) @@ -195,7 +195,7 @@ (do @.Monad [[head-id head-type] @.var ids+types (monad.seq @ (list.repeat num-connections @.var)) - [tail-id tail-type] (monad.fold @ (function [[tail-id tail-type] [_head-id _head-type]] + [tail-id tail-type] (monad.fold @ (function (_ [tail-id tail-type] [_head-id _head-type]) (do @ [_ (@.check head-type tail-type)] (wrap [tail-id tail-type]))) @@ -237,7 +237,7 @@ (let [rings-were-erased? (and (set.empty? headR) (list.every? set.empty? tailR+)) same-types? (list.every? (type/= boundT) (list& (maybe.default headT head-bound) - (list/map (function [[tail-id ?tailT]] + (list/map (function (_ [tail-id ?tailT]) (maybe.default (#.Var tail-id) ?tailT)) (list.zip2 ids tail-bound))))] (@.assert "" diff --git a/stdlib/test/test/lux/macro/poly/eq.lux b/stdlib/test/test/lux/macro/poly/eq.lux index 8867732c0..4605de5d2 100644 --- a/stdlib/test/test/lux/macro/poly/eq.lux +++ b/stdlib/test/test/lux/macro/poly/eq.lux @@ -39,7 +39,7 @@ (def: gen-recursive (r.Random Recursive) - (r.rec (function [gen-recursive] + (r.rec (function (_ gen-recursive) (r.alt r.frac (r.seq r.frac gen-recursive))))) diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index 1adc737a4..7bb684695 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -38,7 +38,7 @@ (-> (-> (/.Mod m) (/.Mod m) Bool) (-> Int Int Bool) (-> (/.Mod m) (/.Mod m) Bool))) - (function [param subject] + (function (_ param subject) (bool/= (m/? param subject) (i/? (value param) (value subject))))) @@ -49,7 +49,7 @@ (-> (/.Mod m) (/.Mod m) (/.Mod m)) (-> Int Int Int) (-> (/.Mod m) (/.Mod m) Bool))) - (function [param subject] + (function (_ param subject) (|> (i/! (value param) (value subject)) (/.mod modulus) diff --git a/stdlib/test/test/lux/type/object/protocol.lux b/stdlib/test/test/lux/type/object/protocol.lux index 2017459bd..d6596950b 100644 --- a/stdlib/test/test/lux/type/object/protocol.lux +++ b/stdlib/test/test/lux/type/object/protocol.lux @@ -28,7 +28,7 @@ (def: object0 Object0 (loop [num-calls +0] - (function [message] + (function (_ message) [(case message (#method0 [arg0 arg1 arg2] output) (output (n/= +0 (n/% +2 num-calls))) diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux index 8d40897d7..892f6ddc4 100644 --- a/stdlib/test/test/lux/world/net/tcp.lux +++ b/stdlib/test/test/lux/world/net/tcp.lux @@ -38,7 +38,7 @@ [[server-close server] (@.server port) #let [from-worked? (: (T.Task Bool) (P.promise #.Nil)) - _ (frp/map (function [socket] + _ (frp/map (function (_ socket) (do @ [bytes-from (@.read temp-from +0 size socket) #let [_ (io.run (P.resolve (#E.Success (and (n/= size bytes-from) -- cgit v1.2.3