diff options
Diffstat (limited to 'stdlib/source/library/lux/control')
36 files changed, 254 insertions, 236 deletions
diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index de474236a..9cc286c29 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -30,8 +30,9 @@ [Text Code]) (type: Stack - {#bottom (Maybe Nat) - #top (List Code)}) + (Record + {#bottom (Maybe Nat) + #top (List Code)})) (def: aliases^ (Parser (List Alias)) @@ -48,7 +49,7 @@ (Parser Stack) (<>.either (<>.and (<>.maybe bottom^) (<code>.tuple (<>.some <code>.any))) - (<>.and (|> bottom^ (<>\map (|>> #.Some))) + (<>.and (|> bottom^ (<>\each (|>> #.Some))) (<>\in (list))))) (def: (stack_mix tops bottom) @@ -68,7 +69,7 @@ _ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line - (|> expansion (list\map %.code) (text.interposed " "))))))) + (|> expansion (list\each %.code) (text.interposed " "))))))) (syntax: .public (=> [aliases aliases^ inputs stack^ @@ -78,8 +79,8 @@ (code.replaced (code.local_identifier from) to pre)) aliased aliases))] - (case [(|> inputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`)))) - (|> outputs (value@ #bottom) (maybe\map (|>> code.nat (~) #.Parameter (`))))] + (case [(|> inputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`)))) + (|> outputs (value@ #bottom) (maybe\each (|>> code.nat (~) #.Parameter (`))))] [(#.Some bottomI) (#.Some bottomO)] (monad.do meta.monad [inputC (singleton (macro.full_expansion (stack_mix (value@ #top inputs) bottomI))) diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 0e248ff9b..f7f5644d3 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -56,7 +56,7 @@ [current (async.value read)] (case current (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (pending tail)) #.None @@ -65,9 +65,10 @@ (abstract: .public (Actor s) {} - {#obituary [(Async <Obituary>) - (Resolver <Obituary>)] - #mailbox (Atom <Mailbox>)} + (Record + {#obituary [(Async <Obituary>) + (Resolver <Obituary>)] + #mailbox (Atom <Mailbox>)}) (type: .public (Mail s) <Mail>) @@ -76,8 +77,9 @@ <Obituary>) (type: .public (Behavior o s) - {#on_init (-> o s) - #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) + (Record + {#on_init (-> o s) + #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))})) (def: .public (spawn! behavior init) (All [o s] (-> (Behavior o s) o (IO (Actor s)))) @@ -112,7 +114,7 @@ (let [[obituary _] (value@ #obituary (:representation actor))] (|> obituary async.value - (\ io.functor map + (\ io.functor each (|>> (case> #.None bit.yes @@ -263,7 +265,7 @@ (do meta.monad [g!type (macro.identifier (format name "_abstract_type")) .let [g!actor (code.local_identifier name) - g!vars (list\map code.local_identifier vars)]] + g!vars (list\each code.local_identifier vars)]] (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) {} @@ -288,11 +290,12 @@ (~ init))))))))) (type: Signature - {#vars (List Text) - #name Text - #inputs (List |input|.Input) - #state Text - #self Text}) + (Record + {#vars (List Text) + #name Text + #inputs (List |input|.Input) + #state Text + #self Text})) (def: signature^ (Parser Signature) @@ -326,9 +329,9 @@ .let [g!type (code.local_identifier (value@ #abstract.name actor_scope)) g!message (code.local_identifier (value@ #name signature)) g!actor_vars (value@ #abstract.type_vars actor_scope) - g!all_vars (|> signature (value@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) - g!inputsC (|> signature (value@ #inputs) (list\map product.left)) - g!inputsT (|> signature (value@ #inputs) (list\map product.right)) + g!all_vars (|> signature (value@ #vars) (list\each code.local_identifier) (list\composite g!actor_vars)) + g!inputsC (|> signature (value@ #inputs) (list\each product.left)) + g!inputsT (|> signature (value@ #inputs) (list\each product.right)) g!state (|> signature (value@ #state) code.local_identifier) g!self (|> signature (value@ #self) code.local_identifier)]] (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) @@ -365,6 +368,6 @@ (if continue? (|> actor (..mail! (action event stop)) - (\ ! map try.maybe)) + (\ ! each try.maybe)) (in #.None)))) channel))) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index bdd852ffc..c996e1dcc 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -42,8 +42,8 @@ succeeded? (atom.compare_and_swap! old new async)] (if succeeded? (do ! - [_ (monad.map ! (function (_ f) (f value)) - _observers)] + [_ (monad.each ! (function (_ f) (f value)) + _observers)] (in #1)) (resolve value)))))))) @@ -60,7 +60,7 @@ (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read! - (\ io.functor map product.left))) + (\ io.functor each product.left))) (def: .public (upon! f async) (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) @@ -83,7 +83,7 @@ (def: .public resolved? (All [a] (-> (Async a) (IO Bit))) (|>> ..value - (\ io.functor map + (\ io.functor each (|>> (case> #.None #0 @@ -93,7 +93,7 @@ (implementation: .public functor (Functor Async) - (def: (map f fa) + (def: (each f fa) (let [[fb resolve] (..async [])] (exec (io.run! (..upon! (|>> f resolve) fa)) @@ -119,7 +119,7 @@ (def: in ..resolved) - (def: (join mma) + (def: (conjoint mma) (let [[ma resolve] (async [])] (exec (io.run! (..upon! (..upon! resolve) mma)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index b6d9461f0..5be4a9059 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -95,4 +95,4 @@ (All [a] (-> a (Atom a) (IO a))) (|> atom (..update! (function.constant value)) - (io\map product.left))) + (io\each product.left))) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 1e447ef17..df0ef8160 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -85,11 +85,11 @@ (implementation: .public functor (Functor Channel) - (def: (map f) - (async\map - (maybe\map + (def: (each f) + (async\each + (maybe\each (function (_ [head tail]) - [(f head) (map f tail)]))))) + [(f head) (each f tail)]))))) (implementation: .public apply (Apply Channel) @@ -119,7 +119,7 @@ (def: (in a) (async.resolved (#.Some [a ..empty]))) - (def: (join mma) + (def: (conjoint mma) (let [[output sink] (channel [])] (exec (: (Async Any) @@ -185,9 +185,9 @@ (def: .public (of_async async) (All [a] (-> (Async a) (Channel a))) - (async\map (function (_ value) - (#.Some [value ..empty])) - async)) + (async\each (function (_ value) + (#.Some [value ..empty])) + async)) (def: .public (mix f init channel) (All [a b] @@ -276,7 +276,7 @@ [item channel] (case item (#.Some [head tail]) - (\ ! map (|>> (#.Item head)) + (\ ! each (|>> (#.Item head)) (list tail)) #.None diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index e2cdb2aca..8f2378d3d 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -25,9 +25,10 @@ ["." async (#+ Async Resolver)]]) (type: State - {#max_positions Nat - #open_positions Int - #waiting_list (Queue (Resolver Any))}) + (Record + {#max_positions Nat + #open_positions Int + #waiting_list (Queue (Resolver Any))})) (abstract: .public Semaphore {} @@ -130,10 +131,11 @@ (abstract: .public Barrier {} - {#limit Limit - #count (Atom Nat) - #start_turnstile Semaphore - #end_turnstile Semaphore} + (Record + {#limit Limit + #count (Atom Nat) + #start_turnstile Semaphore + #end_turnstile Semaphore}) (def: .public (barrier limit) (-> Limit Barrier) diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 5e9759bdb..cb6a1e702 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -52,16 +52,16 @@ succeeded? (atom.compare_and_swap! old [new_value observers] var')] (if succeeded? (do ! - [_ (monad.map ! (function (_ sink) - (do ! - [result (\ sink feed new_value)] - (case result - (#try.Success _) - (in []) - - (#try.Failure _) - (un_follow! sink var)))) - observers)] + [_ (monad.each ! (function (_ sink) + (do ! + [result (\ sink feed new_value)] + (case result + (#try.Success _) + (in []) + + (#try.Failure _) + (un_follow! sink var)))) + observers)] (in [])) (write! new_value var)))) @@ -76,9 +76,10 @@ ) (type: (Tx_Frame a) - {#var (Var a) - #original a - #current a}) + (Record + {#var (Var a) + #original a + #current a})) (type: Tx (List (Ex [a] (Tx_Frame a)))) @@ -92,8 +93,8 @@ (list.example (function (_ [_var _original _current]) (same? (:as (Var Any) var) (:as (Var Any) _var)))) - (\ maybe.monad map (function (_ [_var _original _current]) - _current)) + (\ maybe.monad each (function (_ [_var _original _current]) + _current)) :expected)) (def: .public (read var) @@ -141,7 +142,7 @@ (implementation: .public functor (Functor STM) - (def: (map f fa) + (def: (each f fa) (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)])))) @@ -166,7 +167,7 @@ (function (_ tx) [tx a])) - (def: (join mma) + (def: (conjoint mma) (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx'))))) @@ -233,7 +234,7 @@ [finished_tx value] (stm_proc fresh_tx)] (if (can_commit? finished_tx) (do {! io.monad} - [_ (monad.map ! ..commit_var! finished_tx)] + [_ (monad.each ! ..commit_var! finished_tx)] (resolve value)) (..issue_commit! commit)))) diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 1011da5bb..d618d7270 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -59,9 +59,10 @@ ... Default (type: Thread - {#creation Nat - #delay Nat - #action (IO Any)}) + (Record + {#creation Nat + #delay Nat + #action (IO Any)})) )) (def: .public parallelism @@ -127,7 +128,7 @@ ... Default (do {! io.monad} - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) _ (atom.update! (|>> (#.Item {#creation now #delay milli_seconds #action action})) @@ -156,7 +157,7 @@ _ (do ! - [now (\ ! map (|>> instant.millis .nat) instant.now) + [now (\ ! each (|>> instant.millis .nat) instant.now) .let [[ready pending] (list.partition (function (_ thread) (|> (value@ #creation thread) (n.+ (value@ #delay thread)) @@ -165,7 +166,7 @@ swapped? (atom.compare_and_swap! threads pending ..runner)] (if swapped? (do ! - [_ (monad.map ! (|>> (value@ #action) ..execute! io.io) ready)] + [_ (monad.each ! (|>> (value@ #action) ..execute! io.io) ready)] (recur [])) (panic! (exception.error ..cannot_continue_running_threads [])))) )))) diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index 15fdc16d1..f56d127c7 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -54,7 +54,7 @@ (implementation: .public functor (All [o] (Functor (All [i] (Cont i o)))) - (def: (map f fv) + (def: (each f fv) (function (_ k) (fv (function.composite k f))))) @@ -77,7 +77,7 @@ (def: (in value) (function (_ k) (k value))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ k) (ffa (continued k))))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index c59767584..cf00522fa 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -27,8 +27,9 @@ ["//" try (#+ Try)]]) (type: .public (Exception a) - {#label Text - #constructor (-> a Text)}) + (Record + {#label Text + #constructor (-> a Text)})) (def: .public (match? exception error) (All [e] (-> (Exception e) Text Bit)) @@ -93,16 +94,16 @@ (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name - .let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) + .let [descriptor ($_ text\composite "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] (in (list (` (def: (~ export_policy) (~ g!self) - (All [(~+ (list\map |type_variable|.format t_vars))] - (..Exception [(~+ (list\map (value@ #|input|.type) inputs))])) + (All [(~+ (list\each |type_variable|.format t_vars))] + (..Exception [(~+ (list\each (value@ #|input|.type) inputs))])) (let [(~ g!descriptor) (~ (code.text descriptor))] {#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\map (value@ #|input|.binding) inputs))]) - ((~! text\compose) (~ g!descriptor) + #..constructor (function ((~ g!self) [(~+ (list\each (value@ #|input|.binding) inputs))]) + ((~! text\composite) (~ g!descriptor) (~ (maybe.else (' "") body))))})))))))) (def: (report' entries) @@ -116,7 +117,7 @@ (list.repeated (n.+ (text.size header_separator) largest_header_size)) text.together - (text\compose text.new_line)) + (text\composite text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " @@ -125,21 +126,21 @@ text.together)] (|> message (text.replaced text.new_line on_new_line) - ($_ text\compose padding header header_separator)))))] + ($_ text\composite padding header header_separator)))))] (case entries #.End "" (#.Item head tail) (list\mix (function (_ post pre) - ($_ text\compose pre text.new_line (on_entry post))) + ($_ text\composite pre text.new_line (on_entry post))) (on_entry head) tail)))) (syntax: .public (report [entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))]) (in (list (` ((~! report') (list (~+ (|> entries - (list\map (function (_ [header message]) - (` [(~ header) (~ message)]))))))))))) + (list\each (function (_ [header message]) + (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) (All [a] diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 11cc82e62..3bbcd1bce 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -31,4 +31,4 @@ (All [a] (Monoid (-> a a))) (def: identity ..identity) - (def: compose ..composite)) + (def: composite ..composite)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 98009b21d..4f5013f77 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -31,7 +31,7 @@ (All [i o] (Monoid (Mixin i o))) (def: identity ..nothing) - (def: compose ..with)) + (def: composite ..with)) (def: .public (advice when then) (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index dd647ce41..3d26dedd1 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -25,9 +25,10 @@ ["." //]) (type: Mutual - {#declaration Declaration - #type Code - #body Code}) + (Record + {#declaration Declaration + #type Code + #body Code})) (.def: mutual (Parser [Declaration Code Code]) @@ -68,35 +69,36 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) - functions) - .let [definitions (list\map (..mutual_definition hidden_names g!context) - (list.zipped/2 hidden_names - functions)) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ #type mutual))))) - functions) - user_names (list\map (|>> (value@ [#declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + functions)) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ #type mutual))))) + functions) + user_names (list\each (|>> (value@ [#declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list (` (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (.let [[(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]) (~ g!output) (~ body)] (exec (~ g!pop) (~ g!output)))))))))) (type: Definition - {#export_policy Code - #mutual Mutual}) + (Record + {#export_policy Code + #mutual Mutual})) (.def: definition (Parser Definition) @@ -119,37 +121,37 @@ (macro.with_identifiers [g!context g!output] (do {! meta.monad} [here_name meta.current_module_name - hidden_names (monad.map ! (//.constant (macro.identifier "mutual_function#")) - functions) - .let [definitions (list\map (..mutual_definition hidden_names g!context) - (list.zipped/2 hidden_names - (list\map (value@ #mutual) functions))) - context_types (list\map (function (_ mutual) - (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) - functions) - user_names (list\map (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) - functions)] - g!pop (local.push (list\map (function (_ [g!name mutual]) - [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] - (..macro g!context g!name)]) - (list.zipped/2 hidden_names - functions)))] + hidden_names (monad.each ! (//.constant (macro.identifier "mutual_function#")) + functions) + .let [definitions (list\each (..mutual_definition hidden_names g!context) + (list.zipped/2 hidden_names + (list\each (value@ #mutual) functions))) + context_types (list\each (function (_ mutual) + (` (-> (~ g!context) (~ (value@ [#mutual #type] mutual))))) + functions) + user_names (list\each (|>> (value@ [#mutual #declaration #declaration.name]) code.local_identifier) + functions)] + g!pop (local.push (list\each (function (_ [g!name mutual]) + [[here_name (value@ [#mutual #declaration #declaration.name] mutual)] + (..macro g!context g!name)]) + (list.zipped/2 hidden_names + functions)))] (in (list& (` (.def: (~ g!context) - [(~+ (list\map (value@ [#mutual #type]) functions))] + [(~+ (list\each (value@ [#mutual #type]) functions))] (.let [(~ g!context) (: (Rec (~ g!context) [(~+ context_types)]) [(~+ definitions)]) [(~+ user_names)] (~ g!context)] - [(~+ (list\map (function (_ g!name) - (` ((~ g!name) (~ g!context)))) - user_names))]))) + [(~+ (list\each (function (_ g!name) + (` ((~ g!name) (~ g!context)))) + user_names))]))) g!pop - (list\map (function (_ mutual) - (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] - (` (.def: - (~ (value@ #export_policy mutual)) - (~ g!name) - (~ (value@ [#mutual #type] mutual)) - (.let [[(~+ user_names)] (~ g!context)] - (~ g!name)))))) - functions))))))) + (list\each (function (_ mutual) + (.let [g!name (|> mutual (value@ [#mutual #declaration #declaration.name]) code.local_identifier)] + (` (.def: + (~ (value@ #export_policy mutual)) + (~ g!name) + (~ (value@ [#mutual #type] mutual)) + (.let [[(~+ user_names)] (~ g!context)] + (~ g!name)))))) + functions))))))) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 4666dfb8a..4f051e604 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -44,7 +44,7 @@ (implementation: .public functor (Functor IO) - (def: (map f) + (def: (each f) (|>> run!' f !io))) (implementation: .public apply @@ -60,7 +60,9 @@ (def: &functor ..functor) - (def: in (|>> !io)) + (def: in + (|>> !io)) - (def: join (|>> run!' run!' !io))) + (def: conjoint + (|>> run!' run!' !io))) ) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 58cf7a526..e12de5bb9 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -54,7 +54,7 @@ (implementation: .public functor (Functor Lazy) - (def: (map f fa) + (def: (each f fa) (lazy (f (value fa))))) (implementation: .public apply @@ -69,4 +69,4 @@ (def: &functor ..functor) (def: in (|>> lazy)) - (def: join value)) + (def: conjoint ..value)) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 854ef0402..6fbc4b294 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -20,7 +20,7 @@ (def: identity #.None) - (def: (compose mx my) + (def: (composite mx my) (case mx #.None my @@ -31,7 +31,7 @@ (implementation: .public functor (Functor Maybe) - (def: (map f ma) + (def: (each f ma) (case ma #.None #.None (#.Some a) (#.Some (f a))))) @@ -57,7 +57,7 @@ (def: (in x) (#.Some x)) - (def: (join mma) + (def: (conjoint mma) (case mma #.None #.None @@ -102,7 +102,7 @@ (def: in (|>> (\ ..monad in) (\ monad in))) - (def: (join MmMma) + (def: (conjoint MmMma) (do monad [mMma MmMma] (case mMma @@ -114,7 +114,7 @@ (def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (macro: .public (else tokens state) (case tokens diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 30c728cd2..4d32c8df6 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -22,7 +22,7 @@ (implementation: .public functor (All [s] (Functor (Parser s))) - (def: (map f ma) + (def: (each f ma) (function (_ input) (case (ma input) (#try.Failure msg) @@ -59,7 +59,7 @@ (function (_ input) (#try.Success [input x]))) - (def: (join mma) + (def: (conjoint mma) (function (_ input) (case (mma input) (#try.Failure msg) @@ -96,7 +96,7 @@ (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do {! ..monad} [head first] - (\ ! map (|>> [head]) second))) + (\ ! each (|>> [head]) second))) (def: .public (or left right) (All [s a b] @@ -134,7 +134,7 @@ (#try.Success [input (list)]) (#try.Success [input' head]) - (..result (\ ..monad map (|>> (list& head)) + (..result (\ ..monad each (|>> (list& head)) (some parser)) input')))) @@ -143,7 +143,7 @@ (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) - (\ ..monad map (|>> #.Item)))) + (\ ..monad each (|>> #.Item)))) (def: .public (exactly amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -153,13 +153,13 @@ [x parser] (|> parser (exactly (-- amount)) - (\ ! map (|>> (#.Item x))))))) + (\ ! each (|>> (#.Item x))))))) (def: .public (at_least amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) (do {! ..monad} [minimum (..exactly amount parser)] - (\ ! map (list\compose minimum) (..some parser)))) + (\ ! each (list\composite minimum) (..some parser)))) (def: .public (at_most amount parser) (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) @@ -171,7 +171,7 @@ (#try.Success [input (list)]) (#try.Success [input' x]) - (..result (\ ..monad map (|>> (#.Item x)) + (..result (\ ..monad each (|>> (#.Item x)) (at_most (-- amount) parser)) input'))))) @@ -181,7 +181,7 @@ [minimum (..exactly minimum parser)] (case additional 0 (in minimum) - _ (\ ! map (list\compose minimum) + _ (\ ! each (list\composite minimum) (..at_most additional parser))))) (def: .public (separated_by separator parser) @@ -196,7 +196,7 @@ (|> parser (..and separator) ..some - (\ ! map (|>> (list\map product.right) (#.Item x))))))) + (\ ! each (|>> (list\each product.right) (#.Item x))))))) (def: .public (not parser) (All [s a] (-> (Parser s a) (Parser s Any))) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 42bffc310..27caea2af 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple nat int rev local) + [lux (#- Tuple Variant nat int rev local) [abstract [monad (#+ do)]] [control @@ -36,7 +36,7 @@ (-> (List Analysis) Text) (format text.new_line "Remaining input: " (|> asts - (list\map /.%analysis) + (list\each /.%analysis) (text.interposed " ")))) (exception: .public (cannot_parse {input (List Analysis)}) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 4fd9d15f5..220dd5ea2 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -99,7 +99,7 @@ (def: .public frac (Parser Frac) - (//\map frac.of_bits ..bits/64)) + (//\each frac.of_bits ..bits/64)) (exception: .public (invalid_tag {range Nat} {byte Nat}) (exception.report @@ -112,7 +112,7 @@ ..bits/8)] (`` (case flag (^template [<number> <tag> <parser>] - [<number> (\ ! map (|>> <tag>) <parser>)]) + [<number> (\ ! each (|>> <tag>) <parser>)]) ((~~ (template.spliced <case>+))) _ (//.lifted (exception.except ..invalid_tag [(~~ (template.amount <case>+)) flag])))))]) @@ -153,13 +153,13 @@ 0 (#try.Success [[offset binary] (/.empty 0)]) _ (|> binary (/.slice offset size) - (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) + (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) (template [<size> <name> <bits>] [(`` (def: .public <name> (Parser Binary) (do //.monad - [size (//\map .nat <bits>)] + [size (//\each .nat <bits>)] (..segment size))))] [08 binary/8 ..bits/8] diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index 1a3bbc5a7..9b83d835a 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -32,9 +32,9 @@ (def: remaining_inputs (-> (List Code) Text) - (|>> (list\map code.format) + (|>> (list\each code.format) (text.interposed " ") - ($_ text\compose text.new_line "Remaining input: "))) + ($_ text\composite text.new_line "Remaining input: "))) (def: .public any (Parser Code) @@ -47,7 +47,7 @@ (#try.Success [tokens' t])))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser <type>) (function (_ tokens) @@ -87,14 +87,14 @@ (#.Item [token tokens']) (if (code\= code token) (#try.Success [tokens' []]) - (#try.Failure ($_ text\compose "Expected a " (code.format code) " but instead got " (code.format token) + (#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) (remaining_inputs tokens)))) _ (#try.Failure "There are no tokens to parse!")))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))] + [(with_expansions [<failure> (as_is (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))] (def: .public <query> (Parser Text) (function (_ tokens) @@ -130,10 +130,10 @@ (#.Item [[_ (<tag> members)] tokens']) (case (p members) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse " <desc> (remaining_inputs tokens))))))] + (#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))))))] [ form #.Form "form"] [tuple #.Tuple "tuple"] @@ -147,17 +147,17 @@ (#.Item [[_ (#.Record pairs)] tokens']) (case (p (un_paired pairs)) (#try.Success [#.End x]) (#try.Success [tokens' x]) - _ (#try.Failure ($_ text\compose "Parser was expected to fully consume record" (remaining_inputs tokens)))) + _ (#try.Failure ($_ text\composite "Parser was expected to fully consume record" (remaining_inputs tokens)))) _ - (#try.Failure ($_ text\compose "Cannot parse record" (remaining_inputs tokens)))))) + (#try.Failure ($_ text\composite "Cannot parse record" (remaining_inputs tokens)))))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens #.End (#try.Success [tokens []]) - _ (#try.Failure ($_ text\compose "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) + _ (#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens)))))) (def: .public end? (Parser Bit) @@ -179,9 +179,9 @@ _ (#try.Failure (|> unconsumed - (list\map code.format) + (list\each code.format) (text.interposed ", ") - (text\compose "Unconsumed inputs: ")))))) + (text\composite "Unconsumed inputs: ")))))) (def: .public (local inputs parser) (All [a] (-> (List Code) (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index f084a838d..fbb7335f5 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -41,4 +41,4 @@ (def: .public (result parser environment) (All [a] (-> (Parser a) Environment (Try a))) - (\ try.monad map product.right (parser environment))) + (\ try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 1348b92b4..dcbda6f71 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -146,8 +146,8 @@ (#/.Object kvs) (case (|> kvs dictionary.entries - (list\map (function (_ [key value]) - (list (#/.String key) value))) + (list\each (function (_ [key value]) + (list (#/.String key) value))) list.together (//.result parser)) (#try.Failure error) @@ -195,4 +195,4 @@ (|>> (//.and ..string) //.some ..object - (//\map (dictionary.of_list text.hash)))) + (//\each (dictionary.of_list text.hash)))) diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index df28b3df1..d6c6fbeca 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -1,6 +1,6 @@ (.module: [library - [lux (#- Variant Tuple function loop i64 local) + [lux (#- Tuple Variant function loop i64 local) [abstract [monad (#+ do)]] [control diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 0e9724a15..24a2f9e3c 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -31,8 +31,9 @@ (//.Parser [Offset Text])) (type: .public Slice - {#basis Offset - #distance Offset}) + (Record + {#basis Offset + #distance Offset})) (def: (remaining' offset tape) (-> Offset Text Text) @@ -161,7 +162,7 @@ (do //.monad [char any .let [char' (maybe.trusted (/.char 0 char))] - _ (//.assertion ($_ /\compose "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) + _ (//.assertion ($_ /\composite "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) (.and (n.>= bottom char') (n.<= top char')))] (in char))) @@ -265,7 +266,7 @@ (do //.monad [=left left =right right] - (in ($_ /\compose =left =right)))) + (in ($_ /\composite =left =right)))) (def: .public (and! left right) (-> (Parser Slice) (Parser Slice) (Parser Slice)) @@ -277,7 +278,7 @@ (template [<name> <base> <doc_modifier>] [(def: .public (<name> parser) (-> (Parser Text) (Parser Text)) - (|> parser <base> (\ //.monad map /.together)))] + (|> parser <base> (\ //.monad each /.together)))] [some //.some "some"] [many //.many "many"] @@ -297,7 +298,7 @@ (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) - (\ //.monad map /.together)))] + (\ //.monad each /.together)))] [exactly //.exactly "exactly"] [at_most //.at_most "at most"] @@ -319,7 +320,7 @@ (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) - (\ //.monad map /.together))) + (\ //.monad each /.together))) (def: .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 0b726282a..d51ebc152 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -54,7 +54,7 @@ (exception: .public (unconsumed_input {remaining (List Type)}) (exception.report ["Types" (|> remaining - (list\map (|>> %.type (format text.new_line "* "))) + (list\each (|>> %.type (format text.new_line "* "))) (text.interposed ""))])) (type: .public Env @@ -132,7 +132,7 @@ (def: (label idx) (-> Nat Code) - (code.local_identifier ($_ text\compose "label" text.tab (n\encoded idx)))) + (code.local_identifier ($_ text\composite "label" text.tab (n\encoded idx)))) (def: .public (with_extension type poly) (All [a] (-> Type (Parser a) (Parser [Code a]))) @@ -175,7 +175,7 @@ (All [a] (-> (Parser a) (Parser [Code (List Code) a]))) (do {! //.monad} [headT any - funcI (\ ! map dictionary.size ..env) + funcI (\ ! each dictionary.size ..env) [num_args non_poly] (local (list headT) ..polymorphic') env ..env .let [funcL (label funcI) @@ -194,7 +194,7 @@ partial_varI (++ partialI) partial_varL (label partial_varI) partialC (` ((~ funcL) (~+ (|> (list.indices num_args) - (list\map (|>> (n.* 2) ++ (n.+ funcI) label)) + (list\each (|>> (n.* 2) ++ (n.+ funcI) label)) list.reversed))))] (recur (++ current_arg) (|> env' @@ -344,6 +344,6 @@ _ (local (list funcT) (..parameter! 0)) allC (let [allT (list& funcT argsT)] (|> allT - (monad.map ! (function.constant ..parameter)) + (monad.each ! (function.constant ..parameter)) (local allT)))] (in (` ((~+ allC)))))) diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 2e982ad45..6be4241d0 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -108,7 +108,7 @@ (if (name\= expected actual) (|> children (..result' parser attrs') - (try\map (|>> [[attrs tail]]))) + (try\each (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) (def: .public any diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 8fda36325..760dfb143 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -104,11 +104,12 @@ prev <code>.any]) (with_identifiers [g!temp] (in (list (` (let [(~ g!temp) (~ prev)] - [(~+ (list\map (function (_ body) (` (|> (~ g!temp) (~+ body)))) - paths))])))))) + [(~+ (list\each (function (_ body) (` (|> (~ g!temp) (~+ body)))) + paths))])))))) (syntax: .public (case> [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) (in (list (` (case (~ prev) - (~+ (list\join (list\map (function (_ [pattern body]) (list pattern body)) - branches)))))))) + (~+ (|> branches + (list\each (function (_ [pattern body]) (list pattern body))) + list\conjoint))))))) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 7d6462858..b5b6c3e6e 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -24,7 +24,7 @@ (implementation: .public functor (All [r] (Functor (Reader r))) - (def: (map f fa) + (def: (each f fa) (function (_ env) (f (fa env))))) @@ -45,7 +45,7 @@ (def: (in x) (function (_ env) x)) - (def: (join mma) + (def: (conjoint mma) (function (_ env) (mma env env)))) @@ -58,7 +58,7 @@ (def: in (|>> (\ monad in) (\ ..monad in))) - (def: (join eMeMa) + (def: (conjoint eMeMa) (function (_ env) (do monad [eMa (result env eMeMa)] diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index 1ca544ca6..a8a30cfd2 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -58,8 +58,8 @@ (do {! monad} [[cleaners output] (computation [[] (list)])] (|> cleaners - (monad.map ! (function (_ cleaner) (cleaner []))) - (\ ! map (list\mix clean output))))) + (monad.each ! (function (_ cleaner) (cleaner []))) + (\ ! each (list\mix clean output))))) (def: .public (acquire! monad cleaner value) (All [! a] (-> (Monad !) (-> a (! (Try Any))) a @@ -74,10 +74,10 @@ (-> (Functor !) (All [r] (Functor (Region r !))))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ region+cleaners) - (\ super map + (\ super each (function (_ [cleaners' temp]) [cleaners' (case temp (#try.Success value) @@ -124,7 +124,7 @@ (function (_ [region cleaners]) (\ super in [cleaners (#try.Success value)]))) - (def: (join ffa) + (def: (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] @@ -153,6 +153,6 @@ (-> (Monad !) (! a) (All [r] (Region r ! a)))) (function (_ [region cleaners]) - (\ monad map + (\ monad each (|>> #try.Success [cleaners]) operation))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index eaba75049..8ba79f6a7 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -36,8 +36,8 @@ (def: deadline (Parser Date) ($_ <>.either - (<>\map (|>> instant.of_millis instant.date) - <c>.int) + (<>\each (|>> instant.of_millis instant.date) + <c>.int) (do <>.monad [raw <c>.text] (case (\ date.codec decoded raw) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 45b2bd083..ec84db916 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -51,14 +51,14 @@ (do {! meta.monad} [this_module meta.current_module_name .let [[name vars] declaration] - g!brand (\ ! map (|>> %.code code.text) + g!brand (\ ! each (|>> %.code code.text) (macro.identifier (format (%.name [this_module name])))) .let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]] (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) (` (def: (~ (code.local_identifier forger)) - (All [(~+ (list\map code.local_identifier vars))] + (All [(~+ (list\each code.local_identifier vars))] (-> (-> (~ input) (~ output)) (~ capability))) (~! ..capability))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index 497e250ff..1087cf751 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -20,8 +20,9 @@ (-> (Policy brand value label) value)) (type: .public (Privilege brand label) - {#can_upgrade (Can_Upgrade brand label) - #can_downgrade (Can_Downgrade brand label)}) + (Record + {#can_upgrade (Can_Upgrade brand label) + #can_downgrade (Can_Downgrade brand label)})) (type: .public (Delegation brand from to) (All [value] @@ -58,7 +59,7 @@ (implementation: .public functor (:~ (..of_policy Functor)) - (def: (map f fa) + (def: (each f fa) (|> fa :representation f :abstraction))) (implementation: .public apply @@ -74,7 +75,7 @@ (def: &functor ..functor) (def: in (|>> :abstraction)) - (def: join (|>> :representation))) + (def: conjoint (|>> :representation))) ) (template [<brand> <value> <upgrade> <downgrade>] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 586cb652c..4b3a64a08 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -42,7 +42,7 @@ (implementation: .public functor (All [s] (Functor (State s))) - (def: (map f ma) + (def: (each f ma) (function (_ state) (let [[state' a] (ma state)] [state' (f a)])))) @@ -67,7 +67,7 @@ (function (_ state) [state a])) - (def: (join mma) + (def: (conjoint mma) (function (_ state) (let [[state' ma] (mma state)] (ma state'))))) @@ -91,9 +91,9 @@ (implementation: (with//functor functor) (All [M s] (-> (Functor M) (Functor (All [a] (-> s (M [s a])))))) - (def: (map f sfa) + (def: (each f sfa) (function (_ state) - (\ functor map (function (_ [s a]) [s (f a)]) + (\ functor each (function (_ [s a]) [s (f a)]) (sfa state))))) (implementation: (with//apply monad) @@ -124,7 +124,7 @@ (function (_ state) (\ monad in [state a]))) - (def: (join sMsMa) + (def: (conjoint sMsMa) (function (_ state) (do monad [[state' sMa] (sMsMa state)] diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index 8366b2efc..a7acf841e 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -71,7 +71,7 @@ (implementation: .public functor (All [!] (Functor (Thread !))) - (def: (map f) + (def: (each f) (function (_ fa) (function (_ !) (f (fa !)))))) @@ -94,7 +94,7 @@ (function (_ !) value)) - (def: (join ffa) + (def: (conjoint ffa) (function (_ !) ((ffa !) !)))) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 2a1fce570..48ee21443 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -10,13 +10,14 @@ ["." location]]]]) (type: .public (Try a) - (#Failure Text) - (#Success a)) + (Variant + (#Failure Text) + (#Success a))) (implementation: .public functor (Functor Try) - (def: (map f ma) + (def: (each f ma) (case ma (#Failure msg) (#Failure msg) @@ -50,7 +51,7 @@ (def: (in a) (#Success a)) - (def: (join mma) + (def: (conjoint mma) (case mma (#Failure msg) (#Failure msg) @@ -69,7 +70,7 @@ (|>> (\ ..monad in) (\ monad in))) - (def: (join MeMea) + (def: (conjoint MeMea) (do monad [eMea MeMea] (case eMea @@ -81,7 +82,7 @@ (def: .public (lifted monad) (All [! a] (-> (Monad !) (-> (! a) (! (Try a))))) - (\ monad map (\ ..monad in))) + (\ monad each (\ ..monad in))) (implementation: .public (equivalence (^open "_\.")) (All [a] (-> (Equivalence a) (Equivalence (Try a)))) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index d42e57780..825700d8f 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -9,8 +9,9 @@ ["." monad (#+ Monad do)]]]]) (type: .public (Writer log value) - {#log log - #value value}) + (Record + {#log log + #value value})) (def: .public (write message) (All [log] (-> log (Writer log Any))) @@ -20,7 +21,7 @@ (All [l] (Functor (Writer l))) - (def: (map f fa) + (def: (each f fa) (let [[log datum] fa] [log (f datum)]))) @@ -33,7 +34,7 @@ (def: (on fa ff) (let [[log1 f] ff [log2 a] fa] - [(\ monoid compose log1 log2) (f a)]))) + [(\ monoid composite log1 log2) (f a)]))) (implementation: .public (monad monoid) (All [l] @@ -44,9 +45,9 @@ (def: in (|>> [(\ monoid identity)])) - (def: (join mma) + (def: (conjoint mma) (let [[log1 [log2 a]] mma] - [(\ monoid compose log1 log2) a]))) + [(\ monoid composite log1 log2) a]))) (implementation: .public (with monoid monad) (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) @@ -59,7 +60,7 @@ (let [writer (..monad monoid)] (|>> (\ writer in) (\ monad in)))) - (def: (join MlMla) + (def: (conjoint MlMla) (do monad [[l1 Mla] (for {@.old (: ((:parameter 1) (Writer (:parameter 0) ((:parameter 1) (Writer (:parameter 0) (:parameter 2))))) @@ -67,10 +68,10 @@ ... On new compiler MlMla) [l2 a] Mla] - (in [(\ monoid compose l1 l2) a])))) + (in [(\ monoid composite l1 l2) a])))) (def: .public (lifted monoid monad) (All [l M a] (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) - (\ monad map (|>> [(\ monoid identity)]))) + (\ monad each (|>> [(\ monoid identity)]))) |