diff options
author | Eduardo Julian | 2018-05-02 00:20:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-02 00:20:42 -0400 |
commit | 0144da58ba856bd6f6072b588bbd076c9c3fdb36 (patch) | |
tree | 19aa593327891ced4d28ef1fd0a3394c70ffa38d /stdlib/source | |
parent | e4e67f0427d93b3686366ffe9f14a4751690101e (diff) |
- Re-named "Applicative" to "Apply".
Diffstat (limited to 'stdlib/source')
25 files changed, 89 insertions, 90 deletions
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index 93d3498d4..e160fec12 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad]) [io #+ IO io] (data (coll [list "list/" Monoid<List>])) @@ -103,7 +103,7 @@ input)) output)))) -(struct: #export _ (Applicative Channel) +(struct: #export _ (Apply Channel) (def: functor Functor<Channel>) (def: (apply ff fa) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index 30895098f..0e3e0c695 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -3,7 +3,7 @@ (lux [io #+ IO io] [function] (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad]) (data [product]) (concurrency [atom #+ Atom atom]) @@ -79,7 +79,7 @@ fa) fb)))) -(struct: #export _ (Applicative Promise) +(struct: #export _ (Apply Promise) (def: functor Functor<Promise>) (def: (apply ff fa) diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index 6c86af772..707512821 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad]) [io #+ IO io] (data [product] @@ -133,7 +133,7 @@ (let [[tx' a] (fa tx)] [tx' (f a)])))) -(struct: #export _ (Applicative STM) +(struct: #export _ (Apply STM) (def: functor Functor<STM>) (def: (apply ff fa) diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux index 1ebfa181c..0f95d428c 100644 --- a/stdlib/source/lux/concurrency/task.lux +++ b/stdlib/source/lux/concurrency/task.lux @@ -2,7 +2,7 @@ lux (lux (data ["E" error]) (control ["F" functor] - ["A" applicative] + ["A" apply] monad ["ex" exception #+ Exception]) (concurrency ["P" promise]) @@ -42,7 +42,7 @@ (#E.Success (f a)))) fa))) -(struct: #export _ (A.Applicative Task) +(struct: #export _ (A.Apply Task) (def: functor Functor<Task>) (def: (apply ff fa) diff --git a/stdlib/source/lux/control/applicative.lux b/stdlib/source/lux/control/applicative.lux deleted file mode 100644 index 2a926cc20..000000000 --- a/stdlib/source/lux/control/applicative.lux +++ /dev/null @@ -1,34 +0,0 @@ -(.module: - lux - (// [functor #+ Functor] - [monad #+ Monad])) - -(sig: #export (Applicative f) - {#.doc "Applicative functors."} - (: (Functor f) - functor) - (: (All [a b] - (-> (f (-> a b)) (f a) (f b))) - apply)) - -(struct: #export (compose Monad<F> Applicative<F> Applicative<G>) - {#.doc "Applicative functor composition."} - (All [F G] - (-> (Monad F) (Applicative F) (Applicative G) - (Applicative (All [a] (F (G a)))))) - - (def: functor (functor.compose (get@ #functor Applicative<F>) - (get@ #functor Applicative<G>))) - (def: (apply fgf fgx) - ## TODO: Switch from this version to the one below (in comments) ASAP. - (let [fgf' (:: Applicative<F> apply - (:: Monad<F> wrap (:: Applicative<G> apply)) - fgf)] - (:: Applicative<F> apply fgf' fgx)) - ## (let [applyF (:: Applicative<F> apply) - ## applyG (:: Applicative<G> apply)] - ## ($_ applyF - ## (:: Monad<F> wrap applyG) - ## fgf - ## fgx)) - )) diff --git a/stdlib/source/lux/control/apply.lux b/stdlib/source/lux/control/apply.lux new file mode 100644 index 000000000..eb9dbaf00 --- /dev/null +++ b/stdlib/source/lux/control/apply.lux @@ -0,0 +1,34 @@ +(.module: + lux + (// [functor #+ Functor] + [monad #+ Monad])) + +(sig: #export (Apply f) + {#.doc "Applicative functors."} + (: (Functor f) + functor) + (: (All [a b] + (-> (f (-> a b)) (f a) (f b))) + apply)) + +(struct: #export (compose Monad<F> Apply<F> Apply<G>) + {#.doc "Applicative functor composition."} + (All [F G] + (-> (Monad F) (Apply F) (Apply G) + (Apply (All [a] (F (G a)))))) + + (def: functor (functor.compose (get@ #functor Apply<F>) (get@ #functor Apply<G>))) + + (def: (apply fgf fgx) + ## TODO: Switch from this version to the one below (in comments) ASAP. + (let [fgf' (:: Apply<F> apply + (:: Monad<F> wrap (:: Apply<G> apply)) + fgf)] + (:: Apply<F> apply fgf' fgx)) + ## (let [applyF (:: Apply<F> apply) + ## applyG (:: Apply<G> apply)] + ## ($_ applyF + ## (:: Monad<F> wrap applyG) + ## fgf + ## fgx)) + )) diff --git a/stdlib/source/lux/control/continuation.lux b/stdlib/source/lux/control/continuation.lux index 2a145ae5a..d23ebec18 100644 --- a/stdlib/source/lux/control/continuation.lux +++ b/stdlib/source/lux/control/continuation.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] monad) function [macro #+ with-gensyms] @@ -26,7 +26,7 @@ (def: (map f fv) (function (_ k) (fv (compose k f))))) -(struct: #export Applicative<Cont> (All [o] (Applicative (All [i] (Cont i o)))) +(struct: #export Apply<Cont> (All [o] (Apply (All [i] (Cont i o)))) (def: functor Functor<Cont>) (def: (apply ff fv) diff --git a/stdlib/source/lux/control/monad/free.lux b/stdlib/source/lux/control/monad/free.lux index 7a41b3e9f..716ae805b 100644 --- a/stdlib/source/lux/control/monad/free.lux +++ b/stdlib/source/lux/control/monad/free.lux @@ -1,7 +1,7 @@ (.module: lux (/// [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ Monad])) (type: #export (Free F a) @@ -20,8 +20,8 @@ (#Effect value) (#Effect (:: dsl map (map f) value))))) -(struct: #export (Applicative<Free> dsl) - (All [F] (-> (Functor F) (Applicative (Free F)))) +(struct: #export (Apply<Free> dsl) + (All [F] (-> (Functor F) (Apply (Free F)))) (def: functor (Functor<Free> dsl)) diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux index c4aaf35e3..d46b166e4 100644 --- a/stdlib/source/lux/control/parser.lux +++ b/stdlib/source/lux/control/parser.lux @@ -1,7 +1,7 @@ (.module: [lux #- not] (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] [codec]) (data (coll [list "list/" Functor<List> Monoid<List>]) @@ -23,7 +23,7 @@ (#e.Success [input' a]) (#e.Success [input' (f a)]))))) -(struct: #export Applicative<Parser> (All [s] (Applicative (Parser s))) +(struct: #export Apply<Parser> (All [s] (Apply (Parser s))) (def: functor Functor<Parser>) (def: (apply ff fa) diff --git a/stdlib/source/lux/control/reader.lux b/stdlib/source/lux/control/reader.lux index fc2d6540b..228e474db 100644 --- a/stdlib/source/lux/control/reader.lux +++ b/stdlib/source/lux/control/reader.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control ["F" functor] - ["A" applicative] + ["A" apply] [monad #+ do Monad]))) ## [Types] @@ -17,8 +17,8 @@ (function (_ env) (f (fa env))))) -(struct: #export Applicative<Reader> - (All [r] (A.Applicative (Reader r))) +(struct: #export Apply<Reader> + (All [r] (A.Apply (Reader r))) (def: functor Functor<Reader>) diff --git a/stdlib/source/lux/control/region.lux b/stdlib/source/lux/control/region.lux index 1e2b4a47b..3729c00f2 100644 --- a/stdlib/source/lux/control/region.lux +++ b/stdlib/source/lux/control/region.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ Monad do] ["ex" exception #+ Exception exception:]) (data ["e" error #+ Error] @@ -80,10 +80,10 @@ (#e.Error error))]) (fa region+cleaners)))))) -(struct: #export (Applicative<Region> Monad<m>) +(struct: #export (Apply<Region> Monad<m>) (All [m] (-> (Monad m) - (All [r] (Applicative (Region r m))))) + (All [r] (Apply (Region r m))))) (def: functor (Functor<Region> (get@ #monad.functor Monad<m>))) diff --git a/stdlib/source/lux/control/state.lux b/stdlib/source/lux/control/state.lux index 86813bf69..422cf4fc6 100644 --- a/stdlib/source/lux/control/state.lux +++ b/stdlib/source/lux/control/state.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control ["F" functor] - ["A" applicative] + ["A" apply] [monad #+ do Monad]))) ## [Types] @@ -18,8 +18,8 @@ (let [[state' a] (ma state)] [state' (f a)])))) -(struct: #export Applicative<State> - (All [s] (A.Applicative (State s))) +(struct: #export Apply<State> + (All [s] (A.Apply (State s))) (def: functor Functor<State>) @@ -88,8 +88,8 @@ (:: Functor<M> map (function (_ [s a]) [s (f a)]) (sfa state))))) -(struct: (Applicative<StateT> Monad<M>) - (All [M s] (-> (Monad M) (A.Applicative (All [a] (-> s (M [s a])))))) +(struct: (Apply<StateT> Monad<M>) + (All [M s] (-> (Monad M) (A.Apply (All [a] (-> s (M [s a])))))) (def: functor (Functor<StateT> (:: Monad<M> functor))) diff --git a/stdlib/source/lux/control/thread.lux b/stdlib/source/lux/control/thread.lux index 9848ed5bc..d79cc0d10 100644 --- a/stdlib/source/lux/control/thread.lux +++ b/stdlib/source/lux/control/thread.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ Monad do]) [io #+ IO])) @@ -41,8 +41,8 @@ (function (_ !) (f (fa !)))))) -(struct: #export Applicative<Thread> - (All [!] (Applicative (Thread !))) +(struct: #export Apply<Thread> + (All [!] (Apply (Thread !))) (def: functor Functor<Thread>) diff --git a/stdlib/source/lux/control/writer.lux b/stdlib/source/lux/control/writer.lux index 5022620c8..c65a9b29e 100644 --- a/stdlib/source/lux/control/writer.lux +++ b/stdlib/source/lux/control/writer.lux @@ -2,7 +2,7 @@ lux (lux/control monoid ["F" functor] - ["A" applicative] + ["A" apply] [monad #+ do Monad])) (type: #export (Writer l a) @@ -18,9 +18,9 @@ (let [[log datum] fa] [log (f datum)]))) -(struct: #export (Applicative<Writer> mon) +(struct: #export (Apply<Writer> mon) (All [l] - (-> (Monoid l) (A.Applicative (Writer l)))) + (-> (Monoid l) (A.Apply (Writer l)))) (def: functor Functor<Writer>) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index e558c592e..b9b743b2c 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -2,7 +2,7 @@ lux (lux (control [monoid #+ Monoid] [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] [eq #+ Eq] [fold]) @@ -268,7 +268,7 @@ (open Functor<List>) -(struct: #export _ (Applicative List) +(struct: #export _ (Apply List) (def: functor Functor<List>) (def: (apply ff fa) diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux index 0c3156f7f..b51e5034f 100644 --- a/stdlib/source/lux/data/coll/sequence.lux +++ b/stdlib/source/lux/data/coll/sequence.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] [eq #+ Eq] monoid @@ -410,7 +410,7 @@ #tail (|> xs (get@ #tail) (array/map f)) })) -(struct: #export _ (Applicative Sequence) +(struct: #export _ (Apply Sequence) (def: functor Functor<Sequence>) (def: (apply ff fa) diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux index 64cb5618e..5e7f07601 100644 --- a/stdlib/source/lux/data/error.lux +++ b/stdlib/source/lux/data/error.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control ["F" functor] - ["A" applicative] + ["A" apply] ["M" monad #+ do Monad]))) ## [Types] @@ -16,7 +16,7 @@ (#Error msg) (#Error msg) (#Success datum) (#Success (f datum))))) -(struct: #export _ (A.Applicative Error) +(struct: #export _ (A.Apply Error) (def: functor Functor<Error>) (def: (apply ff fa) diff --git a/stdlib/source/lux/data/identity.lux b/stdlib/source/lux/data/identity.lux index 51198d11c..b14658619 100644 --- a/stdlib/source/lux/data/identity.lux +++ b/stdlib/source/lux/data/identity.lux @@ -1,7 +1,7 @@ (.module: lux (lux/control ["F" functor] - ["A" applicative] + ["A" apply] (monad #as M #refer #all) (comonad #as CM #refer #all))) @@ -13,7 +13,7 @@ (struct: #export _ (F.Functor Identity) (def: map id)) -(struct: #export _ (A.Applicative Identity) +(struct: #export _ (A.Apply Identity) (def: functor Functor<Identity>) (def: (apply ff fa) (ff fa))) diff --git a/stdlib/source/lux/data/lazy.lux b/stdlib/source/lux/data/lazy.lux index adcc1234e..fcd07cd5d 100644 --- a/stdlib/source/lux/data/lazy.lux +++ b/stdlib/source/lux/data/lazy.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ Monad do]) (concurrency [atom]) [macro #+ with-gensyms] @@ -37,7 +37,7 @@ (def: (map f fa) (freeze (f (thaw fa))))) -(struct: #export _ (Applicative Lazy) +(struct: #export _ (Apply Lazy) (def: functor Functor<Lazy>) (def: (apply ff fa) (freeze ((thaw ff) (thaw fa))))) diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux index e42af460f..89be2362c 100644 --- a/stdlib/source/lux/data/maybe.lux +++ b/stdlib/source/lux/data/maybe.lux @@ -2,7 +2,7 @@ lux (lux (control ["m" monoid] ["F" functor] - ["A" applicative] + ["A" apply] [monad #+ do Monad] [eq #+ Eq]))) @@ -25,7 +25,7 @@ #.None #.None (#.Some a) (#.Some (f a))))) -(struct: #export _ (A.Applicative Maybe) +(struct: #export _ (A.Apply Maybe) (def: functor Functor<Maybe>) (def: (apply ff fa) diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux index 6e038aa7c..613959b4f 100644 --- a/stdlib/source/lux/io.lux +++ b/stdlib/source/lux/io.lux @@ -1,7 +1,7 @@ (.module: {#.doc "A method for abstracting I/O and effectful computations to make it safe while writing pure functional code."} lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] ["ex" exception #+ Exception]) (data ["e" error #+ Error] @@ -29,7 +29,7 @@ (def: (map f ma) (io (f (ma (:! Void [])))))) -(struct: #export _ (Applicative IO) +(struct: #export _ (Apply IO) (def: functor Functor<IO>) (def: (apply ff fa) @@ -57,11 +57,11 @@ (def: (map f ma) (io (:: e.Functor<Error> map f (run ma))))) -(struct: #export _ (Applicative Process) +(struct: #export _ (Apply Process) (def: functor Functor<Process>) (def: (apply ff fa) - (io (:: e.Applicative<Error> apply (run ff) (run fa))))) + (io (:: e.Apply<Error> apply (run ff) (run fa))))) (struct: #export _ (Monad Process) (def: functor Functor<Process>) diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux index cea574d0c..8a32b2c4c 100644 --- a/stdlib/source/lux/lang/type/check.lux +++ b/stdlib/source/lux/lang/type/check.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Type-checking functionality."} lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] ["ex" exception #+ exception:]) (data [text "text/" Monoid<Text> Eq<Text>] @@ -57,7 +57,7 @@ (#e.Success [context' (f output)]) )))) -(struct: #export _ (Applicative Check) +(struct: #export _ (Apply Check) (def: functor Functor<Check>) (def: (apply ff fa) diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux index 4c56e9184..238028f52 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/macro.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Functions for extracting information from the state of the compiler."} lux (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad]) (data [number] [product] @@ -26,7 +26,7 @@ (#e.Success [compiler' a]) (#e.Success [compiler' (f a)]))))) -(struct: #export _ (Applicative Meta) +(struct: #export _ (Apply Meta) (def: functor Functor<Meta>) (def: (apply ff fa) diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index 2b7c6598d..930f2929d 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Pseudo-random number generation (PRNG) algorithms."} [lux #- list] (lux (control [functor #+ Functor] - [applicative #+ Applicative] + [apply #+ Apply] [monad #+ do Monad] hash) (data [bit] @@ -34,7 +34,7 @@ (let [[state' a] (fa state)] [state' (f a)])))) -(struct: #export _ (Applicative Random) +(struct: #export _ (Apply Random) (def: functor Functor<Random>) (def: (apply ff fa) diff --git a/stdlib/source/lux/type/abstract.lux b/stdlib/source/lux/type/abstract.lux index e537d0b62..9f54f3036 100644 --- a/stdlib/source/lux/type/abstract.lux +++ b/stdlib/source/lux/type/abstract.lux @@ -1,7 +1,6 @@ (.module: lux - (lux (control [applicative] - [monad #+ do Monad] + (lux (control [monad #+ do Monad] ["p" parser]) (data [text "text/" Eq<Text> Monoid<Text>] ["E" error] |