aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/phase.lux28
1 files changed, 14 insertions, 14 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase.lux b/stdlib/source/lux/tool/compiler/phase.lux
index 7107ac9da..596d94f6b 100644
--- a/stdlib/source/lux/tool/compiler/phase.lux
+++ b/stdlib/source/lux/tool/compiler/phase.lux
@@ -4,13 +4,13 @@
[monad (#+ Monad do)]]
[control
["." state]
+ ["." try (#+ Try) ("#@." functor)]
["ex" exception (#+ Exception exception:)]
["." io]
[parser
["s" code]]]
[data
["." product]
- ["." error (#+ Error) ("#@." functor)]
["." text
["%" format (#+ format)]]]
[time
@@ -20,38 +20,38 @@
[syntax (#+ syntax:)]]])
(type: #export (Operation s o)
- (state.State' Error s o))
+ (state.State' Try s o))
(def: #export monad
(All [s] (Monad (Operation s)))
- (state.with error.monad))
+ (state.with try.monad))
(type: #export (Phase s i o)
(-> i (Operation s o)))
(def: #export (run' state operation)
(All [s o]
- (-> s (Operation s o) (Error [s o])))
+ (-> s (Operation s o) (Try [s o])))
(operation state))
(def: #export (run state operation)
(All [s o]
- (-> s (Operation s o) (Error o)))
+ (-> s (Operation s o) (Try o)))
(|> state
operation
- (:: error.monad map product.right)))
+ (:: try.monad map product.right)))
(def: #export get-state
(All [s o]
(Operation s s))
(function (_ state)
- (#error.Success [state state])))
+ (#try.Success [state state])))
(def: #export (set-state state)
(All [s o]
(-> s (Operation s Any)))
(function (_ _)
- (#error.Success [state []])))
+ (#try.Success [state []])))
(def: #export (sub [get set] operation)
(All [s s' o]
@@ -59,22 +59,22 @@
(Operation s' o)
(Operation s o)))
(function (_ state)
- (do error.monad
+ (do try.monad
[[state' output] (operation (get state))]
(wrap [(set state' state) output]))))
(def: #export fail
(-> Text Operation)
- (|>> error.fail (state.lift error.monad)))
+ (|>> try.fail (state.lift try.monad)))
(def: #export (throw exception parameters)
(All [e] (-> (Exception e) e Operation))
(..fail (ex.construct exception parameters)))
(def: #export (lift error)
- (All [s a] (-> (Error a) (Operation s a)))
+ (All [s a] (-> (Try a) (Operation s a)))
(function (_ state)
- (error@map (|>> [state]) error)))
+ (try@map (|>> [state]) error)))
(syntax: #export (assert exception message test)
(wrap (list (` (if (~ test)
@@ -84,7 +84,7 @@
(def: #export identity
(All [s a] (Phase s a a))
(function (_ input state)
- (#error.Success [state input])))
+ (#try.Success [state input])))
(def: #export (compose pre post)
(All [s0 s1 i t o]
@@ -92,7 +92,7 @@
(Phase s1 t o)
(Phase [s0 s1] i o)))
(function (_ input [pre/state post/state])
- (do error.monad
+ (do try.monad
[[pre/state' temp] (pre input pre/state)
[post/state' output] (post temp post/state)]
(wrap [[pre/state' post/state'] output]))))