From f9eca6ccaebfc916e2ccd347eb9bab7362b8899f Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Fri, 6 Jan 2017 19:38:11 -0400
Subject: - Gave custom tags to Error, instead of basing Error on Either.

---
 stdlib/source/lux/data/error.lux | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

(limited to 'stdlib/source')

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))
-- 
cgit v1.2.3