diff options
author | Eduardo Julian | 2017-01-06 19:38:11 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-01-06 19:38:11 -0400 |
commit | f9eca6ccaebfc916e2ccd347eb9bab7362b8899f (patch) | |
tree | 7ed65bcf51b8bc4961c3e9216e0bf8037c106e78 /stdlib/source | |
parent | 1e34eef43c24d1fb05afeccbe55e958b1b088dab (diff) |
- Gave custom tags to Error, instead of basing Error on Either.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/error.lux | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux index 56f60ac2b..94b2c40cb 100644 --- a/stdlib/source/lux/data/error.lux +++ b/stdlib/source/lux/data/error.lux @@ -11,33 +11,34 @@ ## [Types] (type: #export (Error a) - (Either Text a)) + (#Error Text) + (#Success a)) ## [Structures] (struct: #export _ (Functor Error) (def: (map f ma) (case ma - (#;Left msg) (#;Left msg) - (#;Right datum) (#;Right (f datum))))) + (#Error msg) (#Error msg) + (#Success datum) (#Success (f datum))))) (struct: #export _ (Applicative Error) (def: functor Functor<Error>) (def: (wrap a) - (#;Right a)) + (#Success a)) (def: (apply ff fa) (case ff - (#;Right f) + (#Success f) (case fa - (#;Right a) - (#;Right (f a)) + (#Success a) + (#Success (f a)) - (#;Left msg) - (#;Left msg)) + (#Error msg) + (#Error msg)) - (#;Left msg) - (#;Left msg)) + (#Error msg) + (#Error msg)) )) (struct: #export _ (Monad Error) @@ -45,8 +46,8 @@ (def: (join mma) (case mma - (#;Left msg) (#;Left msg) - (#;Right ma) ma))) + (#Error msg) (#Error msg) + (#Success ma) ma))) (struct: #export (ErrorT Monad<M>) (All [M] (-> (Monad M) (Monad (All [a] (M (Error a)))))) @@ -55,10 +56,10 @@ (do Monad<M> [eMea MeMea] (case eMea - (#;Left error) - (wrap (#;Left error)) + (#Error error) + (wrap (#Error error)) - (#;Right Mea) + (#Success Mea) Mea)))) (def: #export (lift-error Monad<M>) @@ -67,4 +68,4 @@ (def: #export (fail message) (All [a] (-> Text (Error a))) - (#;Left message)) + (#Error message)) |