diff options
author | Eduardo Julian | 2016-12-18 18:40:28 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-18 18:40:28 -0400 |
commit | 0df1d8855ab54abea8c729a3575b30c8499cc7e0 (patch) | |
tree | aaf1a71d48aa887bd4fefdcc77e6e66c4a716480 /stdlib/source | |
parent | c3d1a9e971c2b4ca56b1b8f444e8f7aeb6063c2a (diff) |
- Added tests for the monad transformers for Error, Maybe, State, List and Env.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/codata/env.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/codata/state.lux | 9 | ||||
-rw-r--r-- | stdlib/source/lux/data/log.lux | 3 | ||||
-rw-r--r-- | stdlib/source/lux/data/maybe.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/data/struct/list.lux | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/stdlib/source/lux/codata/env.lux b/stdlib/source/lux/codata/env.lux index 8883b4a66..818dd8a7e 100644 --- a/stdlib/source/lux/codata/env.lux +++ b/stdlib/source/lux/codata/env.lux @@ -52,7 +52,7 @@ (env-proc env)) (struct: #export (EnvT Monad<M>) - (All [M e] (-> (Monad M) (Monad (All [a] (Env e (M a)))))) + (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Env e (M a))))))) (def: applicative (compA Applicative<Env> (get@ #M;applicative Monad<M>))) (def: (join eMeMa) (lambda [env] diff --git a/stdlib/source/lux/codata/state.lux b/stdlib/source/lux/codata/state.lux index 82e9b40fd..2ff0ea3a8 100644 --- a/stdlib/source/lux/codata/state.lux +++ b/stdlib/source/lux/codata/state.lux @@ -97,8 +97,15 @@ [state a] (sFa state)] (wrap [state (f a)]))))) +(type: #export (State' M s a) + (-> s (M [s a]))) + +(def: #export (run' state action) + (All [M s a] (-> s (State' M s a) (M [s a]))) + (action state)) + (struct: #export (StateT Monad<M>) - (All [M s] (-> (Monad M) (Monad (All [a] (-> s (M [s a])))))) + (All [M s] (-> (Monad M) (Monad (State' M s)))) (def: applicative (Applicative<StateT> Monad<M>)) (def: (join sMsMa) (lambda [state] diff --git a/stdlib/source/lux/data/log.lux b/stdlib/source/lux/data/log.lux index 6b6cd2095..687f23478 100644 --- a/stdlib/source/lux/data/log.lux +++ b/stdlib/source/lux/data/log.lux @@ -50,8 +50,7 @@ (do Monad<M> [[l1 Mla] (: (($ +1) (Log ($ +0) (($ +1) (Log ($ +0) ($ +2))))) MlMla) - [l2 a] (: (($ +1) (Log ($ +0) ($ +2))) - Mla)] + [l2 a] Mla] (wrap [(:: Monoid<l> append l1 l2) a])))) (def: #export (lift-log Monoid<l> Monad<M>) diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux index 16aa9e30a..bf853baf1 100644 --- a/stdlib/source/lux/data/maybe.lux +++ b/stdlib/source/lux/data/maybe.lux @@ -75,7 +75,7 @@ (wrap #;None) (#;Some Mma) - (join Mma))))) + Mma)))) (def: #export (lift-maybe Monad<M>) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) diff --git a/stdlib/source/lux/data/struct/list.lux b/stdlib/source/lux/data/struct/list.lux index acd48d730..cd7323669 100644 --- a/stdlib/source/lux/data/struct/list.lux +++ b/stdlib/source/lux/data/struct/list.lux @@ -459,7 +459,7 @@ (do Monad<M> [lMla MlMla lla (: (($ +0) (List (List ($ +1)))) - (mapM @ join lMla))] + (seqM @ lMla))] (wrap (concat lla))))) (def: #export (lift-list Monad<M>) |