diff options
author | Eduardo Julian | 2016-12-18 15:35:10 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-18 15:35:10 -0400 |
commit | 47e7627e05f2f961794e312e28bf8a437a1e0c78 (patch) | |
tree | a907281e0d55fe09038d1951c552614f69eb3c77 /stdlib | |
parent | c85654fe58058eb1b5529e6c392b1bc55bd05862 (diff) |
- Tested monad transformer for Error.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux/data/error.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/error.lux | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux index 235eee147..56f60ac2b 100644 --- a/stdlib/source/lux/data/error.lux +++ b/stdlib/source/lux/data/error.lux @@ -59,7 +59,7 @@ (wrap (#;Left error)) (#;Right Mea) - (join Mea))))) + Mea)))) (def: #export (lift-error Monad<M>) (All [M a] (-> (Monad M) (-> (M a) (M (Error a))))) diff --git a/stdlib/test/test/lux/data/error.lux b/stdlib/test/test/lux/data/error.lux index 7cc7c2f4c..6127c37c1 100644 --- a/stdlib/test/test/lux/data/error.lux +++ b/stdlib/test/test/lux/data/error.lux @@ -7,7 +7,8 @@ lux (lux (codata [io]) (control monad) - (data ["&" error]) + (data text/format + ["&" error]) pipe) lux/test) @@ -47,3 +48,14 @@ (case> (#;Left "YOLO") true _ false)) )) ))) + +(test: "Monad transformer" + (let [lift (&;lift-error io;Monad<IO>) + (^open "io/") io;Monad<IO>] + (assert "Can add error functionality to any monad." + (|> (io;run (do (&;ErrorT io;Monad<IO>) + [a (lift (io/wrap 123)) + b (wrap 456)] + (wrap (i.+ a b)))) + (case> (#;Right 579) true + _ false))))) |