aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/phase.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/meta/compiler/phase.lux')
-rw-r--r--stdlib/source/library/lux/meta/compiler/phase.lux14
1 files changed, 13 insertions, 1 deletions
diff --git a/stdlib/source/library/lux/meta/compiler/phase.lux b/stdlib/source/library/lux/meta/compiler/phase.lux
index 77574a4aa..dd87d5866 100644
--- a/stdlib/source/library/lux/meta/compiler/phase.lux
+++ b/stdlib/source/library/lux/meta/compiler/phase.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except except with)
+ [lux (.except except with try)
[abstract
[functor (.only Functor)]
[monad (.only Monad do)]]
@@ -113,6 +113,18 @@
(at ..monad in [])
(..except exception message))]))
+(def .public (try it)
+ (All (_ state value)
+ (-> (Operation state value)
+ (Operation state (Try value))))
+ (function (_ state)
+ (when (it state)
+ {try.#Success [state' it']}
+ {try.#Success [state' {try.#Success it'}]}
+
+ {try.#Failure error}
+ {try.#Success [state {try.#Failure error}]})))
+
(def .public identity
(All (_ s a) (Phase s a a))
(function (_ archive input state)