aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/error.lux35
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))