diff options
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))))) |