aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/control/try.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/control/try.lux')
-rw-r--r--stdlib/source/library/lux/control/try.lux18
1 files changed, 13 insertions, 5 deletions
diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux
index 52f58495a..4a6a35678 100644
--- a/stdlib/source/library/lux/control/try.lux
+++ b/stdlib/source/library/lux/control/try.lux
@@ -10,6 +10,7 @@
["." location]]]])
(type: #export (Try a)
+ {#.doc (doc "A computation that can fail with an error message.")}
(#Failure Text)
(#Success a))
@@ -59,12 +60,16 @@
ma)))
(implementation: #export (with monad)
- ## TODO: Replace (All [a] (M (Try a))) with (functor.Then M Try)
- (All [M] (-> (Monad M) (Monad (All [a] (M (Try a))))))
+ {#.doc (doc "Enhances a monad with error-handling functionality.")}
+ ## TODO: Replace (All [a] (! (Try a))) with (functor.Then ! Try)
+ (All [!] (-> (Monad !) (Monad (All [a] (! (Try a))))))
- (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor))
+ (def: &functor
+ (functor.compose (get@ #monad.&functor monad) ..functor))
- (def: in (|>> (\ ..monad in) (\ monad in)))
+ (def: in
+ (|>> (\ ..monad in)
+ (\ monad in)))
(def: (join MeMea)
(do monad
@@ -77,7 +82,8 @@
Mea))))
(def: #export (lifted monad)
- (All [M a] (-> (Monad M) (-> (M a) (M (Try a)))))
+ {#.doc (doc "Wraps a monadic value with error-handling machinery.")}
+ (All [! a] (-> (Monad !) (-> (! a) (! (Try a)))))
(\ monad map (\ ..monad in)))
(implementation: #export (equivalence (^open "_\."))
@@ -96,6 +102,8 @@
)))
(def: #export (assumed try)
+ {#.doc (doc "Assumes a Try value succeeded."
+ "If it didn't, raises the error as a runtime error.")}
(All [a] (-> (Try a) a))
(case try
(#Success value)