aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/data/error.lux12
-rw-r--r--stdlib/source/test/lux/data/error.lux27
2 files changed, 21 insertions, 18 deletions
diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux
index f05df614d..3e7369ed3 100644
--- a/stdlib/source/lux/data/error.lux
+++ b/stdlib/source/lux/data/error.lux
@@ -72,15 +72,19 @@
(All [M a] (-> (Monad M) (-> (M a) (M (Error a)))))
(monad.lift monad (:: ..monad wrap)))
-(structure: #export (equivalence (^open "_@."))
+(structure: #export (equivalence (^open ",@."))
(All [a] (-> (Equivalence a) (Equivalence (Error a))))
(def: (= reference sample)
(case [reference sample]
[(#Success reference) (#Success sample)]
- (_@= reference sample)
+ (,@= reference sample)
[(#Failure reference) (#Failure sample)]
- ("lux text =" reference sample))))
+ ("lux text =" reference sample)
+
+ _
+ false
+ )))
(def: #export (succeed value)
(All [a] (-> a (Error a)))
@@ -102,7 +106,7 @@
(macro: #export (default tokens compiler)
{#.doc (doc "Allows you to provide a default value that will be used"
"if a (Error x) value turns out to be #Failure."
- (= "foo"
+ (= "bar"
(default "foo" (#Success "bar")))
(= "foo"
(default "foo" (#Failure "KABOOM!"))))}
diff --git a/stdlib/source/test/lux/data/error.lux b/stdlib/source/test/lux/data/error.lux
index 9012b3212..c60c6563a 100644
--- a/stdlib/source/test/lux/data/error.lux
+++ b/stdlib/source/test/lux/data/error.lux
@@ -32,12 +32,12 @@
(def: #export (error element)
(All [a] (-> (Random a) (Random (Error a))))
($_ r.or
- (:: r.monad wrap "KABOOM!")
+ (r.unicode 1)
element))
(def: #export test
Test
- (<| (_.context (%name (name-of /.Error)))
+ (<| (_.context (%name (name-of /._)))
($_ _.and
($equivalence.spec (/.equivalence nat.equivalence) (..error r.nat))
($functor.spec ..injection ..comparison /.functor)
@@ -48,17 +48,16 @@
right r.nat
#let [expected (n/+ left right)
(^open "io@.") io.monad]]
- (let []
- (_.test "Can add error functionality to any monad."
- (let [lift (/.lift io.monad)]
- (|> (do (/.with io.monad)
- [a (lift (io@wrap left))
- b (wrap right)]
- (wrap (n/+ a b)))
- io.run
- (case> (#/.Success actual)
- (n/= expected actual)
+ (_.test "Can add error functionality to any monad."
+ (let [lift (/.lift io.monad)]
+ (|> (do (/.with io.monad)
+ [a (lift (io@wrap left))
+ b (wrap right)]
+ (wrap (n/+ a b)))
+ io.run
+ (case> (#/.Success actual)
+ (n/= expected actual)
- _
- #0))))))
+ _
+ false)))))
)))