diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/io.lux | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux index 9295795be..5ec03c749 100644 --- a/stdlib/source/lux/io.lux +++ b/stdlib/source/lux/io.lux @@ -6,8 +6,9 @@ [monad (#+ do Monad)] ["ex" exception (#+ Exception)]] [data - ["e" error (#+ Error)] - [collection [list]]]]) + ["." error (#+ Error)] + [collection + [list]]]]) (type: #export (IO a) {#.doc "A type that represents synchronous, effectful computations that may interact with the outside world."} @@ -61,31 +62,35 @@ (structure: #export _ (Functor Process) (def: (map f ma) - (io (:: e.Functor<Error> map f (run ma))))) + (io (:: error.Functor<Error> map f (run ma))))) (structure: #export _ (Apply Process) (def: functor Functor<Process>) (def: (apply ff fa) - (io (:: e.Apply<Error> apply (run ff) (run fa))))) + (io (:: error.Apply<Error> apply (run ff) (run fa))))) (structure: #export _ (Monad Process) (def: functor Functor<Process>) (def: (wrap x) - (io (:: e.Monad<Error> wrap x))) + (io (:: error.Monad<Error> wrap x))) (def: (join mma) (case (run mma) - (#e.Success ma) + (#error.Success ma) ma - (#e.Error error) - (io (#e.Error error))))) + (#error.Error error) + (io (#error.Error error))))) + +(def: #export from-io + (All [a] (-> (IO a) (Process a))) + (:: Functor<IO> map (|>> #error.Success))) (def: #export (fail error) (All [a] (-> Text (Process a))) - (io (#e.Error error))) + (io (#error.Error error))) (def: #export (throw exception message) (All [e a] (-> (Exception e) e (Process a))) |