aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux18
1 files changed, 18 insertions, 0 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index be6755ebe..d4e8efda6 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -5907,3 +5907,21 @@
_
(..fail (..wrong_syntax_error (name_of ..:let)))))
+
+(macro: #export (try tokens)
+ {#.doc (doc (case (try (risky_computation input))
+ (#.Right success)
+ (do_something success)
+
+ (#.Left error)
+ (recover_from_failure error)))}
+ (case tokens
+ (^ (list expression))
+ (do meta_monad
+ [g!_ (gensym "g!_")]
+ (wrap (list (` ("lux try"
+ (.function ((~ g!_) (~ g!_))
+ (~ expression)))))))
+
+ _
+ (..fail (..wrong_syntax_error (name_of ..try)))))