aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/abstract/codec.lux8
-rw-r--r--stdlib/source/lux/control/concurrency/actor.lux48
-rw-r--r--stdlib/source/lux/control/concurrency/frp.lux6
-rw-r--r--stdlib/source/lux/control/exception.lux19
-rw-r--r--stdlib/source/lux/control/parser.lux121
-rw-r--r--stdlib/source/lux/control/parser/binary.lux30
-rw-r--r--stdlib/source/lux/control/parser/cli.lux47
-rw-r--r--stdlib/source/lux/control/parser/code.lux73
-rw-r--r--stdlib/source/lux/control/parser/json.lux36
-rw-r--r--stdlib/source/lux/control/parser/synthesis.lux28
-rw-r--r--stdlib/source/lux/control/parser/text.lux80
-rw-r--r--stdlib/source/lux/control/parser/tree.lux18
-rw-r--r--stdlib/source/lux/control/parser/type.lux48
-rw-r--r--stdlib/source/lux/control/parser/xml.lux24
-rw-r--r--stdlib/source/lux/control/pipe.lux2
-rw-r--r--stdlib/source/lux/control/region.lux59
-rw-r--r--stdlib/source/lux/control/remember.lux10
-rw-r--r--stdlib/source/lux/control/try.lux (renamed from stdlib/source/lux/data/error.lux)36
-rw-r--r--stdlib/source/lux/data/binary.lux74
-rw-r--r--stdlib/source/lux/data/format/binary.lux18
-rw-r--r--stdlib/source/lux/data/format/context.lux12
-rw-r--r--stdlib/source/lux/data/format/json.lux40
-rw-r--r--stdlib/source/lux/data/format/xml.lux4
-rw-r--r--stdlib/source/lux/data/number.lux39
-rw-r--r--stdlib/source/lux/data/number/frac.lux29
-rw-r--r--stdlib/source/lux/data/number/int.lux13
-rw-r--r--stdlib/source/lux/data/number/nat.lux10
-rw-r--r--stdlib/source/lux/data/number/ratio.lux4
-rw-r--r--stdlib/source/lux/data/number/rev.lux16
-rw-r--r--stdlib/source/lux/data/text/encoding.lux15
-rw-r--r--stdlib/source/lux/data/text/regex.lux40
-rw-r--r--stdlib/source/lux/debug.lux10
-rw-r--r--stdlib/source/lux/host.jvm.lux6
-rw-r--r--stdlib/source/lux/host.old.lux6
-rw-r--r--stdlib/source/lux/macro.lux157
-rw-r--r--stdlib/source/lux/macro/poly/json.lux2
-rw-r--r--stdlib/source/lux/macro/syntax.lux1
-rw-r--r--stdlib/source/lux/math/modular.lux18
-rw-r--r--stdlib/source/lux/target/jvm/attribute.lux8
-rw-r--r--stdlib/source/lux/target/jvm/constant/pool.lux10
-rw-r--r--stdlib/source/lux/target/jvm/loader.lux14
-rw-r--r--stdlib/source/lux/target/jvm/program.lux22
-rw-r--r--stdlib/source/lux/target/jvm/program/condition.lux18
-rw-r--r--stdlib/source/lux/target/jvm/program/instruction.lux34
-rw-r--r--stdlib/source/lux/target/jvm/reflection.lux60
-rw-r--r--stdlib/source/lux/target/jvm/type.lux1
-rw-r--r--stdlib/source/lux/time/date.lux1
-rw-r--r--stdlib/source/lux/time/duration.lux4
-rw-r--r--stdlib/source/lux/time/instant.lux4
-rw-r--r--stdlib/source/lux/tool/compiler.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/analysis.lux50
-rw-r--r--stdlib/source/lux/tool/compiler/default/evaluation.lux5
-rw-r--r--stdlib/source/lux/tool/compiler/default/init.lux28
-rw-r--r--stdlib/source/lux/tool/compiler/default/platform.lux39
-rw-r--r--stdlib/source/lux/tool/compiler/default/syntax.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/meta/archive.lux26
-rw-r--r--stdlib/source/lux/tool/compiler/meta/archive/document.lux14
-rw-r--r--stdlib/source/lux/tool/compiler/meta/cache.lux8
-rw-r--r--stdlib/source/lux/tool/compiler/meta/io/archive.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/meta/io/context.lux26
-rw-r--r--stdlib/source/lux/tool/compiler/phase.lux28
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/case.lux8
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/case/coverage.lux34
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/module.lux100
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/scope.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/structure.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/type.lux13
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension.lux34
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux34
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/analysis/lux.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/statement/lux.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation.lux58
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/extension/common.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/extension/host.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/scheme/extension/common.lux1
-rw-r--r--stdlib/source/lux/tool/compiler/phase/macro.lux12
-rw-r--r--stdlib/source/lux/tool/compiler/phase/synthesis.lux10
-rw-r--r--stdlib/source/lux/tool/interpreter.lux18
-rw-r--r--stdlib/source/lux/tool/mediator.lux2
-rw-r--r--stdlib/source/lux/tool/mediator/parallelism.lux18
-rw-r--r--stdlib/source/lux/type/check.lux116
-rw-r--r--stdlib/source/lux/type/dynamic.lux10
-rw-r--r--stdlib/source/lux/world/console.lux12
-rw-r--r--stdlib/source/lux/world/db/jdbc.lux36
-rw-r--r--stdlib/source/lux/world/db/jdbc/input.lux16
-rw-r--r--stdlib/source/lux/world/db/jdbc/output.lux81
-rw-r--r--stdlib/source/lux/world/file.lux91
-rw-r--r--stdlib/source/lux/world/net.lux9
-rw-r--r--stdlib/source/lux/world/net/http.lux4
-rw-r--r--stdlib/source/lux/world/net/http/cookie.lux4
-rw-r--r--stdlib/source/lux/world/net/http/query.lux4
-rw-r--r--stdlib/source/lux/world/net/http/request.lux38
-rw-r--r--stdlib/source/lux/world/service/authentication.lux13
-rw-r--r--stdlib/source/lux/world/service/crud.lux11
-rw-r--r--stdlib/source/lux/world/service/inventory.lux13
-rw-r--r--stdlib/source/lux/world/service/journal.lux6
-rw-r--r--stdlib/source/lux/world/service/mail.lux9
-rw-r--r--stdlib/source/lux/world/shell.lux14
-rw-r--r--stdlib/source/program/compositor.lux30
-rw-r--r--stdlib/source/program/licentia.lux14
-rw-r--r--stdlib/source/program/scriptum.lux10
-rw-r--r--stdlib/source/spec/compositor.lux9
-rw-r--r--stdlib/source/spec/compositor/analysis/type.lux8
-rw-r--r--stdlib/source/spec/compositor/common.lux21
-rw-r--r--stdlib/source/spec/compositor/generation/case.lux24
-rw-r--r--stdlib/source/spec/compositor/generation/common.lux58
-rw-r--r--stdlib/source/spec/compositor/generation/function.lux1
-rw-r--r--stdlib/source/spec/compositor/generation/primitive.lux8
-rw-r--r--stdlib/source/spec/compositor/generation/reference.lux13
-rw-r--r--stdlib/source/spec/compositor/generation/structure.lux12
-rw-r--r--stdlib/source/test/lux/abstract/codec.lux9
-rw-r--r--stdlib/source/test/lux/control.lux2
-rw-r--r--stdlib/source/test/lux/control/concurrency/actor.lux12
-rw-r--r--stdlib/source/test/lux/control/parser.lux18
-rw-r--r--stdlib/source/test/lux/control/parser/cli.lux26
-rw-r--r--stdlib/source/test/lux/control/parser/text.lux12
-rw-r--r--stdlib/source/test/lux/control/region.lux21
-rw-r--r--stdlib/source/test/lux/control/try.lux (renamed from stdlib/source/test/lux/data/error.lux)14
-rw-r--r--stdlib/source/test/lux/data.lux2
-rw-r--r--stdlib/source/test/lux/data/binary.lux23
-rw-r--r--stdlib/source/test/lux/data/format/json.lux1
-rw-r--r--stdlib/source/test/lux/data/format/xml.lux2
-rw-r--r--stdlib/source/test/lux/data/number/rev.lux1
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux12
-rw-r--r--stdlib/source/test/lux/macro/poly/json.lux1
-rw-r--r--stdlib/source/test/lux/macro/syntax.lux4
-rw-r--r--stdlib/source/test/lux/math/modular.lux23
-rw-r--r--stdlib/source/test/lux/target/jvm.lux20
-rw-r--r--stdlib/source/test/lux/time/duration.lux2
-rw-r--r--stdlib/source/test/lux/tool/compiler/default/syntax.lux2
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux8
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/primitive.lux21
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux14
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux20
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/extension/analysis/lux.lux6
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux13
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux14
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/primitive.lux7
-rw-r--r--stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux8
-rw-r--r--stdlib/source/test/lux/type/dynamic.lux12
-rw-r--r--stdlib/source/test/lux/world/file.lux56
142 files changed, 1526 insertions, 1540 deletions
diff --git a/stdlib/source/lux/abstract/codec.lux b/stdlib/source/lux/abstract/codec.lux
index f0056f176..2a5048cf3 100644
--- a/stdlib/source/lux/abstract/codec.lux
+++ b/stdlib/source/lux/abstract/codec.lux
@@ -1,7 +1,7 @@
(.module:
[lux #*
- [data
- ["." error (#+ Error)]]]
+ [control
+ ["." try (#+ Try)]]]
[//
[monad (#+ do)]
["." functor]])
@@ -10,7 +10,7 @@
{#.doc "A way to move back-and-forth between a type and an alternative representation for it."}
(: (-> a m)
encode)
- (: (-> m (Error a))
+ (: (-> m (Try a))
decode))
(structure: #export (compose cb-codec ba-codec)
@@ -23,6 +23,6 @@
(:: cb-codec encode)))
(def: (decode cy)
- (do error.monad
+ (do try.monad
[by (:: cb-codec decode cy)]
(:: ba-codec decode by))))
diff --git a/stdlib/source/lux/control/concurrency/actor.lux b/stdlib/source/lux/control/concurrency/actor.lux
index 37117d260..6487801df 100644
--- a/stdlib/source/lux/control/concurrency/actor.lux
+++ b/stdlib/source/lux/control/concurrency/actor.lux
@@ -4,13 +4,13 @@
monad]
[control
["." function]
- ["p" parser
- ["s" code (#+ Parser)]]
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
- ["." io (#+ IO io) ("#;." monad)]]
+ ["." io (#+ IO io) ("#;." monad)]
+ ["p" parser
+ ["s" code (#+ Parser)]]]
[data
["." product]
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]
[collection
@@ -35,7 +35,7 @@
["Message" message-name]))
(with-expansions
- [<Message> (as-is (-> s (Actor s) (Promise (Error s))))
+ [<Message> (as-is (-> s (Actor s) (Promise (Try s))))
<Obituary> (as-is [Text s (List <Message>)])
<Mailbox> (as-is (Rec Mailbox
[(Promise [<Message> Mailbox])
@@ -79,7 +79,7 @@
(type: #export (Behavior s)
{#.doc "An actor's behavior when messages are received."}
- {#handle (-> (Message s) s (Actor s) (Promise (Error s)))
+ {#handle (-> (Message s) s (Actor s) (Promise (Try s)))
#end (-> Text s (Promise Any))})
(def: #export (spawn behavior init)
@@ -94,14 +94,14 @@
[[head tail] |mailbox|
?state' (handle head state self)]
(case ?state'
- (#error.Failure error)
+ (#try.Failure error)
(do @
[_ (end error state)]
(let [[_ resolve] (get@ #obituary (:representation self))]
(exec (io.run (resolve [error state (#.Cons head (..obituary tail))]))
(wrap []))))
- (#error.Success state')
+ (#try.Success state')
(recur state' tail))))]
self)))
@@ -140,7 +140,7 @@
)
(def: (default-handle message state self)
- (All [s] (-> (Message s) s (Actor s) (Promise (Error s))))
+ (All [s] (-> (Message s) s (Actor s) (Promise (Try s))))
(message state self))
(def: (default-end cause state)
@@ -239,7 +239,7 @@
(List a)
((handle message state self)
- (do (error.with promise.monad)
+ (do (try.with promise.monad)
[#let [_ (log! "BEFORE")]
output (message state self)
#let [_ (log! "AFTER")]]
@@ -271,7 +271,7 @@
(~ (code.local-identifier messageN))
(~ (code.local-identifier stateN))
(~ (code.local-identifier selfN)))
- ((~! do) ((~! error.with) (~! promise.monad))
+ ((~! do) ((~! try.with) (~! promise.monad))
[]
(~ bodyC))))))
#..end (~ (case ?stop
@@ -328,12 +328,12 @@
(message: #export Counter
(count! [increment Nat] state self Nat)
(let [state' (n/+ increment state)]
- (promise.resolved (#error.Success [state' state']))))
+ (promise.resolved (#try.Success [state' state']))))
(message: #export (Stack a)
(push [value a] state self (List a))
(let [state' (#.Cons value state)]
- (promise.resolved (#error.Success [state' state'])))))}
+ (promise.resolved (#try.Success [state' state'])))))}
(with-gensyms [g!_ g!return g!error g!task g!sent? g!resolve]
(do @
[current-module macro.current-module-name
@@ -369,28 +369,28 @@
(All [(~+ g!all-vars)]
(-> (~+ g!inputsT)
(~ actorC)
- ((~! promise.Promise) ((~! error.Error) (~ (get@ #output signature))))))
- (let [[(~ g!task) (~ g!resolve)] (: [((~! promise.Promise) ((~! error.Error) (~ g!outputT)))
- (promise.Resolver ((~! error.Error) (~ g!outputT)))]
+ ((~! promise.Promise) ((~! try.Try) (~ (get@ #output signature))))))
+ (let [[(~ g!task) (~ g!resolve)] (: [((~! promise.Promise) ((~! try.Try) (~ g!outputT)))
+ (promise.Resolver ((~! try.Try) (~ g!outputT)))]
(promise.promise []))]
((~! io.run) ((~! do) (~! io.monad)
[(~ g!sent?) (..send (function ((~ g!_) (~ g!state) (~ g!self))
((~! do) (~! promise.monad)
[(~ g!return) (: ((~! promise.Promise)
- ((~! error.Error)
+ ((~! try.Try)
[((~ g!type) (~+ g!actor-refs))
(~ g!outputT)]))
- ((~! do) ((~! error.with) (~! promise.monad))
+ ((~! do) ((~! try.with) (~! promise.monad))
[]
(~ body)))]
(case (~ g!return)
- (#error.Success [(~ g!state) (~ g!return)])
- (exec ((~! io.run) ((~ g!resolve) (#error.Success (~ g!return))))
- ((~! promise.resolved) (#error.Success (~ g!state))))
+ (#try.Success [(~ g!state) (~ g!return)])
+ (exec ((~! io.run) ((~ g!resolve) (#try.Success (~ g!return))))
+ ((~! promise.resolved) (#try.Success (~ g!state))))
- (#error.Failure (~ g!error))
- (exec ((~! io.run) ((~ g!resolve) (#error.Failure (~ g!error))))
- ((~! promise.resolved) (#error.Failure (~ g!error)))))
+ (#try.Failure (~ g!error))
+ (exec ((~! io.run) ((~ g!resolve) (#try.Failure (~ g!error))))
+ ((~! promise.resolved) (#try.Failure (~ g!error)))))
))
(~ g!self))]
(if (~ g!sent?)
diff --git a/stdlib/source/lux/control/concurrency/frp.lux b/stdlib/source/lux/control/concurrency/frp.lux
index ac145f78a..2be15ea23 100644
--- a/stdlib/source/lux/control/concurrency/frp.lux
+++ b/stdlib/source/lux/control/concurrency/frp.lux
@@ -7,11 +7,11 @@
[apply (#+ Apply)]
["." monad (#+ Monad do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
["." io (#+ IO io)]]
[data
["." maybe ("#@." functor)]
- ["." error (#+ Error)]
[collection
["." list ("#@." monoid)]]]
[type (#+ :share)
@@ -27,9 +27,9 @@
(exception: #export channel-is-already-closed)
(signature: #export (Sink a)
- (: (IO (Error Any))
+ (: (IO (Try Any))
close)
- (: (-> a (IO (Error Any)))
+ (: (-> a (IO (Try Any)))
feed))
(def: (sink resolve)
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux
index a8252977f..aac879cb7 100644
--- a/stdlib/source/lux/control/exception.lux
+++ b/stdlib/source/lux/control/exception.lux
@@ -6,7 +6,6 @@
["p" parser
["s" code (#+ Parser)]]]
[data
- ["//" error (#+ Error)]
["." maybe]
["." product]
["." text ("#@." monoid)]
@@ -20,7 +19,9 @@
[syntax
["cs" common
["csr" reader]
- ["csw" writer]]]]])
+ ["csw" writer]]]]]
+ [//
+ ["//" try (#+ Try)]])
(type: #export (Exception a)
{#.doc "An exception provides a way to decorate error messages."}
@@ -35,8 +36,8 @@
{#.doc (doc "If a particular exception is detected on a possibly-erroneous value, handle it."
"If no exception was detected, or a different one from the one being checked, then pass along the original value.")}
(All [e a]
- (-> (Exception e) (-> Text a) (Error a)
- (Error a)))
+ (-> (Exception e) (-> Text a) (Try a)
+ (Try a)))
(case try
(#//.Success output)
(#//.Success output)
@@ -53,7 +54,7 @@
(def: #export (otherwise to-do try)
{#.doc "If no handler could be found to catch the exception, then run a function as a last-resort measure."}
(All [a]
- (-> (-> Text a) (Error a) a))
+ (-> (-> Text a) (Try a) a))
(case try
(#//.Success output)
output
@@ -63,7 +64,7 @@
(def: #export (return value)
{#.doc "A way to lift normal values into the error-handling context."}
- (All [a] (-> a (Error a)))
+ (All [a] (-> a (Try a)))
(#//.Success value))
(def: #export (construct exception message)
@@ -73,11 +74,11 @@
(def: #export (throw exception message)
{#.doc "Decorate an error message with an Exception and lift it into the error-handling context."}
- (All [e] (-> (Exception e) e Error))
+ (All [e] (-> (Exception e) e Try))
(#//.Failure (construct exception message)))
(def: #export (assert exception message test)
- (All [e] (-> (Exception e) e Bit (Error Any)))
+ (All [e] (-> (Exception e) e Bit (Try Any)))
(if test
(#//.Success [])
(..throw exception message)))
@@ -154,7 +155,7 @@
error))
(def: #export (with-stack exception message computation)
- (All [e a] (-> (Exception e) e (Error a) (Error a)))
+ (All [e a] (-> (Exception e) e (Try a) (Try a)))
(case computation
(#//.Failure error)
(#//.Failure (case error
diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux
index 6642310b9..66799e067 100644
--- a/stdlib/source/lux/control/parser.lux
+++ b/stdlib/source/lux/control/parser.lux
@@ -5,15 +5,16 @@
[apply (#+ Apply)]
[monad (#+ Monad do)]
[codec (#+ Codec)]]
+ [control
+ ["." try (#+ Try)]]
[data
[collection
["." list ("#@." functor monoid)]]
- ["." product]
- ["." error (#+ Error)]]])
+ ["." product]]])
(type: #export (Parser s a)
{#.doc "A generic parser."}
- (-> s (Error [s a])))
+ (-> s (Try [s a])))
(structure: #export functor
(All [s] (Functor (Parser s)))
@@ -21,11 +22,11 @@
(def: (map f ma)
(function (_ input)
(case (ma input)
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [input' a])
- (#error.Success [input' (f a)])))))
+ (#try.Success [input' a])
+ (#try.Success [input' (f a)])))))
(structure: #export apply
(All [s] (Apply (Parser s)))
@@ -35,16 +36,16 @@
(def: (apply ff fa)
(function (_ input)
(case (ff input)
- (#error.Success [input' f])
+ (#try.Success [input' f])
(case (fa input')
- (#error.Success [input'' a])
- (#error.Success [input'' (f a)])
+ (#try.Success [input'' a])
+ (#try.Success [input'' (f a)])
- (#error.Failure msg)
- (#error.Failure msg))
+ (#try.Failure msg)
+ (#try.Failure msg))
- (#error.Failure msg)
- (#error.Failure msg)))))
+ (#try.Failure msg)
+ (#try.Failure msg)))))
(structure: #export monad
(All [s] (Monad (Parser s)))
@@ -53,15 +54,15 @@
(def: (wrap x)
(function (_ input)
- (#error.Success [input x])))
+ (#try.Success [input x])))
(def: (join mma)
(function (_ input)
(case (mma input)
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [input' ma])
+ (#try.Success [input' ma])
(ma input')))))
(def: #export (assert message test)
@@ -69,8 +70,8 @@
(All [s] (-> Text Bit (Parser s Any)))
(function (_ input)
(if test
- (#error.Success [input []])
- (#error.Failure message))))
+ (#try.Success [input []])
+ (#try.Failure message))))
(def: #export (maybe p)
{#.doc "Optionality combinator."}
@@ -78,15 +79,15 @@
(-> (Parser s a) (Parser s (Maybe a))))
(function (_ input)
(case (p input)
- (#error.Failure _)
- (#error.Success [input #.None])
+ (#try.Failure _)
+ (#try.Success [input #.None])
- (#error.Success [input' x])
- (#error.Success [input' (#.Some x)]))))
+ (#try.Success [input' x])
+ (#try.Success [input' (#.Some x)]))))
(def: #export (run p input)
(All [s a]
- (-> (Parser s a) s (Error [s a])))
+ (-> (Parser s a) s (Try [s a])))
(p input))
(def: #export (some p)
@@ -95,10 +96,10 @@
(-> (Parser s a) (Parser s (List a))))
(function (_ input)
(case (p input)
- (#error.Failure _)
- (#error.Success [input (list)])
+ (#try.Failure _)
+ (#try.Success [input (list)])
- (#error.Success [input' x])
+ (#try.Success [input' x])
(run (do ..monad
[xs (some p)]
(wrap (list& x xs)))
@@ -128,10 +129,10 @@
(-> (Parser s a) (Parser s b) (Parser s (| a b))))
(function (_ tokens)
(case (p1 tokens)
- (#error.Success [tokens' x1])
- (#error.Success [tokens' (0 x1)])
+ (#try.Success [tokens' x1])
+ (#try.Success [tokens' (0 x1)])
- (#error.Failure _)
+ (#try.Failure _)
(run (do ..monad
[x2 p2]
(wrap (1 x2)))
@@ -144,7 +145,7 @@
(-> (Parser s a) (Parser s a) (Parser s a)))
(function (_ tokens)
(case (pl tokens)
- (#error.Failure _)
+ (#try.Failure _)
(pr tokens)
output
@@ -175,10 +176,10 @@
(if (n/> 0 n)
(function (_ input)
(case (p input)
- (#error.Failure msg)
- (#error.Success [input (list)])
+ (#try.Failure msg)
+ (#try.Success [input (list)])
- (#error.Success [input' x])
+ (#try.Success [input' x])
(run (do ..monad
[xs (at-most (dec n) p)]
(wrap (#.Cons x xs)))
@@ -213,42 +214,42 @@
(All [s a] (-> (Parser s a) (Parser s Any)))
(function (_ input)
(case (p input)
- (#error.Failure msg)
- (#error.Success [input []])
+ (#try.Failure msg)
+ (#try.Success [input []])
_
- (#error.Failure "Expected to fail; yet succeeded."))))
+ (#try.Failure "Expected to fail; yet succeeded."))))
(def: #export (fail message)
(All [s a] (-> Text (Parser s a)))
(function (_ input)
- (#error.Failure message)))
+ (#try.Failure message)))
(def: #export (lift operation)
- (All [s a] (-> (Error a) (Parser s a)))
+ (All [s a] (-> (Try a) (Parser s a)))
(function (_ input)
(case operation
- (#error.Success output)
- (#error.Success [input output])
+ (#try.Success output)
+ (#try.Success [input output])
- (#error.Failure error)
- (#error.Failure error))))
+ (#try.Failure error)
+ (#try.Failure error))))
(def: #export (default value parser)
{#.doc "If the given parser fails, returns the default value."}
(All [s a] (-> a (Parser s a) (Parser s a)))
(function (_ input)
(case (parser input)
- (#error.Failure error)
- (#error.Success [input value])
+ (#try.Failure error)
+ (#try.Success [input value])
- (#error.Success [input' output])
- (#error.Success [input' output]))))
+ (#try.Success [input' output])
+ (#try.Success [input' output]))))
(def: #export remaining
(All [s] (Parser s s))
(function (_ inputs)
- (#error.Success [inputs inputs])))
+ (#try.Success [inputs inputs])))
(def: #export (rec parser)
{#.doc "Combinator for recursive parser."}
@@ -280,23 +281,23 @@
(All [s a] (-> (Parser s a) (Parser s Bit)))
(function (_ input)
(case (parser input)
- (#error.Failure error)
- (#error.Success [input false])
+ (#try.Failure error)
+ (#try.Success [input false])
- (#error.Success [input' _])
- (#error.Success [input' true]))))
+ (#try.Success [input' _])
+ (#try.Success [input' true]))))
(def: #export (codec Codec<a,z> parser)
(All [s a z] (-> (Codec a z) (Parser s a) (Parser s z)))
(function (_ input)
(case (parser input)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [input' to-decode])
+ (#try.Success [input' to-decode])
(case (:: Codec<a,z> decode to-decode)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success value)
- (#error.Success [input' value])))))
+ (#try.Success value)
+ (#try.Success [input' value])))))
diff --git a/stdlib/source/lux/control/parser/binary.lux b/stdlib/source/lux/control/parser/binary.lux
index 89a9c709d..5f8ccc122 100644
--- a/stdlib/source/lux/control/parser/binary.lux
+++ b/stdlib/source/lux/control/parser/binary.lux
@@ -4,9 +4,9 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." binary (#+ Binary)]
[number
["." frac]]
@@ -28,15 +28,15 @@
["Read bytes" (%.nat read)]))
(def: #export (run parser input)
- (All [a] (-> (Parser a) Binary (Error a)))
+ (All [a] (-> (Parser a) Binary (Try a)))
(case (parser [0 input])
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [[end _] output])
+ (#try.Success [[end _] output])
(let [length (binary.size input)]
(if (n/= end length)
- (#error.Success output)
+ (#try.Success output)
(exception.throw ..binary-was-not-fully-read [length end])))))
(type: #export Size Nat)
@@ -51,11 +51,11 @@
(Parser (I64 Any))
(function (_ [offset binary])
(case (<read> offset binary)
- (#error.Success data)
- (#error.Success [(n/+ <size> offset) binary] data)
+ (#try.Success data)
+ (#try.Success [(n/+ <size> offset) binary] data)
- (#error.Failure error)
- (#error.Failure error))))]
+ (#try.Failure error)
+ (#try.Failure error))))]
[bits/8 ..size/8 binary.read/8]
[bits/16 ..size/16 binary.read/16]
@@ -91,18 +91,18 @@
(Parser Bit)
(function (_ [offset binary])
(case (binary.read/8 offset binary)
- (#error.Success data)
+ (#try.Success data)
(case (: Nat data)
(^template [<nat> <bit>]
- <nat> (#error.Success [(inc offset) binary] <bit>))
+ <nat> (#try.Success [(inc offset) binary] <bit>))
([0 #0]
[1 #1])
_
(exception.throw ..invalid-tag [2 data]))
- (#error.Failure error)
- (#error.Failure error))))
+ (#try.Failure error)
+ (#try.Failure error))))
(def: #export nat (Parser Nat) (//@map .nat ..bits/64))
(def: #export int (Parser Int) (//@map .int ..bits/64))
@@ -118,7 +118,7 @@
(do //.monad
[size (//@map .nat <bits>)]
(function (_ [offset binary])
- (do error.monad
+ (do try.monad
[#let [end (n/+ size offset)]
output (binary.slice offset (.dec end) binary)]
(wrap [[end binary] output])))))]
diff --git a/stdlib/source/lux/control/parser/cli.lux b/stdlib/source/lux/control/parser/cli.lux
index fddea13d7..01c75a955 100644
--- a/stdlib/source/lux/control/parser/cli.lux
+++ b/stdlib/source/lux/control/parser/cli.lux
@@ -3,12 +3,13 @@
["@" target]
[abstract
[monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]]
[data
[collection
["." list ("#@." monoid monad)]]
["." text ("#@." equivalence)
- ["%" format (#+ format)]]
- ["." error (#+ Error)]]
+ ["%" format (#+ format)]]]
[macro (#+ with-gensyms)
["." code]
[syntax (#+ syntax:)]]]
@@ -24,18 +25,18 @@
(//.Parser (List Text) a))
(def: #export (run parser inputs)
- (All [a] (-> (Parser a) (List Text) (Error a)))
+ (All [a] (-> (Parser a) (List Text) (Try a)))
(case (//.run parser inputs)
- (#error.Success [remaining output])
+ (#try.Success [remaining output])
(case remaining
#.Nil
- (#error.Success output)
+ (#try.Success output)
_
- (#error.Failure (format "Remaining CLI inputs: " (text.join-with " " remaining))))
+ (#try.Failure (format "Remaining CLI inputs: " (text.join-with " " remaining))))
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure try)
+ (#try.Failure try)))
(def: #export any
{#.doc "Just returns the next input without applying any logic."}
@@ -43,16 +44,16 @@
(function (_ inputs)
(case inputs
(#.Cons arg inputs')
- (#error.Success [inputs' arg])
+ (#try.Success [inputs' arg])
_
- (#error.Failure "Cannot parse empty arguments."))))
+ (#try.Failure "Cannot parse empty arguments."))))
(def: #export (parse parser)
{#.doc "Parses the next input with a parsing function."}
- (All [a] (-> (-> Text (Error a)) (Parser a)))
+ (All [a] (-> (-> Text (Try a)) (Parser a)))
(function (_ inputs)
- (do error.monad
+ (do try.monad
[[remaining raw] (any inputs)
output (parser raw)]
(wrap [remaining output]))))
@@ -61,11 +62,11 @@
{#.doc "Checks that a token is in the inputs."}
(-> Text (Parser Any))
(function (_ inputs)
- (do error.monad
+ (do try.monad
[[remaining raw] (any inputs)]
(if (text@= reference raw)
(wrap [remaining []])
- (error.fail (format "Missing token: '" reference "'"))))))
+ (try.fail (format "Missing token: '" reference "'"))))))
(def: #export (somewhere cli)
{#.doc "Given a parser, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."}
@@ -73,16 +74,16 @@
(function (_ inputs)
(loop [immediate inputs]
(case (//.run cli immediate)
- (#error.Success [remaining output])
- (#error.Success [remaining output])
+ (#try.Success [remaining output])
+ (#try.Success [remaining output])
- (#error.Failure error)
+ (#try.Failure try)
(case immediate
#.Nil
- (#error.Failure error)
+ (#try.Failure try)
(#.Cons to-omit immediate')
- (do error.monad
+ (do try.monad
[[remaining output] (recur immediate')]
(wrap [(#.Cons to-omit remaining)
output])))))))
@@ -92,8 +93,8 @@
(Parser Any)
(function (_ inputs)
(case inputs
- #.Nil (#error.Success [inputs []])
- _ (#error.Failure (format "Unknown parameters: " (text.join-with " " inputs))))))
+ #.Nil (#try.Success [inputs []])
+ _ (#try.Failure (format "Unknown parameters: " (text.join-with " " inputs))))))
(def: #export (named name value)
(All [a] (-> Text (Parser a) (Parser a)))
@@ -168,10 +169,10 @@
(` process.run!)))))]
((~' wrap) (~ g!output))))))
(~ g!args))
- (#error.Success [(~ g!_) (~ g!output)])
+ (#try.Success [(~ g!_) (~ g!output)])
(~ g!output)
- (#error.Failure (~ g!message))
+ (#try.Failure (~ g!message))
(.error! (~ g!message))
))))
)))
diff --git a/stdlib/source/lux/control/parser/code.lux b/stdlib/source/lux/control/parser/code.lux
index 25009b447..33ff0abe2 100644
--- a/stdlib/source/lux/control/parser/code.lux
+++ b/stdlib/source/lux/control/parser/code.lux
@@ -2,10 +2,11 @@
[lux (#- nat int rev)
[abstract
["." monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]]
[data
["." bit]
["." name]
- ["." error (#+ Error)]
[number
["." nat]
["." int]
@@ -38,18 +39,18 @@
(Parser Code)
(function (_ tokens)
(case tokens
- #.Nil (#error.Failure "There are no tokens to parse!")
- (#.Cons [t tokens']) (#error.Success [tokens' t]))))
+ #.Nil (#try.Failure "There are no tokens to parse!")
+ (#.Cons [t tokens']) (#try.Success [tokens' t]))))
(template [<query> <assertion> <type> <tag> <eq> <desc>]
- [(with-expansions [<error> (as-is (#error.Failure ($_ text@compose "Cannot parse " <desc> (remaining-inputs tokens))))]
+ [(with-expansions [<error> (as-is (#try.Failure ($_ text@compose "Cannot parse " <desc> (remaining-inputs tokens))))]
(def: #export <query>
{#.doc (code.text ($_ text@compose "Parses the next " <desc> " input."))}
(Parser <type>)
(function (_ tokens)
(case tokens
(#.Cons [[_ (<tag> x)] tokens'])
- (#error.Success [tokens' x])
+ (#try.Success [tokens' x])
_
<error>)))
@@ -60,7 +61,7 @@
(case tokens
(#.Cons [[_ (<tag> actual)] tokens'])
(if (:: <eq> = expected actual)
- (#error.Success [tokens' []])
+ (#try.Success [tokens' []])
<error>)
_
@@ -83,12 +84,12 @@
(case tokens
(#.Cons [token tokens'])
(if (code@= ast token)
- (#error.Success [tokens' []])
- (#error.Failure ($_ text@compose "Expected a " (code.to-text ast) " but instead got " (code.to-text token)
- (remaining-inputs tokens))))
+ (#try.Success [tokens' []])
+ (#try.Failure ($_ text@compose "Expected a " (code.to-text ast) " but instead got " (code.to-text token)
+ (remaining-inputs tokens))))
_
- (#error.Failure "There are no tokens to parse!"))))
+ (#try.Failure "There are no tokens to parse!"))))
(template [<name> <tag> <desc>]
[(def: #export <name>
@@ -97,10 +98,10 @@
(function (_ tokens)
(case tokens
(#.Cons [[_ (<tag> ["" x])] tokens'])
- (#error.Success [tokens' x])
+ (#try.Success [tokens' x])
_
- (#error.Failure ($_ text@compose "Cannot parse local " <desc> (remaining-inputs tokens))))))]
+ (#try.Failure ($_ text@compose "Cannot parse local " <desc> (remaining-inputs tokens))))))]
[local-identifier #.Identifier "identifier"]
[ local-tag #.Tag "tag"]
@@ -115,11 +116,11 @@
(case tokens
(#.Cons [[_ (<tag> members)] tokens'])
(case (p members)
- (#error.Success [#.Nil x]) (#error.Success [tokens' x])
- _ (#error.Failure ($_ text@compose "Parser was expected to fully consume " <desc> (remaining-inputs tokens))))
+ (#try.Success [#.Nil x]) (#try.Success [tokens' x])
+ _ (#try.Failure ($_ text@compose "Parser was expected to fully consume " <desc> (remaining-inputs tokens))))
_
- (#error.Failure ($_ text@compose "Cannot parse " <desc> (remaining-inputs tokens))))))]
+ (#try.Failure ($_ text@compose "Cannot parse " <desc> (remaining-inputs tokens))))))]
[ form #.Form "form"]
[tuple #.Tuple "tuple"]
@@ -133,59 +134,59 @@
(case tokens
(#.Cons [[_ (#.Record pairs)] tokens'])
(case (p (join-pairs pairs))
- (#error.Success [#.Nil x]) (#error.Success [tokens' x])
- _ (#error.Failure ($_ text@compose "Parser was expected to fully consume record" (remaining-inputs tokens))))
+ (#try.Success [#.Nil x]) (#try.Success [tokens' x])
+ _ (#try.Failure ($_ text@compose "Parser was expected to fully consume record" (remaining-inputs tokens))))
_
- (#error.Failure ($_ text@compose "Cannot parse record" (remaining-inputs tokens))))))
+ (#try.Failure ($_ text@compose "Cannot parse record" (remaining-inputs tokens))))))
(def: #export end!
{#.doc "Ensures there are no more inputs."}
(Parser Any)
(function (_ tokens)
(case tokens
- #.Nil (#error.Success [tokens []])
- _ (#error.Failure ($_ text@compose "Expected list of tokens to be empty!" (remaining-inputs tokens))))))
+ #.Nil (#try.Success [tokens []])
+ _ (#try.Failure ($_ text@compose "Expected list of tokens to be empty!" (remaining-inputs tokens))))))
(def: #export end?
{#.doc "Checks whether there are no more inputs."}
(Parser Bit)
(function (_ tokens)
(case tokens
- #.Nil (#error.Success [tokens #1])
- _ (#error.Success [tokens #0]))))
+ #.Nil (#try.Success [tokens #1])
+ _ (#try.Success [tokens #0]))))
(def: #export (lift outcome)
- (All [a] (-> (Error a) (Parser a)))
+ (All [a] (-> (Try a) (Parser a)))
(function (_ input)
(case outcome
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success value)
- (#error.Success [input value])
+ (#try.Success value)
+ (#try.Success [input value])
)))
(def: #export (run syntax inputs)
- (All [a] (-> (Parser a) (List Code) (Error a)))
+ (All [a] (-> (Parser a) (List Code) (Try a)))
(case (syntax inputs)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [unconsumed value])
+ (#try.Success [unconsumed value])
(case unconsumed
#.Nil
- (#error.Success value)
+ (#try.Success value)
_
- (#error.Failure (text@compose "Unconsumed inputs: "
- (|> (list@map code.to-text unconsumed)
- (text.join-with ", ")))))))
+ (#try.Failure (text@compose "Unconsumed inputs: "
+ (|> (list@map code.to-text unconsumed)
+ (text.join-with ", ")))))))
(def: #export (local inputs syntax)
{#.doc "Run a syntax parser with the given list of inputs, instead of the real ones."}
(All [a] (-> (List Code) (Parser a) (Parser a)))
(function (_ real)
- (do error.monad
+ (do try.monad
[value (run syntax inputs)]
(wrap [real value]))))
diff --git a/stdlib/source/lux/control/parser/json.lux b/stdlib/source/lux/control/parser/json.lux
index 1ef75eab4..ed1620627 100644
--- a/stdlib/source/lux/control/parser/json.lux
+++ b/stdlib/source/lux/control/parser/json.lux
@@ -3,10 +3,10 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
["." bit]
- ["." error (#+ Error)]
["." text ("#@." equivalence monoid)]
[number
["." frac]]
@@ -31,23 +31,23 @@
(exception: #export empty-input)
(def: #export (run json parser)
- (All [a] (-> JSON (Parser a) (Error a)))
+ (All [a] (-> JSON (Parser a) (Try a)))
(case (//.run parser (list json))
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
- (#error.Success output)
+ (#try.Success output)
_
(exception.throw unconsumed-input remainder))
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
(def: #export (fail error)
(All [a] (-> Text (Parser a)))
(function (_ inputs)
- (#error.Failure error)))
+ (#try.Failure error)))
(def: #export any
{#.doc "Just returns the JSON input without applying any logic."}
@@ -58,7 +58,7 @@
(exception.throw empty-input [])
(#.Cons head tail)
- (#error.Success [tail head]))))
+ (#try.Success [tail head]))))
(template [<name> <type> <tag> <desc>]
[(def: #export <name>
@@ -124,10 +124,10 @@
(case head
(#/.Array values)
(case (//.run parser (row.to-list values))
- (#error.Failure error)
+ (#try.Failure error)
(fail error)
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
(wrap output)
@@ -151,10 +151,10 @@
(list (#/.String key) value)))
list.concat
(//.run parser))
- (#error.Failure error)
+ (#try.Failure error)
(fail error)
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
(wrap output)
@@ -173,15 +173,15 @@
(^ (list& (#/.String key) value inputs'))
(if (text@= key field-name)
(case (//.run parser (list value))
- (#error.Success [#.Nil output])
- (#error.Success [inputs' output])
+ (#try.Success [#.Nil output])
+ (#try.Success [inputs' output])
- (#error.Success [inputs'' _])
+ (#try.Success [inputs'' _])
(exception.throw unconsumed-input inputs'')
- (#error.Failure error)
- (#error.Failure error))
- (do error.monad
+ (#try.Failure error)
+ (#try.Failure error))
+ (do try.monad
[[inputs'' output] (recur inputs')]
(wrap [(list& (#/.String key) value inputs'')
output])))
diff --git a/stdlib/source/lux/control/parser/synthesis.lux b/stdlib/source/lux/control/parser/synthesis.lux
index a239b6931..784f08698 100644
--- a/stdlib/source/lux/control/parser/synthesis.lux
+++ b/stdlib/source/lux/control/parser/synthesis.lux
@@ -3,9 +3,9 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." bit]
["." name]
[number
@@ -41,15 +41,15 @@
(//.Parser ..Input))
(def: #export (run input parser)
- (All [a] (-> ..Input (Parser a) (Error a)))
+ (All [a] (-> ..Input (Parser a) (Try a)))
(case (parser input)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [#.Nil value])
- (#error.Success value)
+ (#try.Success [#.Nil value])
+ (#try.Success value)
- (#error.Success [unconsumed _])
+ (#try.Success [unconsumed _])
(exception.throw ..unconsumed-input unconsumed)))
(def: #export any
@@ -60,7 +60,7 @@
(exception.throw ..empty-input [])
(#.Cons [head tail])
- (#error.Success [tail head]))))
+ (#try.Success [tail head]))))
(template [<query> <assertion> <tag> <type> <eq>]
[(def: #export <query>
@@ -68,7 +68,7 @@
(.function (_ input)
(case input
(^ (list& (<tag> x) input'))
- (#error.Success [input' x])
+ (#try.Success [input' x])
_
(exception.throw ..cannot-parse input))))
@@ -79,7 +79,7 @@
(case input
(^ (list& (<tag> actual) input'))
(if (:: <eq> = expected actual)
- (#error.Success [input' []])
+ (#try.Success [input' []])
(exception.throw ..cannot-parse input))
_
@@ -99,9 +99,9 @@
(.function (_ input)
(case input
(^ (list& (/.tuple head) tail))
- (do error.monad
+ (do try.monad
[output (..run head parser)]
- (#error.Success [tail output]))
+ (#try.Success [tail output]))
_
(exception.throw ..cannot-parse input))))
@@ -112,9 +112,9 @@
(case input
(^ (list& (/.function/abstraction [environment actual body]) tail))
(if (n/= expected actual)
- (do error.monad
+ (do try.monad
[output (..run (list body) parser)]
- (#error.Success [tail [environment output]]))
+ (#try.Success [tail [environment output]]))
(exception.throw ..wrong-arity [expected actual]))
_
diff --git a/stdlib/source/lux/control/parser/text.lux b/stdlib/source/lux/control/parser/text.lux
index 7c7c7fe4a..0e57f02f6 100644
--- a/stdlib/source/lux/control/parser/text.lux
+++ b/stdlib/source/lux/control/parser/text.lux
@@ -3,11 +3,11 @@
[abstract
[monad (#+ Monad do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
["." product]
["." maybe]
- ["." error (#+ Error)]
["/" text ("#@." monoid)]
[number
["." nat ("#@." decimal)]]
@@ -47,20 +47,20 @@
(exception: #export cannot-slice)
(def: #export (run parser input)
- (All [a] (-> (Parser a) Text (Error a)))
+ (All [a] (-> (Parser a) Text (Try a)))
(case (parser [start-offset input])
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [[end-offset _] output])
+ (#try.Success [[end-offset _] output])
(if (n/= end-offset (/.size input))
- (#error.Success output)
+ (#try.Success output)
(exception.throw ..unconsumed-input [end-offset input]))))
(def: #export offset
(Parser Offset)
(function (_ (^@ input [offset tape]))
- (#error.Success [input offset])))
+ (#try.Success [input offset])))
(def: (with-slices parser)
(-> (Parser (List Slice)) (Parser Slice))
@@ -80,7 +80,7 @@
(function (_ [offset tape])
(case (/.nth offset tape)
(#.Some output)
- (#error.Success [[("lux i64 +" 1 offset) tape] (/.from-code output)])
+ (#try.Success [[("lux i64 +" 1 offset) tape] (/.from-code output)])
_
(exception.throw ..cannot-parse []))))
@@ -89,9 +89,9 @@
{#.doc "Just returns the next character without applying any logic."}
(Parser Slice)
(function (_ [offset tape])
- (#error.Success [[("lux i64 +" 1 offset) tape]
- {#basis offset
- #distance 1}])))
+ (#try.Success [[("lux i64 +" 1 offset) tape]
+ {#basis offset
+ #distance 1}])))
(template [<name> <type> <any>]
[(def: #export (<name> p)
@@ -99,7 +99,7 @@
(All [a] (-> (Parser a) (Parser <type>)))
(function (_ input)
(case (p input)
- (#error.Failure msg)
+ (#try.Failure msg)
(<any> input)
_
@@ -116,12 +116,12 @@
(case (/.index-of' reference offset tape)
(#.Some where)
(if (n/= offset where)
- (#error.Success [[("lux i64 +" (/.size reference) offset) tape]
- []])
- (#error.Failure ($_ /@compose "Could not match: " (/.encode reference) " @ " (maybe.assume (/.clip' offset tape)))))
+ (#try.Success [[("lux i64 +" (/.size reference) offset) tape]
+ []])
+ (#try.Failure ($_ /@compose "Could not match: " (/.encode reference) " @ " (maybe.assume (/.clip' offset tape)))))
_
- (#error.Failure ($_ /@compose "Could not match: " (/.encode reference))))))
+ (#try.Failure ($_ /@compose "Could not match: " (/.encode reference))))))
(def: #export (this? reference)
{#.doc "Lex a text if it matches the given sample."}
@@ -129,25 +129,25 @@
(function (_ (^@ input [offset tape]))
(case (/.index-of' reference offset tape)
(^multi (#.Some where) (n/= offset where))
- (#error.Success [[("lux i64 +" (/.size reference) offset) tape]
- #1])
+ (#try.Success [[("lux i64 +" (/.size reference) offset) tape]
+ #1])
_
- (#error.Success [input #0]))))
+ (#try.Success [input #0]))))
(def: #export end
{#.doc "Ensure the parser's input is empty."}
(Parser Any)
(function (_ (^@ input [offset tape]))
(if (n/= offset (/.size tape))
- (#error.Success [input []])
+ (#try.Success [input []])
(exception.throw ..unconsumed-input input))))
(def: #export end?
{#.doc "Ask if the parser's input is empty."}
(Parser Bit)
(function (_ (^@ input [offset tape]))
- (#error.Success [input (n/= offset (/.size tape))])))
+ (#try.Success [input (n/= offset (/.size tape))])))
(def: #export peek
{#.doc "Lex the next character (without consuming it from the input)."}
@@ -155,7 +155,7 @@
(function (_ (^@ input [offset tape]))
(case (/.nth offset tape)
(#.Some output)
- (#error.Success [input (/.from-code output)])
+ (#try.Success [input (/.from-code output)])
_
(exception.throw ..cannot-parse []))))
@@ -164,7 +164,7 @@
{#.doc "Get all of the remaining input (without consuming it)."}
(Parser Text)
(function (_ (^@ input [offset tape]))
- (#error.Success [input (remaining offset tape)])))
+ (#try.Success [input (remaining offset tape)])))
(def: #export (range bottom top)
{#.doc "Only lex characters within a range."}
@@ -216,10 +216,10 @@
(#.Some output)
(let [output (/.from-code output)]
(if (<modifier> (/.contains? output options))
- (#error.Success [[("lux i64 +" 1 offset) tape] output])
- (#error.Failure ($_ /@compose "Character (" output
- ") is should " <description-modifier>
- "be one of: " options))))
+ (#try.Success [[("lux i64 +" 1 offset) tape] output])
+ (#try.Failure ($_ /@compose "Character (" output
+ ") is should " <description-modifier>
+ "be one of: " options))))
_
(exception.throw ..cannot-parse []))))]
@@ -237,12 +237,12 @@
(#.Some output)
(let [output (/.from-code output)]
(if (<modifier> (/.contains? output options))
- (#error.Success [[("lux i64 +" 1 offset) tape]
- {#basis offset
- #distance 1}])
- (#error.Failure ($_ /@compose "Character (" output
- ") is should " <description-modifier>
- "be one of: " options))))
+ (#try.Success [[("lux i64 +" 1 offset) tape]
+ {#basis offset
+ #distance 1}])
+ (#try.Failure ($_ /@compose "Character (" output
+ ") is should " <description-modifier>
+ "be one of: " options))))
_
(exception.throw ..cannot-parse []))))]
@@ -258,8 +258,8 @@
(case (/.nth offset tape)
(#.Some output)
(if (p output)
- (#error.Success [[("lux i64 +" 1 offset) tape] (/.from-code output)])
- (#error.Failure ($_ /@compose "Character does not satisfy predicate: " (/.from-code output))))
+ (#try.Success [[("lux i64 +" 1 offset) tape] (/.from-code output)])
+ (#try.Failure ($_ /@compose "Character does not satisfy predicate: " (/.from-code output))))
_
(exception.throw ..cannot-parse []))))
@@ -346,11 +346,11 @@
(All [a] (-> Text (Parser a) (Parser a)))
(function (_ real-input)
(case (run parser local-input)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success value)
- (#error.Success [real-input value]))))
+ (#try.Success value)
+ (#try.Success [real-input value]))))
(def: #export (slice parser)
(-> (Parser Slice) (Parser Text))
@@ -359,7 +359,7 @@
(function (_ (^@ input [offset tape]))
(case (/.clip basis ("lux i64 +" basis distance) tape)
(#.Some output)
- (#error.Success [input output])
+ (#try.Success [input output])
#.None
(exception.throw ..cannot-slice [])))))
diff --git a/stdlib/source/lux/control/parser/tree.lux b/stdlib/source/lux/control/parser/tree.lux
index 50c8c8a0e..3dbc5522d 100644
--- a/stdlib/source/lux/control/parser/tree.lux
+++ b/stdlib/source/lux/control/parser/tree.lux
@@ -1,9 +1,9 @@
(.module:
[lux #*
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
[tree (#+ Tree)
["." zipper (#+ Zipper)]]]]
["." //])
@@ -12,22 +12,22 @@
(//.Parser (Zipper t) a))
(def: #export (run-zipper zipper parser)
- (All [t a] (-> (Zipper t) (Parser t a) (Error a)))
+ (All [t a] (-> (Zipper t) (Parser t a) (Try a)))
(case (//.run zipper parser)
- (#error.Success [zipper output])
- (#error.Success output)
+ (#try.Success [zipper output])
+ (#try.Success output)
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
(def: #export (run tree parser)
- (All [t a] (-> (Tree t) (Parser t a) (Error a)))
+ (All [t a] (-> (Tree t) (Parser t a) (Try a)))
(run-zipper (zipper.zip tree) parser))
(def: #export value
(All [t] (Parser t t))
(function (_ zipper)
- (#error.Success [zipper (zipper.value zipper)])))
+ (#try.Success [zipper (zipper.value zipper)])))
(exception: #export cannot-move-further)
@@ -38,7 +38,7 @@
(let [next (<direction> zipper)]
(if (is? zipper next)
(exception.throw cannot-move-further [])
- (#error.Success [next []])))))]
+ (#try.Success [next []])))))]
[up zipper.up]
[down zipper.down]
diff --git a/stdlib/source/lux/control/parser/type.lux b/stdlib/source/lux/control/parser/type.lux
index 3fe852739..6e42cad87 100644
--- a/stdlib/source/lux/control/parser/type.lux
+++ b/stdlib/source/lux/control/parser/type.lux
@@ -3,11 +3,11 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]
["." function]]
[data
["." name ("#@." codec)]
- ["." error (#+ Error)]
[number
["." nat ("#@." decimal)]]
["." text ("#@." monoid)
@@ -63,67 +63,67 @@
(def: #export fresh Env (dictionary.new nat.hash))
(def: (run' env types poly)
- (All [a] (-> Env (List Type) (Parser a) (Error a)))
+ (All [a] (-> Env (List Type) (Parser a) (Try a)))
(case (//.run poly [env types])
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [[env' remaining] output])
+ (#try.Success [[env' remaining] output])
(case remaining
#.Nil
- (#error.Success output)
+ (#try.Success output)
_
(exception.throw unconsumed remaining))))
(def: #export (run type poly)
- (All [a] (-> Type (Parser a) (Error a)))
+ (All [a] (-> Type (Parser a) (Try a)))
(run' fresh (list type) poly))
(def: #export env
(Parser Env)
(.function (_ [env inputs])
- (#error.Success [[env inputs] env])))
+ (#try.Success [[env inputs] env])))
(def: (with-env temp poly)
(All [a] (-> Env (Parser a) (Parser a)))
(.function (_ [env inputs])
(case (//.run poly [temp inputs])
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [[_ remaining] output])
- (#error.Success [[env remaining] output]))))
+ (#try.Success [[_ remaining] output])
+ (#try.Success [[env remaining] output]))))
(def: #export peek
(Parser Type)
(.function (_ [env inputs])
(case inputs
#.Nil
- (#error.Failure "Empty stream of types.")
+ (#try.Failure "Empty stream of types.")
(#.Cons headT tail)
- (#error.Success [[env inputs] headT]))))
+ (#try.Success [[env inputs] headT]))))
(def: #export any
(Parser Type)
(.function (_ [env inputs])
(case inputs
#.Nil
- (#error.Failure "Empty stream of types.")
+ (#try.Failure "Empty stream of types.")
(#.Cons headT tail)
- (#error.Success [[env tail] headT]))))
+ (#try.Success [[env tail] headT]))))
(def: #export (local types poly)
(All [a] (-> (List Type) (Parser a) (Parser a)))
(.function (_ [env pass-through])
(case (run' env types poly)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success output)
- (#error.Success [[env pass-through] output]))))
+ (#try.Success output)
+ (#try.Success [[env pass-through] output]))))
(def: (label idx)
(-> Nat Code)
@@ -137,11 +137,11 @@
(case (//.run poly
[(dictionary.put current-id [type g!var] env)
inputs])
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [[_ inputs'] output])
- (#error.Success [[env inputs'] [g!var output]])))))
+ (#try.Success [[_ inputs'] output])
+ (#try.Success [[env inputs'] [g!var output]])))))
(template [<name> <flattener> <tag> <exception>]
[(def: #export (<name> poly)
diff --git a/stdlib/source/lux/control/parser/xml.lux b/stdlib/source/lux/control/parser/xml.lux
index be5c0f7b6..f9ac14f8f 100644
--- a/stdlib/source/lux/control/parser/xml.lux
+++ b/stdlib/source/lux/control/parser/xml.lux
@@ -3,9 +3,9 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." name ("#@." equivalence codec)]
["." text ("#@." monoid)]
[collection
@@ -43,7 +43,7 @@
(#.Cons head tail)
(case head
(#/.Text value)
- (#error.Success [tail value])
+ (#try.Success [tail value])
(#/.Node _)
(exception.throw unexpected-input [])))))
@@ -66,18 +66,18 @@
(exception.throw unknown-attribute [])
(#.Some value)
- (#error.Success [docs value]))))))
+ (#try.Success [docs value]))))))
(def: (run' reader docs)
- (All [a] (-> (Parser a) (List XML) (Error a)))
+ (All [a] (-> (Parser a) (List XML) (Try a)))
(case (//.run reader docs)
- (#error.Success [remaining output])
+ (#try.Success [remaining output])
(if (list.empty? remaining)
- (#error.Success output)
+ (#try.Success output)
(exception.throw unconsumed-inputs remaining))
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
(def: #export (node tag)
(-> Name (Parser Any))
@@ -93,7 +93,7 @@
(#/.Node _tag _attrs _children)
(if (name@= tag _tag)
- (#error.Success [docs []])
+ (#try.Success [docs []])
(exception.throw wrong-tag tag))))))
(def: #export (children reader)
@@ -109,7 +109,7 @@
(exception.throw unexpected-input [])
(#/.Node _tag _attrs _children)
- (do error.monad
+ (do try.monad
[output (run' reader _children)]
(wrap [tail output]))))))
@@ -121,8 +121,8 @@
(exception.throw empty-input [])
(#.Cons head tail)
- (#error.Success [tail []]))))
+ (#try.Success [tail []]))))
(def: #export (run reader document)
- (All [a] (-> (Parser a) XML (Error a)))
+ (All [a] (-> (Parser a) XML (Try a)))
(run' reader (list document)))
diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux
index a53b61164..929da9a46 100644
--- a/stdlib/source/lux/control/pipe.lux
+++ b/stdlib/source/lux/control/pipe.lux
@@ -3,10 +3,10 @@
[abstract
[monad (#+ do)]]
[control
+ ["e" try]
["p" parser
["s" code (#+ Parser)]]]
[data
- ["e" error]
[collection
["." list ("#;." fold monad)]]]
[macro (#+ with-gensyms)
diff --git a/stdlib/source/lux/control/region.lux b/stdlib/source/lux/control/region.lux
index de90f4cea..23e46353e 100644
--- a/stdlib/source/lux/control/region.lux
+++ b/stdlib/source/lux/control/region.lux
@@ -4,8 +4,9 @@
[functor (#+ Functor)]
[apply (#+ Apply)]
["." monad (#+ Monad do)]]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[collection
@@ -14,12 +15,12 @@
["ex" exception (#+ Exception exception:)]])
(type: (Cleaner r m)
- (-> r (m (Error Any))))
+ (-> r (m (Try Any))))
(type: #export (Region r m a)
(-> [r (List (Cleaner r m))]
(m [(List (Cleaner r m))
- (Error a)])))
+ (Try a)])))
(def: separator
Text
@@ -30,29 +31,29 @@
text.new-line))
(exception: #export [a] (clean-up-error {error Text}
- {output (Error a)})
+ {output (Try a)})
(format error
(case output
- (#error.Success _)
+ (#try.Success _)
""
- (#error.Failure error|output)
+ (#try.Failure error|output)
(format separator
error|output))))
(def: (combine-outcomes clean-up output)
- (All [a] (-> (Error Any) (Error a) (Error a)))
+ (All [a] (-> (Try Any) (Try a) (Try a)))
(case clean-up
- (#error.Success _)
+ (#try.Success _)
output
- (#error.Failure error|clean-up)
+ (#try.Failure error|clean-up)
(ex.throw clean-up-error [error|clean-up output])))
(def: #export (run Monad<m> computation)
(All [m a]
(-> (Monad m) (All [r] (Region r m a))
- (m (Error a))))
+ (m (Try a))))
(do Monad<m>
[[cleaners output] (computation [[] (list)])
results (monad.map @ (function (_ cleaner) (cleaner []))
@@ -60,12 +61,12 @@
(wrap (list;fold combine-outcomes output results))))
(def: #export (acquire Monad<m> cleaner value)
- (All [m a] (-> (Monad m) (-> a (m (Error Any))) a
+ (All [m a] (-> (Monad m) (-> a (m (Try Any))) a
(All [r] (Region r m a))))
(function (_ [region cleaners])
(:: Monad<m> wrap [(#.Cons (function (_ region) (cleaner value))
cleaners)
- (#error.Success value)])))
+ (#try.Success value)])))
(structure: #export (functor Functor<m>)
(All [m]
@@ -78,11 +79,11 @@
(:: Functor<m> map
(function (_ [cleaners' temp])
[cleaners' (case temp
- (#error.Success value)
- (#error.Success (f value))
+ (#try.Success value)
+ (#try.Success (f value))
- (#error.Failure error)
- (#error.Failure error))])
+ (#try.Failure error)
+ (#try.Failure error))])
(fa region+cleaners))))))
(structure: #export (apply Monad<m>)
@@ -99,16 +100,16 @@
[[cleaners ef] (ff [region cleaners])
[cleaners ea] (fa [region cleaners])]
(case ef
- (#error.Success f)
+ (#try.Success f)
(case ea
- (#error.Success a)
- (wrap [cleaners (#error.Success (f a))])
+ (#try.Success a)
+ (wrap [cleaners (#try.Success (f a))])
- (#error.Failure error)
- (wrap [cleaners (#error.Failure error)]))
+ (#try.Failure error)
+ (wrap [cleaners (#try.Failure error)]))
- (#error.Failure error)
- (wrap [cleaners (#error.Failure error)]))))))
+ (#try.Failure error)
+ (wrap [cleaners (#try.Failure error)]))))))
(structure: #export (monad Monad<m>)
(All [m]
@@ -120,25 +121,25 @@
(def: (wrap value)
(function (_ [region cleaners])
- (:: Monad<m> wrap [cleaners (#error.Success value)])))
+ (:: Monad<m> wrap [cleaners (#try.Success value)])))
(def: (join ffa)
(function (_ [region cleaners])
(do Monad<m>
[[cleaners efa] (ffa [region cleaners])]
(case efa
- (#error.Success fa)
+ (#try.Success fa)
(fa [region cleaners])
- (#error.Failure error)
- (wrap [cleaners (#error.Failure error)]))))))
+ (#try.Failure error)
+ (wrap [cleaners (#try.Failure error)]))))))
(def: #export (fail Monad<m> error)
(All [m a]
(-> (Monad m) Text
(All [r] (Region r m a))))
(function (_ [region cleaners])
- (:: Monad<m> wrap [cleaners (#error.Failure error)])))
+ (:: Monad<m> wrap [cleaners (#try.Failure error)])))
(def: #export (throw Monad<m> exception message)
(All [m e a]
@@ -154,4 +155,4 @@
(function (_ [region cleaners])
(do Monad<m>
[output operation]
- (wrap [cleaners (#error.Success output)]))))
+ (wrap [cleaners (#try.Success output)]))))
diff --git a/stdlib/source/lux/control/remember.lux b/stdlib/source/lux/control/remember.lux
index 6dd930b88..1bf5097ab 100644
--- a/stdlib/source/lux/control/remember.lux
+++ b/stdlib/source/lux/control/remember.lux
@@ -3,11 +3,11 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try]
+ ["ex" exception (#+ exception:)]
["p" parser ("#@." functor)
- ["s" code (#+ Parser)]]
- ["ex" exception (#+ exception:)]]
+ ["s" code (#+ Parser)]]]
[data
- ["." error]
["." text
["%" format (#+ format)]]]
[time
@@ -35,10 +35,10 @@
(do p.monad
[raw s.text]
(case (:: date.codec decode raw)
- (#error.Success date)
+ (#try.Success date)
(wrap date)
- (#error.Failure message)
+ (#try.Failure message)
(p.fail message)))))
(syntax: #export (remember {deadline ..deadline} {message s.text} {focus (p.maybe s.any)})
diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/control/try.lux
index c730ee5a5..66c325c65 100644
--- a/stdlib/source/lux/data/error.lux
+++ b/stdlib/source/lux/control/try.lux
@@ -6,12 +6,12 @@
["." monad (#+ Monad do)]
[equivalence (#+ Equivalence)]]])
-(type: #export (Error a)
+(type: #export (Try a)
(#Failure Text)
(#Success a))
(structure: #export functor
- (Functor Error)
+ (Functor Try)
(def: (map f ma)
(case ma
@@ -22,7 +22,7 @@
(#Success (f datum)))))
(structure: #export apply
- (Apply Error)
+ (Apply Try)
(def: &functor ..functor)
@@ -41,7 +41,7 @@
))
(structure: #export monad
- (Monad Error)
+ (Monad Try)
(def: &functor ..functor)
@@ -57,8 +57,8 @@
ma)))
(structure: #export (with monad)
- ## TODO: Replace (All [a] (M (Error a))) with (functor.Then M Error)
- (All [M] (-> (Monad M) (Monad (All [a] (M (Error a))))))
+ ## TODO: Replace (All [a] (M (Try a))) with (functor.Then M Try)
+ (All [M] (-> (Monad M) (Monad (All [a] (M (Try a))))))
(def: &functor (functor.compose (get@ #monad.&functor monad) ..functor))
@@ -68,18 +68,18 @@
(do monad
[eMea MeMea]
(case eMea
- (#Failure error)
- (wrap (#Failure error))
+ (#Failure try)
+ (wrap (#Failure try))
(#Success Mea)
Mea))))
(def: #export (lift monad)
- (All [M a] (-> (Monad M) (-> (M a) (M (Error a)))))
+ (All [M a] (-> (Monad M) (-> (M a) (M (Try a)))))
(monad.lift monad (:: ..monad wrap)))
(structure: #export (equivalence (^open ",@."))
- (All [a] (-> (Equivalence a) (Equivalence (Error a))))
+ (All [a] (-> (Equivalence a) (Equivalence (Try a))))
(def: (= reference sample)
(case [reference sample]
@@ -94,16 +94,16 @@
)))
(def: #export (succeed value)
- (All [a] (-> a (Error a)))
+ (All [a] (-> a (Try a)))
(#Success value))
(def: #export (fail message)
- (-> Text Error)
+ (-> Text Try)
(#Failure message))
-(def: #export (assume error)
- (All [a] (-> (Error a) a))
- (case error
+(def: #export (assume try)
+ (All [a] (-> (Try a) a))
+ (case try
(#Success value)
value
@@ -112,14 +112,14 @@
(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."
+ "if a (Try x) value turns out to be #Failure."
(= "bar"
(default "foo" (#Success "bar")))
(= "foo"
(default "foo" (#Failure "KABOOM!"))))}
(case tokens
- (^ (list else error))
- (#Success [compiler (list (` (case (~ error)
+ (^ (list else try))
+ (#Success [compiler (list (` (case (~ try)
(#..Success (~' g!temp))
(~' g!temp)
diff --git a/stdlib/source/lux/data/binary.lux b/stdlib/source/lux/data/binary.lux
index 485aab536..019cf6482 100644
--- a/stdlib/source/lux/data/binary.lux
+++ b/stdlib/source/lux/data/binary.lux
@@ -6,10 +6,10 @@
[monad (#+ do)]
[equivalence (#+ Equivalence)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
["." maybe]
- ["." error (#+ Error)]
[number
["." i64]]
[text
@@ -129,73 +129,73 @@
(|>> .nat-to-frac [] ArrayBuffer::new Uint8Array::new)})))
(def: #export (read/8 idx binary)
- (-> Nat Binary (Error I64))
+ (-> Nat Binary (Try I64))
(if (n/< (..!size binary) idx)
- (#error.Success (!read idx binary))
+ (#try.Success (!read idx binary))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (read/16 idx binary)
- (-> Nat Binary (Error I64))
+ (-> Nat Binary (Try I64))
(if (n/< (..!size binary) (n/+ 1 idx))
- (#error.Success ($_ i64.or
- (i64.left-shift 8 (!read idx binary))
- (!read (n/+ 1 idx) binary)))
+ (#try.Success ($_ i64.or
+ (i64.left-shift 8 (!read idx binary))
+ (!read (n/+ 1 idx) binary)))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (read/32 idx binary)
- (-> Nat Binary (Error I64))
+ (-> Nat Binary (Try I64))
(if (n/< (..!size binary) (n/+ 3 idx))
- (#error.Success ($_ i64.or
- (i64.left-shift 24 (!read idx binary))
- (i64.left-shift 16 (!read (n/+ 1 idx) binary))
- (i64.left-shift 8 (!read (n/+ 2 idx) binary))
- (!read (n/+ 3 idx) binary)))
+ (#try.Success ($_ i64.or
+ (i64.left-shift 24 (!read idx binary))
+ (i64.left-shift 16 (!read (n/+ 1 idx) binary))
+ (i64.left-shift 8 (!read (n/+ 2 idx) binary))
+ (!read (n/+ 3 idx) binary)))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (read/64 idx binary)
- (-> Nat Binary (Error I64))
+ (-> Nat Binary (Try I64))
(if (n/< (..!size binary) (n/+ 7 idx))
- (#error.Success ($_ i64.or
- (i64.left-shift 56 (!read idx binary))
- (i64.left-shift 48 (!read (n/+ 1 idx) binary))
- (i64.left-shift 40 (!read (n/+ 2 idx) binary))
- (i64.left-shift 32 (!read (n/+ 3 idx) binary))
- (i64.left-shift 24 (!read (n/+ 4 idx) binary))
- (i64.left-shift 16 (!read (n/+ 5 idx) binary))
- (i64.left-shift 8 (!read (n/+ 6 idx) binary))
- (!read (n/+ 7 idx) binary)))
+ (#try.Success ($_ i64.or
+ (i64.left-shift 56 (!read idx binary))
+ (i64.left-shift 48 (!read (n/+ 1 idx) binary))
+ (i64.left-shift 40 (!read (n/+ 2 idx) binary))
+ (i64.left-shift 32 (!read (n/+ 3 idx) binary))
+ (i64.left-shift 24 (!read (n/+ 4 idx) binary))
+ (i64.left-shift 16 (!read (n/+ 5 idx) binary))
+ (i64.left-shift 8 (!read (n/+ 6 idx) binary))
+ (!read (n/+ 7 idx) binary)))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (write/8 idx value binary)
- (-> Nat (I64 Any) Binary (Error Binary))
+ (-> Nat (I64 Any) Binary (Try Binary))
(if (n/< (..!size binary) idx)
(exec (|> binary
(!write idx value))
- (#error.Success binary))
+ (#try.Success binary))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (write/16 idx value binary)
- (-> Nat (I64 Any) Binary (Error Binary))
+ (-> Nat (I64 Any) Binary (Try Binary))
(if (n/< (..!size binary) (n/+ 1 idx))
(exec (|> binary
(!write idx (i64.logic-right-shift 8 value))
(!write (n/+ 1 idx) value))
- (#error.Success binary))
+ (#try.Success binary))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (write/32 idx value binary)
- (-> Nat (I64 Any) Binary (Error Binary))
+ (-> Nat (I64 Any) Binary (Try Binary))
(if (n/< (..!size binary) (n/+ 3 idx))
(exec (|> binary
(!write idx (i64.logic-right-shift 24 value))
(!write (n/+ 1 idx) (i64.logic-right-shift 16 value))
(!write (n/+ 2 idx) (i64.logic-right-shift 8 value))
(!write (n/+ 3 idx) value))
- (#error.Success binary))
+ (#try.Success binary))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(def: #export (write/64 idx value binary)
- (-> Nat (I64 Any) Binary (Error Binary))
+ (-> Nat (I64 Any) Binary (Try Binary))
(if (n/< (..!size binary) (n/+ 7 idx))
(exec (|> binary
(!write idx (i64.logic-right-shift 56 value))
@@ -206,7 +206,7 @@
(!write (n/+ 5 idx) (i64.logic-right-shift 16 value))
(!write (n/+ 6 idx) (i64.logic-right-shift 8 value))
(!write (n/+ 7 idx) value))
- (#error.Success binary))
+ (#try.Success binary))
(exception.throw index-out-of-bounds [(..!size binary) idx])))
(structure: #export equivalence (Equivalence Binary)
@@ -240,8 +240,8 @@
["Target output space" (%.nat target-output)]))))
(def: #export (copy bytes source-offset source target-offset target)
- (-> Nat Nat Binary Nat Binary (Error Binary))
- (with-expansions [<for-jvm> (as-is (do error.monad
+ (-> Nat Nat Binary Nat Binary (Try Binary))
+ (with-expansions [<for-jvm> (as-is (do try.monad
[_ (java/lang/System::arraycopy source (.int source-offset) target (.int target-offset) (.int bytes))]
(wrap target)))]
(`` (for {(~~ (static @.old))
@@ -260,16 +260,16 @@
(!read (n/+ source-offset idx) source)
target)
(recur (inc idx)))
- (#error.Success target)))
+ (#try.Success target)))
(exception.throw ..cannot-copy-bytes [source-input target-output])))))))
(def: #export (slice from to binary)
- (-> Nat Nat Binary (Error Binary))
+ (-> Nat Nat Binary (Try Binary))
(let [size (..!size binary)]
(if (n/<= to from)
(if (and (n/< size from)
(n/< size to))
- (with-expansions [<for-jvm> (as-is (#error.Success (java/util/Arrays::copyOfRange binary (.int from) (.int (inc to)))))]
+ (with-expansions [<for-jvm> (as-is (#try.Success (java/util/Arrays::copyOfRange binary (.int from) (.int (inc to)))))]
(`` (for {(~~ (static @.old))
<for-jvm>
@@ -283,5 +283,5 @@
(exception.throw inverted-slice [size from to]))))
(def: #export (slice' from binary)
- (-> Nat Binary (Error Binary))
+ (-> Nat Binary (Try Binary))
(slice from (dec (..!size binary)) binary))
diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux
index b1f0d56cd..d7abd617c 100644
--- a/stdlib/source/lux/data/format/binary.lux
+++ b/stdlib/source/lux/data/format/binary.lux
@@ -7,13 +7,13 @@
[monad (#+ Monad do)]
[equivalence (#+ Equivalence)]]
[control
+ ["." try (#+ Try)]
["<>" parser ("#@." monad)
["/" binary (#+ Offset Size Parser)]]
["." function]
["ex" exception (#+ exception:)]]
[data
["." product]
- ["." error (#+ Error)]
["." binary (#+ Binary)]
[number
["." i64]
@@ -65,7 +65,7 @@
[(n/+ <size> offset)
(|> binary
(<write> offset value)
- error.assume)])]))]
+ try.assume)])]))]
[bits/8 /.size/8 binary.write/8]
[bits/16 /.size/16 binary.write/16]
@@ -83,7 +83,7 @@
(function (_ [offset binary])
(|> binary
(binary.write/8 offset 0)
- error.assume
+ try.assume
[(.inc offset)]
leftT))])
@@ -93,7 +93,7 @@
(function (_ [offset binary])
(|> binary
(binary.write/8 offset 1)
- error.assume
+ try.assume
[(.inc offset)]
rightT))])
)))
@@ -121,7 +121,7 @@
[(n/+ 1 offset)
(|> binary
(binary.write/8 offset (if value 1 0))
- error.assume)])]))
+ try.assume)])]))
(template [<name> <type>]
[(def: #export <name> (Writer <type>) (|>> .i64 ..bits/64))]
@@ -145,8 +145,8 @@
[size'
(function (_ [offset binary])
[(n/+ size' offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (<write> offset size binary)]
(binary.copy size 0 value (n/+ <size> offset) binary)))])]))))]
@@ -188,8 +188,8 @@
specification@identity))]
[(n/+ <size> size)
(function (_ [offset binary])
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (<write> offset (n/+ extra-count capped-count) binary)]
(wrap (mutation [(n/+ <size> offset) binary])))))])))
diff --git a/stdlib/source/lux/data/format/context.lux b/stdlib/source/lux/data/format/context.lux
index 6c3cc6903..bc186f8b4 100644
--- a/stdlib/source/lux/data/format/context.lux
+++ b/stdlib/source/lux/data/format/context.lux
@@ -4,9 +4,9 @@
[monad (#+ do)]]
[control
[parser (#+ Parser)]
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[collection
@@ -36,10 +36,10 @@
(ex.throw unknown-property name))))
(def: #export (run context property)
- (All [a] (-> Context (Property a) (Error a)))
+ (All [a] (-> Context (Property a) (Try a)))
(case (property context)
- (#error.Success [_ output])
- (#error.Success output)
+ (#try.Success [_ output])
+ (#try.Success output)
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 219f7cd9b..2c4d3ada1 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -7,13 +7,13 @@
codec]
[control
pipe
+ ["." try (#+ Try)]
["p" parser ("#@." monad)
["l" text (#+ Parser)]
["s" code]]]
[data
["." bit]
["." maybe]
- ["." error (#+ Error)]
["." product]
[number
["." frac ("#@." decimal)]]
@@ -93,52 +93,52 @@
(def: #export (get-fields json)
{#.doc "Get all the fields in a JSON object."}
- (-> JSON (Error (List String)))
+ (-> JSON (Try (List String)))
(case json
(#Object obj)
- (#error.Success (dictionary.keys obj))
+ (#try.Success (dictionary.keys obj))
_
- (#error.Failure ($_ text@compose "Cannot get the fields of a non-object."))))
+ (#try.Failure ($_ text@compose "Cannot get the fields of a non-object."))))
(def: #export (get key json)
{#.doc "A JSON object field getter."}
- (-> String JSON (Error JSON))
+ (-> String JSON (Try JSON))
(case json
(#Object obj)
(case (dictionary.get key obj)
(#.Some value)
- (#error.Success value)
+ (#try.Success value)
#.None
- (#error.Failure ($_ text@compose "Missing field '" key "' on object.")))
+ (#try.Failure ($_ text@compose "Missing field '" key "' on object.")))
_
- (#error.Failure ($_ text@compose "Cannot get field '" key "' of a non-object."))))
+ (#try.Failure ($_ text@compose "Cannot get field '" key "' of a non-object."))))
(def: #export (set key value json)
{#.doc "A JSON object field setter."}
- (-> String JSON JSON (Error JSON))
+ (-> String JSON JSON (Try JSON))
(case json
(#Object obj)
- (#error.Success (#Object (dictionary.put key value obj)))
+ (#try.Success (#Object (dictionary.put key value obj)))
_
- (#error.Failure ($_ text@compose "Cannot set field '" key "' of a non-object."))))
+ (#try.Failure ($_ text@compose "Cannot set field '" key "' of a non-object."))))
(template [<name> <tag> <type> <desc>]
[(def: #export (<name> key json)
{#.doc (code.text ($_ text@compose "A JSON object field getter for " <desc> "."))}
- (-> Text JSON (Error <type>))
+ (-> Text JSON (Try <type>))
(case (get key json)
- (#error.Success (<tag> value))
- (#error.Success value)
+ (#try.Success (<tag> value))
+ (#try.Success value)
- (#error.Success _)
- (#error.Failure ($_ text@compose "Wrong value type at key: " key))
+ (#try.Success _)
+ (#try.Failure ($_ text@compose "Wrong value type at key: " key))
- (#error.Failure error)
- (#error.Failure error)))]
+ (#try.Failure error)
+ (#try.Failure error)))]
[get-boolean #Boolean Boolean "booleans"]
[get-number #Number Number "numbers"]
@@ -287,10 +287,10 @@
offset (l.many l.decimal)]
(wrap ($_ text@compose mark (if signed?' "-" "") offset))))]
(case (frac@decode ($_ text@compose (if signed? "-" "") digits "." decimals exp))
- (#error.Failure message)
+ (#try.Failure message)
(p.fail message)
- (#error.Success value)
+ (#try.Success value)
(wrap value))))
(def: escaped~
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 3c81ef889..c4524fdf9 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -5,10 +5,10 @@
[equivalence (#+ Equivalence)]
[codec (#+ Codec)]]
[control
+ [try (#+ Try)]
["p" parser ("#@." monad)
["l" text (#+ Parser)]]]
[data
- [error (#+ Error)]
["." product]
["." name ("#@." equivalence codec)]
[number
@@ -172,7 +172,7 @@
(p.after (p.maybe xml-header^))))
(def: #export read
- (-> Text (Error XML))
+ (-> Text (Try XML))
(l.run xml^))
(def: (sanitize-value input)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 0577258ca..9b8381491 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -2,8 +2,9 @@
[lux #*
[abstract
[codec (#+ Codec)]]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." text]]]
["." / #_
["#." nat]
@@ -20,12 +21,12 @@
" number, generates a Nat, an Int, a Rev or a Frac.")
commas "Allows for the presence of commas among the digits."
description [cursor (#.Text ($_ "lux text concat" encoding " " commas))]]
- (#error.Success [state (list (` (doc (~ description)
- (~ example-1)
- (~ example-2))))]))
+ (#try.Success [state (list (` (doc (~ description)
+ (~ example-1)
+ (~ example-2))))]))
_
- (#error.Failure "Wrong syntax for 'encoding-doc'.")))
+ (#try.Failure "Wrong syntax for 'encoding-doc'.")))
(def: (comma-prefixed? number)
(-> Text Bit)
@@ -46,29 +47,29 @@
(case tokens
(#.Cons [meta (#.Text repr')] #.Nil)
(if (comma-prefixed? repr')
- (#error.Failure <error>)
+ (#try.Failure <error>)
(let [repr (clean-commas repr')]
(case (:: <nat> decode repr)
- (#error.Success value)
- (#error.Success [state (list [meta (#.Nat value)])])
+ (#try.Success value)
+ (#try.Success [state (list [meta (#.Nat value)])])
- (^multi (#error.Failure _)
- [(:: <int> decode repr) (#error.Success value)])
- (#error.Success [state (list [meta (#.Int value)])])
+ (^multi (#try.Failure _)
+ [(:: <int> decode repr) (#try.Success value)])
+ (#try.Success [state (list [meta (#.Int value)])])
- (^multi (#error.Failure _)
- [(:: <rev> decode repr) (#error.Success value)])
- (#error.Success [state (list [meta (#.Rev value)])])
+ (^multi (#try.Failure _)
+ [(:: <rev> decode repr) (#try.Success value)])
+ (#try.Success [state (list [meta (#.Rev value)])])
- (^multi (#error.Failure _)
- [(:: <frac> decode repr) (#error.Success value)])
- (#error.Success [state (list [meta (#.Frac value)])])
+ (^multi (#try.Failure _)
+ [(:: <frac> decode repr) (#try.Success value)])
+ (#try.Success [state (list [meta (#.Frac value)])])
_
- (#error.Failure <error>))))
+ (#try.Failure <error>))))
_
- (#error.Failure <error>)))]
+ (#try.Failure <error>)))]
[bin /nat.binary /int.binary /rev.binary /frac.binary
"Invalid binary syntax."
diff --git a/stdlib/source/lux/data/number/frac.lux b/stdlib/source/lux/data/number/frac.lux
index 5a816df33..a23c5c4e2 100644
--- a/stdlib/source/lux/data/number/frac.lux
+++ b/stdlib/source/lux/data/number/frac.lux
@@ -7,8 +7,9 @@
[equivalence (#+ Equivalence)]
["." order (#+ Order)]
[codec (#+ Codec)]]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." maybe]]
["." math]]
["." // #_
@@ -84,10 +85,10 @@
(def: (decode input)
(case ("lux f64 decode" [input])
(#.Some value)
- (#error.Success value)
+ (#try.Success value)
#.None
- (#error.Failure "Could not decode Frac"))))
+ (#try.Failure "Could not decode Frac"))))
(template [<struct> <int> <base> <char-set> <error>]
[(structure: #export <struct> (Codec Text Frac)
@@ -114,7 +115,7 @@
decimal-part ("lux text clip" (inc split-index) ("lux text size" repr) repr)]
(case [(:: <int> decode whole-part)
(:: <int> decode ("lux text concat" "+" decimal-part))]
- (^multi [(#error.Success whole) (#error.Success decimal)]
+ (^multi [(#try.Success whole) (#try.Success decimal)]
(i/>= +0 decimal))
(let [sign (if (i/< +0 whole)
-1.0
@@ -127,19 +128,19 @@
(f/* <base> output))))
adjusted-decimal (|> decimal int-to-frac (f// div-power))
dec-rev (case (:: //rev.hex decode ("lux text concat" "." decimal-part))
- (#error.Success dec-rev)
+ (#try.Success dec-rev)
dec-rev
- (#error.Failure error)
+ (#try.Failure error)
(error! error))]
- (#error.Success (f/+ (int-to-frac whole)
- (f/* sign adjusted-decimal))))
+ (#try.Success (f/+ (int-to-frac whole)
+ (f/* sign adjusted-decimal))))
_
- (#error.Failure ("lux text concat" <error> repr))))
+ (#try.Failure ("lux text concat" <error> repr))))
_
- (#error.Failure ("lux text concat" <error> repr)))))]
+ (#try.Failure ("lux text concat" <error> repr)))))]
[binary //int.binary +2.0 "01" "Invalid binary syntax: "]
)
@@ -308,14 +309,14 @@
("lux text concat" (<to> whole-part))
("lux text concat" (if (f/= -1.0 sign) "-" "+")))]
(case (:: ..binary decode as-binary)
- (#error.Failure _)
- (#error.Failure ("lux text concat" <error> repr))
+ (#try.Failure _)
+ (#try.Failure ("lux text concat" <error> repr))
output
output))
_
- (#error.Failure ("lux text concat" <error> repr))))))]
+ (#try.Failure ("lux text concat" <error> repr))))))]
[octal "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary]
[hex "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary]
@@ -332,7 +333,7 @@
(def: exponent-size Nat 11)
(template [<hex> <name>]
- [(def: <name> (|> <hex> (:: //nat.hex decode) error.assume .i64))]
+ [(def: <name> (|> <hex> (:: //nat.hex decode) try.assume .i64))]
["7FF7FFFFFFFFFFFF" not-a-number-bits]
["7FF0000000000000" positive-infinity-bits]
diff --git a/stdlib/source/lux/data/number/int.lux b/stdlib/source/lux/data/number/int.lux
index 464575700..c924ba9fe 100644
--- a/stdlib/source/lux/data/number/int.lux
+++ b/stdlib/source/lux/data/number/int.lux
@@ -9,8 +9,9 @@
[equivalence (#+ Equivalence)]
["." order (#+ Order)]
[codec (#+ Codec)]]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." maybe]
[text (#+ Char)]]]
[//
@@ -81,18 +82,18 @@
#.None))
(def: (int-decode-loop input-size repr sign <base> <to-value> <error>)
- (-> Nat Text Int Int (-> Char (Maybe Nat)) Text (Error Int))
+ (-> Nat Text Int Int (-> Char (Maybe Nat)) Text (Try Int))
(loop [idx 1
output +0]
(if (n/< input-size idx)
(case (<to-value> ("lux text char" idx repr))
#.None
- (#error.Failure <error>)
+ (#try.Failure <error>)
(#.Some digit-value)
(recur (inc idx)
(|> output (i/* <base>) (i/+ (.int digit-value)))))
- (#error.Success (i/* sign output)))))
+ (#try.Success (i/* sign output)))))
(template [<struct> <base> <to-character> <to-value> <error>]
[(structure: #export <struct> (Codec Text Int)
@@ -117,8 +118,8 @@
(int-decode-loop input-size repr sign <base> <to-value> <error>)
#.None
- (#error.Failure <error>))
- (#error.Failure <error>)))))]
+ (#try.Failure <error>))
+ (#try.Failure <error>)))))]
[binary +2 nat.binary-character nat.binary-value "Invalid binary syntax for Int: "]
[octal +8 nat.octal-character nat.octal-value "Invalid octal syntax for Int: "]
diff --git a/stdlib/source/lux/data/number/nat.lux b/stdlib/source/lux/data/number/nat.lux
index fd671641f..0a5b94f0a 100644
--- a/stdlib/source/lux/data/number/nat.lux
+++ b/stdlib/source/lux/data/number/nat.lux
@@ -10,9 +10,9 @@
[codec (#+ Codec)]
["." order (#+ Order)]]
[control
- ["." function]]
+ ["." function]
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." maybe]
["." text (#+ Char)]]])
@@ -191,13 +191,13 @@
(if (n/< input-size idx)
(case (<to-value> ("lux text char" idx repr))
#.None
- (#error.Failure ("lux text concat" <error> repr))
+ (#try.Failure ("lux text concat" <error> repr))
(#.Some digit-value)
(recur (inc idx)
(|> output (n/* <base>) (n/+ digit-value))))
- (#error.Success output)))
- (#error.Failure ("lux text concat" <error> repr))))))]
+ (#try.Success output)))
+ (#try.Failure ("lux text concat" <error> repr))))))]
[binary 2 binary-character binary-value "Invalid binary syntax for Nat: "]
[octal 8 octal-character octal-value "Invalid octal syntax for Nat: "]
diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux
index 8af1cf66c..5709b5724 100644
--- a/stdlib/source/lux/data/number/ratio.lux
+++ b/stdlib/source/lux/data/number/ratio.lux
@@ -9,10 +9,10 @@
[monad (#+ do)]]
[control
["." function]
+ ["." try]
["p" parser
["s" code (#+ Parser)]]]
[data
- ["." error]
["." product]
["." maybe]
[number
@@ -108,7 +108,7 @@
(def: (decode input)
(case (text.split-with ..separator input)
(#.Some [num denom])
- (do error.monad
+ (do try.monad
[numerator (nat@decode num)
denominator (nat@decode denom)]
(wrap (normalize {#numerator numerator
diff --git a/stdlib/source/lux/data/number/rev.lux b/stdlib/source/lux/data/number/rev.lux
index 746347ca8..f57137c88 100644
--- a/stdlib/source/lux/data/number/rev.lux
+++ b/stdlib/source/lux/data/number/rev.lux
@@ -10,9 +10,9 @@
["." order (#+ Order)]
[codec (#+ Codec)]]
[control
- ["." function]]
+ ["." function]
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." maybe]
[collection
["." array (#+ Array)]]]]
@@ -53,7 +53,7 @@
("lux text clip" 1 ("lux text size" input) input))
(template [<struct> <codec> <char-bit-size> <error>]
- [(with-expansions [<error-output> (as-is (#error.Failure ("lux text concat" <error> repr)))]
+ [(with-expansions [<error-output> (as-is (#try.Failure ("lux text concat" <error> repr)))]
(structure: #export <struct> (Codec Text Rev)
(def: (encode value)
(let [raw-output (:: <codec> encode (:coerce Nat value))
@@ -78,8 +78,8 @@
(case ("lux text char" 0 repr)
(^ (char "."))
(case (:: <codec> decode (de-prefix repr))
- (#error.Success output)
- (#error.Success (:coerce Rev output))
+ (#try.Success output)
+ (#try.Success (:coerce Rev output))
_
<error-output>)
@@ -271,11 +271,11 @@
(recur (digits-sub! power digits)
(inc idx)
(//i64.set (n/- idx (dec //i64.width)) output))))
- (#error.Success (:coerce Rev output))))
+ (#try.Success (:coerce Rev output))))
#.None
- (#error.Failure ("lux text concat" "Wrong syntax for Rev: " input)))
- (#error.Failure ("lux text concat" "Wrong syntax for Rev: " input))))
+ (#try.Failure ("lux text concat" "Wrong syntax for Rev: " input)))
+ (#try.Failure ("lux text concat" "Wrong syntax for Rev: " input))))
))
(structure: #export hash (Hash Rev)
diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux
index fca1e7632..59e5efcc2 100644
--- a/stdlib/source/lux/data/text/encoding.lux
+++ b/stdlib/source/lux/data/text/encoding.lux
@@ -3,9 +3,10 @@
["@" target]
[abstract
[codec (#+ Codec)]]
+ [control
+ ["." try (#+ Try)]]
[data
- [binary (#+ Binary)]
- ["." error (#+ Error)]]
+ [binary (#+ Binary)]]
[type
abstract]
["." host]])
@@ -207,16 +208,16 @@
(TextEncoder::encode [value]))})))
(def: #export (from-utf8 value)
- (-> Binary (Error Text))
+ (-> Binary (Try Text))
(`` (for {(~~ (static @.old))
- (#error.Success (java/lang/String::new value (..name ..utf-8)))
+ (#try.Success (java/lang/String::new value (..name ..utf-8)))
(~~ (static @.jvm))
- (#error.Success (java/lang/String::new value (..name ..utf-8)))
+ (#try.Success (java/lang/String::new value (..name ..utf-8)))
(~~ (static @.js))
- (#error.Success (|> (TextDecoder::new [(..name ..utf-8)])
- (TextDecoder::decode [value])))})))
+ (#try.Success (|> (TextDecoder::new [(..name ..utf-8)])
+ (TextDecoder::decode [value])))})))
(structure: #export UTF-8 (Codec Binary Text)
(def: encode ..to-utf8)
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index ca5b98c89..addd07532 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -3,20 +3,20 @@
[abstract
monad]
[control
+ ["." try]
["p" parser ("#@." monad)
["l" text (#+ Parser)]
["s" code]]]
[data
["." product]
- ["." error]
["." maybe]
[number (#+ hex)
["." nat ("#@." decimal)]]
[collection
["." list ("#@." fold monad)]]]
["." macro (#+ with-gensyms)
- ["." code]
- [syntax (#+ syntax:)]]]
+ [syntax (#+ syntax:)]
+ ["." code]]]
["." //
["%" format (#+ format)]])
@@ -321,31 +321,31 @@
(All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (| l r)])))
(function (_ input)
(case (left input)
- (#error.Success [input' [lt lv]])
- (#error.Success [input' [lt (0 lv)]])
+ (#try.Success [input' [lt lv]])
+ (#try.Success [input' [lt (0 lv)]])
- (#error.Failure _)
+ (#try.Failure _)
(case (right input)
- (#error.Success [input' [rt rv]])
- (#error.Success [input' [rt (1 rv)]])
+ (#try.Success [input' [rt rv]])
+ (#try.Success [input' [rt (1 rv)]])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: (|||_^ left right)
(All [l r] (-> (Parser [Text l]) (Parser [Text r]) (Parser Text)))
(function (_ input)
(case (left input)
- (#error.Success [input' [lt lv]])
- (#error.Success [input' lt])
+ (#try.Success [input' [lt lv]])
+ (#try.Success [input' lt])
- (#error.Failure _)
+ (#try.Failure _)
(case (right input)
- (#error.Success [input' [rt rv]])
- (#error.Success [input' rt])
+ (#try.Success [input' [rt rv]])
+ (#try.Success [input' rt])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: (prep-alternative [num-captures alt])
(-> [Nat Code] Code)
@@ -463,11 +463,11 @@
(case (l.run (p.before l.end
(regex^ current-module))
pattern)
- (#error.Failure error)
+ (#try.Failure error)
(macro.fail (format "Error while parsing regular-expression:" //.new-line
error))
- (#error.Success regex)
+ (#try.Success regex)
(wrap (list regex))
)))
@@ -488,6 +488,6 @@
(with-gensyms [g!temp]
(wrap (list& (` (^multi (~ g!temp)
[((~! l.run) (..regex (~ (code.text pattern))) (~ g!temp))
- (#error.Success (~ (maybe.default g!temp bindings)))]))
+ (#try.Success (~ (maybe.default g!temp bindings)))]))
body
branches))))
diff --git a/stdlib/source/lux/debug.lux b/stdlib/source/lux/debug.lux
index 6a4c208fa..db18eb37e 100644
--- a/stdlib/source/lux/debug.lux
+++ b/stdlib/source/lux/debug.lux
@@ -7,12 +7,12 @@
[monad (#+ do)]]
[control
["." function]
+ ["." try (#+ Try)]
["." exception (#+ exception:)]
["<>" parser
["<.>" type (#+ Parser)]]
pipe]
[data
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[format
@@ -277,10 +277,10 @@
))))
(def: #export (represent type value)
- (-> Type Any (Error Text))
+ (-> Type Any (Try Text))
(case (<type>.run type ..representation)
- (#error.Success representation)
- (#error.Success (representation value))
+ (#try.Success representation)
+ (#try.Success (representation value))
- (#error.Failure error)
+ (#try.Failure _)
(exception.throw cannot-represent-value type)))
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index eeefb361d..1daa2ded1 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -7,12 +7,12 @@
[control
["." function]
["." io]
+ ["." try (#+ Try)]
["p" parser ("#@." monad)
["s" code (#+ Parser)]]]
[data
["." maybe]
["." product]
- ["." error (#+ Error)]
["." bit ("#@." codec)]
number
["." text ("#@." equivalence monoid)
@@ -1758,7 +1758,7 @@
(:coerce Bit)))
(def: load-class
- (-> Text (Error (primitive "java.lang.Class" [Any])))
+ (-> Text (Try (primitive "java.lang.Class" [Any])))
(|>> (:coerce (primitive "java.lang.String"))
["Ljava/lang/String;"]
("jvm member invoke static" "java.lang.Class" "forName")
@@ -1794,7 +1794,7 @@
"Special options can also be given for the return values."
"#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
- "#try means that the computation might throw an exception, and the return value will be wrapped by the Error type."
+ "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
"#io means the computation has side effects, and will be wrapped by the IO type."
"These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
(import: java/lang/String
diff --git a/stdlib/source/lux/host.old.lux b/stdlib/source/lux/host.old.lux
index abda3863a..c559d3555 100644
--- a/stdlib/source/lux/host.old.lux
+++ b/stdlib/source/lux/host.old.lux
@@ -6,12 +6,12 @@
[control
["." function]
["." io]
+ ["." try (#+ Try)]
["p" parser
["s" code (#+ Parser)]]]
[data
["." maybe]
["." product]
- ["." error (#+ Error)]
["." bit ("#@." codec)]
number
["." text ("#@." equivalence monoid)
@@ -1788,7 +1788,7 @@
("jvm invokevirtual:java.lang.Class:isInterface:" class))
(def: (load-class class-name)
- (-> Text (Error (primitive "java.lang.Class" [Any])))
+ (-> Text (Try (primitive "java.lang.Class" [Any])))
(try ("jvm invokestatic:java.lang.Class:forName:java.lang.String" class-name)))
(def: (class-kind [class-name _])
@@ -1821,7 +1821,7 @@
"Special options can also be given for the return values."
"#? means that the values will be returned inside a Maybe type. That way, null becomes #.None."
- "#try means that the computation might throw an exception, and the return value will be wrapped by the Error type."
+ "#try means that the computation might throw an exception, and the return value will be wrapped by the Try type."
"#io means the computation has side effects, and will be wrapped by the IO type."
"These options must show up in the following order [#io #try #?] (although, each option can be used independently)."
(import: java/lang/String
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 7eedc2f35..041a3270b 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -4,11 +4,12 @@
[functor (#+ Functor)]
[apply (#+ Apply)]
["." monad (#+ Monad do)]]
+ [control
+ ["." try (#+ Try)]]
[data
["." product]
["." name ("#@." codec equivalence)]
["." maybe]
- ["." error (#+ Error)]
[number
["." nat ("#@." decimal)]]
["." text ("#@." monoid equivalence)]
@@ -18,17 +19,17 @@
["." code]])
## (type: (Meta a)
-## (-> Lux (Error [Lux a])))
+## (-> Lux (Try [Lux a])))
(structure: #export functor (Functor Meta)
(def: (map f fa)
(function (_ compiler)
(case (fa compiler)
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [compiler' a])
- (#error.Success [compiler' (f a)])))))
+ (#try.Success [compiler' a])
+ (#try.Success [compiler' (f a)])))))
(structure: #export apply (Apply Meta)
(def: &functor ..functor)
@@ -36,31 +37,31 @@
(def: (apply ff fa)
(function (_ compiler)
(case (ff compiler)
- (#error.Success [compiler' f])
+ (#try.Success [compiler' f])
(case (fa compiler')
- (#error.Success [compiler'' a])
- (#error.Success [compiler'' (f a)])
+ (#try.Success [compiler'' a])
+ (#try.Success [compiler'' (f a)])
- (#error.Failure msg)
- (#error.Failure msg))
+ (#try.Failure msg)
+ (#try.Failure msg))
- (#error.Failure msg)
- (#error.Failure msg)))))
+ (#try.Failure msg)
+ (#try.Failure msg)))))
(structure: #export monad (Monad Meta)
(def: &functor ..functor)
(def: (wrap x)
(function (_ compiler)
- (#error.Success [compiler x])))
+ (#try.Success [compiler x])))
(def: (join mma)
(function (_ compiler)
(case (mma compiler)
- (#error.Failure msg)
- (#error.Failure msg)
+ (#try.Failure msg)
+ (#try.Failure msg)
- (#error.Success [compiler' ma])
+ (#try.Success [compiler' ma])
(ma compiler')))))
(def: (get k plist)
@@ -76,63 +77,63 @@
(get k plist'))))
(def: #export (run' compiler action)
- (All [a] (-> Lux (Meta a) (Error [Lux a])))
+ (All [a] (-> Lux (Meta a) (Try [Lux a])))
(action compiler))
(def: #export (run compiler action)
- (All [a] (-> Lux (Meta a) (Error a)))
+ (All [a] (-> Lux (Meta a) (Try a)))
(case (action compiler)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [_ output])
- (#error.Success output)))
+ (#try.Success [_ output])
+ (#try.Success output)))
(def: #export (either left right)
{#.doc "Pick whichever computation succeeds."}
(All [a] (-> (Meta a) (Meta a) (Meta a)))
(function (_ compiler)
(case (left compiler)
- (#error.Failure error)
+ (#try.Failure error)
(right compiler)
- (#error.Success [compiler' output])
- (#error.Success [compiler' output]))))
+ (#try.Success [compiler' output])
+ (#try.Success [compiler' output]))))
(def: #export (assert message test)
{#.doc "Fails with the given message if the test is #0."}
(-> Text Bit (Meta Any))
(function (_ compiler)
(if test
- (#error.Success [compiler []])
- (#error.Failure message))))
+ (#try.Success [compiler []])
+ (#try.Failure message))))
(def: #export (fail msg)
{#.doc "Fails with the given message."}
(All [a]
(-> Text (Meta a)))
(function (_ _)
- (#error.Failure msg)))
+ (#try.Failure msg)))
(def: #export (find-module name)
(-> Text (Meta Module))
(function (_ compiler)
(case (get name (get@ #.modules compiler))
(#.Some module)
- (#error.Success [compiler module])
+ (#try.Success [compiler module])
_
- (#error.Failure ($_ text@compose "Unknown module: " name)))))
+ (#try.Failure ($_ text@compose "Unknown module: " name)))))
(def: #export current-module-name
(Meta Text)
(function (_ compiler)
(case (get@ #.current-module compiler)
(#.Some current-module)
- (#error.Success [compiler current-module])
+ (#try.Success [compiler current-module])
_
- (#error.Failure "No current module.")
+ (#try.Failure "No current module.")
)))
(def: #export current-module
@@ -281,7 +282,7 @@
this-module current-module-name]
(: (Meta (Maybe Macro))
(function (_ compiler)
- (#error.Success [compiler (find-macro' (get@ #.modules compiler) this-module module name)])))))
+ (#try.Success [compiler (find-macro' (get@ #.modules compiler) this-module module name)])))))
(def: #export (expand-once syntax)
{#.doc (doc "Given code that requires applying a macro, does it once and returns the result."
@@ -358,20 +359,20 @@
(def: #export count
(Meta Nat)
(function (_ compiler)
- (#error.Success [(update@ #.seed inc compiler)
- (get@ #.seed compiler)])))
+ (#try.Success [(update@ #.seed inc compiler)
+ (get@ #.seed compiler)])))
(def: #export (gensym prefix)
{#.doc (doc "Generates a unique name as an Code node (ready to be used in code templates)."
"A prefix can be given (or just be empty text) to better identify the code for debugging purposes.")}
(-> Text (Meta Code))
(function (_ compiler)
- (#error.Success [(update@ #.seed inc compiler)
- (|> compiler
- (get@ #.seed)
- (:: nat.decimal encode)
- ($_ text@compose "__gensym__" prefix)
- [""] code.identifier)])))
+ (#try.Success [(update@ #.seed inc compiler)
+ (|> compiler
+ (get@ #.seed)
+ (:: nat.decimal encode)
+ ($_ text@compose "__gensym__" prefix)
+ [""] code.identifier)])))
(def: (get-local-identifier ast)
(-> Code (Meta Text))
@@ -426,12 +427,12 @@
(def: #export (module-exists? module)
(-> Text (Meta Bit))
(function (_ compiler)
- (#error.Success [compiler (case (get module (get@ #.modules compiler))
- (#.Some _)
- #1
-
- #.None
- #0)])))
+ (#try.Success [compiler (case (get module (get@ #.modules compiler))
+ (#.Some _)
+ #1
+
+ #.None
+ #0)])))
(def: (try-both f x1 x2)
(All [a b]
@@ -460,10 +461,10 @@
(get@ [#.type-context #.var-bindings])
(find-type-var var))
(^or #.None (#.Some (#.Var _)))
- (#error.Success [compiler type])
+ (#try.Success [compiler type])
(#.Some type')
- (#error.Success [compiler type'])))
+ (#try.Success [compiler type'])))
_
(:: ..monad wrap type)))
@@ -491,7 +492,7 @@
((clean-type var-type) compiler)
#.None
- (#error.Failure ($_ text@compose "Unknown variable: " name))))))
+ (#try.Failure ($_ text@compose "Unknown variable: " name))))))
(def: #export (find-def name)
{#.doc "Looks-up a definition's whole data in the available modules (including the current one)."}
@@ -505,23 +506,23 @@
(^slots [#.definitions]) (get v-prefix (get@ #.modules compiler))]
(get v-name definitions)))
(#.Some definition)
- (#error.Success [compiler definition])
+ (#try.Success [compiler definition])
_
(let [current-module (|> compiler (get@ #.current-module) (maybe.default "???"))
separator ($_ text@compose text.new-line " ")]
- (#error.Failure ($_ text@compose
- "Unknown definition: " (name@encode name) text.new-line
- " Current module: " current-module text.new-line
- (case (get current-module (get@ #.modules compiler))
- (#.Some this-module)
- ($_ text@compose
- " Imports: " (|> this-module (get@ #.imports) (text.join-with separator)) text.new-line
- " Aliases: " (|> this-module (get@ #.module-aliases) (list@map (function (_ [alias real]) ($_ text@compose alias " => " real))) (text.join-with separator)) text.new-line)
-
- _
- "")
- " All Known modules: " (|> compiler (get@ #.modules) (list@map product.left) (text.join-with separator)) text.new-line)))))))
+ (#try.Failure ($_ text@compose
+ "Unknown definition: " (name@encode name) text.new-line
+ " Current module: " current-module text.new-line
+ (case (get current-module (get@ #.modules compiler))
+ (#.Some this-module)
+ ($_ text@compose
+ " Imports: " (|> this-module (get@ #.imports) (text.join-with separator)) text.new-line
+ " Aliases: " (|> this-module (get@ #.module-aliases) (list@map (function (_ [alias real]) ($_ text@compose alias " => " real))) (text.join-with separator)) text.new-line)
+
+ _
+ "")
+ " All Known modules: " (|> compiler (get@ #.modules) (list@map product.left) (text.join-with separator)) text.new-line)))))))
(def: #export (find-def-type name)
{#.doc "Looks-up a definition's type in the available modules (including the current one)."}
@@ -566,10 +567,10 @@
(function (_ compiler)
(case (get module-name (get@ #.modules compiler))
#.None
- (#error.Failure ($_ text@compose "Unknown module: " module-name))
+ (#try.Failure ($_ text@compose "Unknown module: " module-name))
(#.Some module)
- (#error.Success [compiler (get@ #.definitions module)]))))
+ (#try.Success [compiler (get@ #.definitions module)]))))
(def: #export (exports module-name)
{#.doc "All the exported definitions in a module."}
@@ -594,7 +595,7 @@
(|> compiler
(get@ #.modules)
[compiler]
- #error.Success)))
+ #try.Success)))
(def: #export (tags-of type-name)
{#.doc "All the tags associated with a type definition."}
@@ -613,7 +614,7 @@
{#.doc "The cursor of the current expression being analyzed."}
(Meta Cursor)
(function (_ compiler)
- (#error.Success [compiler (get@ #.cursor compiler)])))
+ (#try.Success [compiler (get@ #.cursor compiler)])))
(def: #export expected-type
{#.doc "The expected type of the current expression being analyzed."}
@@ -621,10 +622,10 @@
(function (_ compiler)
(case (get@ #.expected compiler)
(#.Some type)
- (#error.Success [compiler type])
+ (#try.Success [compiler type])
#.None
- (#error.Failure "Not expecting any type."))))
+ (#try.Failure "Not expecting any type."))))
(def: #export (imported-modules module-name)
{#.doc "All the modules imported by a specified module."}
@@ -689,14 +690,14 @@
(function (_ compiler)
(case (list.inits (get@ #.scopes compiler))
#.None
- (#error.Failure "No local environment")
+ (#try.Failure "No local environment")
(#.Some scopes)
- (#error.Success [compiler
- (list@map (|>> (get@ [#.locals #.mappings])
- (list@map (function (_ [name [type _]])
- [name type])))
- scopes)]))))
+ (#try.Success [compiler
+ (list@map (|>> (get@ [#.locals #.mappings])
+ (list@map (function (_ [name [type _]])
+ [name type])))
+ scopes)]))))
(def: #export (un-alias def-name)
{#.doc "Given an aliased definition's name, returns the original definition being referenced."}
@@ -714,12 +715,12 @@
{#.doc "Obtains the current state of the compiler."}
(Meta Lux)
(function (_ compiler)
- (#error.Success [compiler compiler])))
+ (#try.Success [compiler compiler])))
(def: #export type-context
(Meta Type-Context)
(function (_ compiler)
- (#error.Success [compiler (get@ #.type-context compiler)])))
+ (#try.Success [compiler (get@ #.type-context compiler)])))
(template [<macro> <func>]
[(macro: #export (<macro> tokens)
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index e9e11091a..fec2d6c60 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -5,6 +5,7 @@
[equivalence (#+ Equivalence)]
["." codec]]
[control
+ ["e" try]
["p" parser
["<.>" type]
["</>" json]
@@ -13,7 +14,6 @@
[data
["." bit]
maybe
- ["e" error]
["." sum]
["." product]
[number
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index ede922cbc..c634e010c 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -7,7 +7,6 @@
["</>" code]]]
[data
["." maybe]
- ["." error (#+ Error)]
[number
["." nat]
["." int]
diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux
index fa26f0abe..b0f8be77a 100644
--- a/stdlib/source/lux/math/modular.lux
+++ b/stdlib/source/lux/math/modular.lux
@@ -4,12 +4,12 @@
[codec (#+ Codec)]
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
["p" parser
["l" text (#+ Parser)]
["s" code]]]
[data
- ["." error (#+ Error)]
[number
["." int ("#@." decimal)]]
["." text ("#@." monoid)]]
@@ -28,10 +28,10 @@
Int
(def: #export (from-int value)
- (Ex [m] (-> Int (Error (Modulus m))))
+ (Ex [m] (-> Int (Try (Modulus m))))
(if (i/= +0 value)
(ex.throw zero-cannot-be-a-modulus [])
- (#error.Success (:abstraction value))))
+ (#try.Success (:abstraction value))))
(def: #export (to-int modulus)
(All [m] (-> (Modulus m) Int))
@@ -57,10 +57,10 @@
(syntax: #export (modulus {modulus s.int})
(case (from-int modulus)
- (#error.Success _)
- (wrap (list (` (error.assume (..from-int (~ (code.int modulus)))))))
+ (#try.Success _)
+ (wrap (list (` (try.assume (..from-int (~ (code.int modulus)))))))
- (#error.Failure error)
+ (#try.Failure error)
(p.fail error)))
(def: intL
@@ -104,13 +104,13 @@
(wrap (mod modulus remainder))))))
(def: #export (equalize reference sample)
- (All [r s] (-> (Mod r) (Mod s) (Error (Mod r))))
+ (All [r s] (-> (Mod r) (Mod s) (Try (Mod r))))
(let [[reference reference-modulus] (:representation reference)
[sample sample-modulus] (:representation sample)]
(if (i/= (to-int reference-modulus)
(to-int sample-modulus))
- (#error.Success (:abstraction {#remainder sample
- #modulus reference-modulus}))
+ (#try.Success (:abstraction {#remainder sample
+ #modulus reference-modulus}))
(ex.throw cannot-equalize-moduli [reference-modulus sample-modulus]))))
(template [<name> <op>]
diff --git a/stdlib/source/lux/target/jvm/attribute.lux b/stdlib/source/lux/target/jvm/attribute.lux
index 662da93a9..2f4361960 100644
--- a/stdlib/source/lux/target/jvm/attribute.lux
+++ b/stdlib/source/lux/target/jvm/attribute.lux
@@ -5,12 +5,12 @@
["." equivalence (#+ Equivalence)]]
[control
["." state (#+ State)]
+ ["." try]
["." exception (#+ exception:)]
["<>" parser
["<2>" binary (#+ Parser)]]]
[data
["." product]
- ["." error]
[format
[".F" binary (#+ Writer) ("#@." monoid)]]]]
["." // #_
@@ -123,16 +123,16 @@
//constant/pool.find-utf8
(state.run pool)
product.right)
- (^open "_@.") (error.equivalence //index.equivalence)]
+ (^open "_@.") (try.equivalence //index.equivalence)]
(<>.rec
(function (_ parser)
(do <>.monad
[@name //index.parser
length //unsigned.u4-parser]
- (cond (_@= ?@constant (#error.Success @name))
+ (cond (_@= ?@constant (#try.Success @name))
(:: @ map (..constant' @name) /constant.parser)
- (_@= ?@code (#error.Success @name))
+ (_@= ?@code (#try.Success @name))
(:: @ map (..code' @name) (/code.parser parser))
## else
diff --git a/stdlib/source/lux/target/jvm/constant/pool.lux b/stdlib/source/lux/target/jvm/constant/pool.lux
index c9e136380..dc500c885 100644
--- a/stdlib/source/lux/target/jvm/constant/pool.lux
+++ b/stdlib/source/lux/target/jvm/constant/pool.lux
@@ -5,11 +5,11 @@
[monad (#+ do)]]
[control
["." state (#+ State)]
+ ["." try (#+ Try)]
["." exception (#+ exception:)]
["<>" parser ("#@." functor)
["<2>" binary (#+ Parser)]]]
[data
- ["." error (#+ Error)]
[number
["." int]
["." frac]]
@@ -82,7 +82,7 @@
(#.Some entry)
(case entry
(<tag> value)
- [pool (#error.Success value)]
+ [pool (#try.Success value)]
_
[pool (exception.throw ..invalid-constant [<index> (name-of <tag>)])])
@@ -106,7 +106,7 @@
(<tag> actual)
(if (:: <=> = actual <expected>)
[pool
- (#error.Success <index>)]
+ (#try.Success <index>)]
<try-again>)
_
@@ -120,10 +120,10 @@
(-> of (State Pool (Index of))))
(type: (Fetcher of)
- (-> (Index of) (State Pool (Error of))))
+ (-> (Index of) (State Pool (Try of))))
(type: (Finder of)
- (-> of (State Pool (Error (Index of)))))
+ (-> of (State Pool (Try (Index of)))))
(template [<name> <type> <tag> <equivalence> <format>]
[(def: #export (<name> value)
diff --git a/stdlib/source/lux/target/jvm/loader.lux b/stdlib/source/lux/target/jvm/loader.lux
index 7fc9f4ff8..ed82231e1 100644
--- a/stdlib/source/lux/target/jvm/loader.lux
+++ b/stdlib/source/lux/target/jvm/loader.lux
@@ -4,12 +4,12 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
["." io (#+ IO)]
[concurrency
["." atom (#+ Atom)]]]
[data
- ["." error (#+ Error)]
["." binary (#+ Binary)]
["." text
["%" format (#+ format)]]
@@ -74,7 +74,7 @@
(java/lang/reflect/AccessibleObject::setAccessible true)))))
(def: #export (define class-name bytecode loader)
- (-> Text Binary java/lang/ClassLoader (Error java/lang/Object))
+ (-> Text Binary java/lang/ClassLoader (Try java/lang/Object))
(let [signature (array.from-list (list (:coerce java/lang/Object
class-name)
(:coerce java/lang/Object
@@ -112,26 +112,26 @@
(case (dictionary.get class-name classes)
(#.Some bytecode)
(case (..define class-name bytecode (<| <cast> self))
- (#error.Success class)
+ (#try.Success class)
(:assume class)
- (#error.Failure error)
+ (#try.Failure error)
(error! (ex.construct ..cannot-define [class-name error])))
#.None
(error! (ex.construct ..unknown [class-name (dictionary.keys classes)]))))))))))
(def: #export (store name bytecode library)
- (-> Text Binary Library (IO (Error Any)))
+ (-> Text Binary Library (IO (Try Any)))
(do io.monad
[library' (atom.read library)]
(if (dictionary.contains? name library')
(wrap (ex.throw ..already-stored name))
(do @
[_ (atom.update (dictionary.put name bytecode) library)]
- (wrap (#error.Success []))))))
+ (wrap (#try.Success []))))))
(def: #export (load name loader)
(-> Text java/lang/ClassLoader
- (IO (Error (java/lang/Class java/lang/Object))))
+ (IO (Try (java/lang/Class java/lang/Object))))
(java/lang/ClassLoader::loadClass name loader))
diff --git a/stdlib/source/lux/target/jvm/program.lux b/stdlib/source/lux/target/jvm/program.lux
index 673743c73..774094c5b 100644
--- a/stdlib/source/lux/target/jvm/program.lux
+++ b/stdlib/source/lux/target/jvm/program.lux
@@ -7,9 +7,9 @@
["." state (#+ State)]
["." writer (#+ Writer)]
["." function]
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
[text
["%" format]]
[number
@@ -45,11 +45,11 @@
#known-labels (dictionary.new nat.hash)})
(type: #export Partial
- (-> Resolver (Error Instruction)))
+ (-> Resolver (Try Instruction)))
(def: partial-identity
Partial
- (function.constant (#error.Success /instruction.nop)))
+ (function.constant (#try.Success /instruction.nop)))
(structure: partial-monoid
(Monoid Partial)
@@ -65,7 +65,7 @@
## else
(function (_ resolver)
- (do error.monad
+ (do try.monad
[left (left resolver)
right (right resolver)]
(wrap (/instruction@compose left right)))))))
@@ -100,9 +100,9 @@
state.monad))))
(def: #export (resolve pool program)
- (All [a] (-> Pool (Program a) (Error [Pool Instruction a])))
+ (All [a] (-> Pool (Program a) (Try [Pool Instruction a])))
(let [[[pool tracker] [partial output]] (state.run [pool ..fresh] program)]
- (do error.monad
+ (do try.monad
[instruction (partial (get@ #known-labels tracker))]
(wrap [pool instruction output]))))
@@ -110,7 +110,7 @@
(-> Instruction (Program Any))
(function (_ [pool tracker])
[[pool tracker]
- [(function.constant (#error.Success instruction))
+ [(function.constant (#try.Success instruction))
[]]]))
(template [<name> <instruction>]
@@ -279,7 +279,7 @@
(-> U1 (Program Any))
(function (_ [pool tracker])
[[pool tracker]
- [(function.constant (#error.Success (/instruction.bipush byte)))
+ [(function.constant (#try.Success (/instruction.bipush byte)))
[]]]))
(def: (lift on-pool)
@@ -368,7 +368,7 @@
(#.Some @to)
(case (jump @from @to)
(#.Left jump)
- (#error.Success (<instruction> jump))
+ (#try.Success (<instruction> jump))
(#.Right jump)
(exception.throw ..cannot-do-a-big-jump [label @from jump]))
@@ -409,10 +409,10 @@
(#.Some @to)
(case (jump @from @to)
(#.Left jump)
- (#error.Success (<normal-instruction> jump))
+ (#try.Success (<normal-instruction> jump))
(#.Right jump)
- (#error.Success (<wide-instruction> jump)))
+ (#try.Success (<wide-instruction> jump)))
#.None
(exception.throw ..unknown-label [label])))
diff --git a/stdlib/source/lux/target/jvm/program/condition.lux b/stdlib/source/lux/target/jvm/program/condition.lux
index 5769efc79..e0b778c07 100644
--- a/stdlib/source/lux/target/jvm/program/condition.lux
+++ b/stdlib/source/lux/target/jvm/program/condition.lux
@@ -4,10 +4,10 @@
[monad (#+ do)]
[monoid (#+ Monoid)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
[number (#+ hex)]
- ["." error (#+ Error)]
["." binary]
[text
["%" format (#+ format)]]
@@ -24,16 +24,16 @@
#stack U2})
(type: #export Condition
- (-> Environment (Error Environment)))
+ (-> Environment (Try Environment)))
(structure: #export monoid
(Monoid Condition)
- (def: identity (|>> #error.Success))
+ (def: identity (|>> #try.Success))
(def: (compose left right)
(function (_ environment)
- (do error.monad
+ (do try.monad
[environment (left environment)]
(right environment)))))
@@ -46,7 +46,7 @@
(|> env
(set@ #stack (///unsigned.u2 stack))
(set@ [#resources #//resources.max-stack] (///unsigned.u2 max-stack))
- #error.Success)))
+ #try.Success)))
(exception: #export (cannot-pop-stack {stack-size Nat}
{wanted-pops Nat})
@@ -58,9 +58,9 @@
(-> Nat Condition)
(let [stack-size (///unsigned.nat (get@ #stack env))]
(if (n/<= stack-size wanted-pops)
- (#error.Success (update@ #stack
- (|>> ///unsigned.nat (n/- wanted-pops) ///unsigned.u2)
- env))
+ (#try.Success (update@ #stack
+ (|>> ///unsigned.nat (n/- wanted-pops) ///unsigned.u2)
+ env))
(exception.throw ..cannot-pop-stack [stack-size wanted-pops]))))
(type: #export Local U1)
@@ -72,4 +72,4 @@
(|> environment
(set@ [#resources #//resources.max-locals]
(///unsigned.u2 max-locals))
- #error.Success)))
+ #try.Success)))
diff --git a/stdlib/source/lux/target/jvm/program/instruction.lux b/stdlib/source/lux/target/jvm/program/instruction.lux
index 373801405..83efb98b7 100644
--- a/stdlib/source/lux/target/jvm/program/instruction.lux
+++ b/stdlib/source/lux/target/jvm/program/instruction.lux
@@ -4,10 +4,10 @@
[monad (#+ do)]
[monoid (#+ Monoid)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
[number (#+ hex)]
- ["." error (#+ Error)]
["." binary]
[text
["%" format (#+ format)]]
@@ -31,13 +31,13 @@
(type: #export Size Nat)
(type: #export Instruction
- [Size (-> [Environment Specification] (Error [Environment Specification]))])
+ [Size (-> [Environment Specification] (Try [Environment Specification]))])
(def: (instruction size condition transform)
(-> Size Condition (-> Specification Specification) Instruction)
[size
(function (_ [environment specification])
- (do error.monad
+ (do try.monad
[environment' (condition environment)]
(wrap [environment'
(transform specification)])))])
@@ -48,7 +48,7 @@
(-> Code Mutation)
(function (_ [offset binary])
[(n/+ 1 offset)
- (error.assume
+ (try.assume
(binary.write/8 offset code binary))]))
(def: (nullary code [size mutation])
@@ -60,8 +60,8 @@
(-> Code U1 Mutation)
(function (_ [offset binary])
[(n/+ 2 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)]
(binary.write/8 (n/+ 1 offset) (///unsigned.nat input0) binary)))]))
@@ -74,8 +74,8 @@
(-> Code U2 Mutation)
(function (_ [offset binary])
[(n/+ 3 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)]
(binary.write/16 (n/+ 1 offset) (///unsigned.nat input0) binary)))]))
@@ -88,8 +88,8 @@
(-> Code U4 Mutation)
(function (_ [offset binary])
[(n/+ 5 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)]
(binary.write/16 (n/+ 1 offset) (///unsigned.nat input0) binary)))]))
@@ -102,8 +102,8 @@
(-> Code U1 U1 Mutation)
(function (_ [offset binary])
[(n/+ 3 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)
_ (binary.write/8 (n/+ 1 offset) (///unsigned.nat input0) binary)]
(binary.write/8 (n/+ 2 offset) (///unsigned.nat input1) binary)))]))
@@ -117,8 +117,8 @@
(-> Code U2 U1 Mutation)
(function (_ [offset binary])
[(n/+ 4 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)
_ (binary.write/16 (n/+ 1 offset) (///unsigned.nat input0) binary)]
(binary.write/8 (n/+ 3 offset) (///unsigned.nat input1) binary)))]))
@@ -132,8 +132,8 @@
(-> Code U2 U1 U1 Mutation)
(function (_ [offset binary])
[(n/+ 5 offset)
- (error.assume
- (do error.monad
+ (try.assume
+ (do try.monad
[_ (binary.write/8 offset code binary)
_ (binary.write/16 (n/+ 1 offset) (///unsigned.nat input0) binary)
_ (binary.write/8 (n/+ 3 offset) (///unsigned.nat input1) binary)]
@@ -496,6 +496,6 @@
(def: (compose [left-size left] [right-size right])
[(n/+ left-size right-size)
(function (_ input)
- (do error.monad
+ (do try.monad
[temp (left input)]
(right temp)))]))
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index 25ecffdf9..e52395dc3 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -5,11 +5,11 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]
[parser
["<t>" text]]]
[data
- ["." error (#+ Error)]
["." text ("#@." equivalence)
["%" format (#+ format)]]
[collection
@@ -99,26 +99,26 @@
)
(def: #export (load name)
- (-> Text (Error (java/lang/Class java/lang/Object)))
+ (-> Text (Try (java/lang/Class java/lang/Object)))
(case (java/lang/Class::forName name)
- (#error.Success class)
- (#error.Success class)
+ (#try.Success class)
+ (#try.Success class)
- (#error.Failure error)
+ (#try.Failure _)
(exception.throw ..unknown-class name)))
(def: #export (sub? super sub)
- (-> Text Text (Error Bit))
- (do error.monad
+ (-> Text Text (Try Bit))
+ (do try.monad
[super (..load super)
sub (..load sub)]
(wrap (java/lang/Class::isAssignableFrom sub super))))
(def: #export (generic reflection)
- (-> java/lang/reflect/Type (Error /.Generic))
+ (-> java/lang/reflect/Type (Try /.Generic))
(<| (case (host.check java/lang/reflect/TypeVariable reflection)
(#.Some reflection)
- (#error.Success (#/.Var (java/lang/reflect/TypeVariable::getName reflection)))
+ (#try.Success (#/.Var (java/lang/reflect/TypeVariable::getName reflection)))
_)
(case (host.check java/lang/reflect/WildcardType reflection)
(#.Some reflection)
@@ -132,17 +132,17 @@
(#.Some _)
## TODO: Array bounds should not be "erased" as they
## are right now.
- (#error.Success (#/.Wildcard #.None))
+ (#try.Success (#/.Wildcard #.None))
_
- (:: error.monad map
+ (:: try.monad map
(|>> [<kind>] #.Some #/.Wildcard)
(generic bound))))
([[_ (#.Some bound)] #/.Upper]
[[(#.Some bound) _] #/.Lower])
_
- (#error.Success (#/.Wildcard #.None)))
+ (#try.Success (#/.Wildcard #.None)))
_)
(case (host.check java/lang/Class reflection)
(#.Some class)
@@ -159,14 +159,14 @@
_
(if (text.starts-with? /.array-prefix class-name)
(exception.throw ..not-a-class reflection)
- (#error.Success (#/.Class class-name (list))))))
+ (#try.Success (#/.Class class-name (list))))))
_)
(case (host.check java/lang/reflect/ParameterizedType reflection)
(#.Some reflection)
(let [raw (java/lang/reflect/ParameterizedType::getRawType reflection)]
(case (host.check java/lang/Class raw)
(#.Some raw)
- (do error.monad
+ (do try.monad
[paramsT (|> reflection
java/lang/reflect/ParameterizedType::getActualTypeArguments
array.to-list
@@ -183,7 +183,7 @@
(exception.throw ..cannot-convert-to-a-lux-type reflection)))
(def: #export (type reflection)
- (-> java/lang/reflect/Type (Error /.Type))
+ (-> java/lang/reflect/Type (Try /.Type))
(<| (case (host.check java/lang/Class reflection)
(#.Some reflection)
(case (|> reflection
@@ -191,7 +191,7 @@
java/lang/Class::getName)
(^template [<reflection> <type>]
(^ (static <reflection>))
- (#error.Success <type>))
+ (#try.Success <type>))
([reflection.boolean /.boolean]
[reflection.byte /.byte]
[reflection.short /.short]
@@ -204,22 +204,22 @@
class-name
(if (text.starts-with? /.array-prefix class-name)
(<t>.run /.parse-signature (/.binary-name class-name))
- (#error.Success (/.class class-name (list)))))
+ (#try.Success (/.class class-name (list)))))
_)
(case (host.check java/lang/reflect/GenericArrayType reflection)
(#.Some reflection)
(|> reflection
java/lang/reflect/GenericArrayType::getGenericComponentType
type
- (:: error.monad map (/.array 1)))
+ (:: try.monad map (/.array 1)))
_)
## else
- (:: error.monad map (|>> #/.Generic)
+ (:: try.monad map (|>> #/.Generic)
(..generic reflection))))
(def: #export (return reflection)
- (-> java/lang/reflect/Type (Error /.Return))
- (with-expansions [<else> (as-is (:: error.monad map (|>> #.Some)
+ (-> java/lang/reflect/Type (Try /.Return))
+ (with-expansions [<else> (as-is (:: try.monad map (|>> #.Some)
(..type reflection)))]
(case (host.check java/lang/Class reflection)
(#.Some class)
@@ -227,7 +227,7 @@
(:coerce (java/lang/Class java/lang/Object))
java/lang/Class::getName)
(^ (static reflection.void))
- (#error.Success #.None)
+ (#try.Success #.None)
_
<else>)
@@ -256,7 +256,7 @@
["Type" (%.type type)]))
(def: #export (correspond class type)
- (-> (java/lang/Class java/lang/Object) Type (Error Mapping))
+ (-> (java/lang/Class java/lang/Object) Type (Try Mapping))
(case type
(#.Primitive name params)
(let [class-name (java/lang/Class::getName class)
@@ -271,7 +271,7 @@
(list@fold (function (_ [name paramT] mapping)
(dictionary.put name paramT mapping))
/lux.fresh)
- #error.Success)
+ #try.Success)
(exception.throw ..type-parameter-mismatch [num-class-params num-type-params class type]))
(exception.throw ..cannot-correspond [class type])))
@@ -310,21 +310,21 @@
)
(def: #export (field field target)
- (-> Text (java/lang/Class java/lang/Object) (Error java/lang/reflect/Field))
+ (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field))
(case (java/lang/Class::getDeclaredField field target)
- (#error.Success field)
+ (#try.Success field)
(let [owner (java/lang/reflect/Field::getDeclaringClass field)]
(if (is? owner target)
- (#error.Success field)
+ (#try.Success field)
(exception.throw ..mistaken-field-owner [field owner target])))
- (#error.Failure _)
+ (#try.Failure _)
(exception.throw ..unknown-field [field target])))
(template [<name> <exception> <then?> <else?>]
[(def: #export (<name> field class)
- (-> Text (java/lang/Class java/lang/Object) (Error [Bit /.Type]))
- (do error.monad
+ (-> Text (java/lang/Class java/lang/Object) (Try [Bit /.Type]))
+ (do try.monad
[fieldJ (..field field class)
#let [modifiers (java/lang/reflect/Field::getModifiers fieldJ)]]
(case (java/lang/reflect/Modifier::isStatic modifiers)
diff --git a/stdlib/source/lux/target/jvm/type.lux b/stdlib/source/lux/target/jvm/type.lux
index 09906deca..fffac9b6e 100644
--- a/stdlib/source/lux/target/jvm/type.lux
+++ b/stdlib/source/lux/target/jvm/type.lux
@@ -7,7 +7,6 @@
["<>" parser
["<t>" text (#+ Parser)]]]
[data
- [error (#+ Error)]
["." product]
["." maybe ("#@." functor)]
["." text ("#@." equivalence)
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 45121339a..a495cc9fa 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -10,7 +10,6 @@
["p" parser ("#@." functor)
["l" text (#+ Parser)]]]
[data
- ["." error (#+ Error)]
["." maybe]
[number
["." nat ("#@." decimal)]
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 0bbdd94ea..8a5611d16 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -7,14 +7,14 @@
[monoid (#+ Monoid)]
[monad (#+ do)]]
[control
+ ["e" try]
["p" parser
["l" text]]]
[data
[number
["." nat ("#@." decimal)]
["." int ("#@." decimal number)]]
- ["." text ("#@." monoid)]
- ["e" error]]
+ ["." text ("#@." monoid)]]
[type
abstract]])
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 2b4d10394..b26707173 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -8,10 +8,10 @@
[monad (#+ do Monad)]]
[control
[io (#+ IO io)]
+ ["." try (#+ Try)]
["p" parser
["l" text (#+ Parser)]]]
[data
- ["." error (#+ Error)]
["." maybe]
[number
["." int ("#@." decimal)]]
@@ -300,7 +300,7 @@
## (shift (duration.scale-up utc-millis duration.milli))))))
## (def: (decode input)
-## (-> Text (Error Instant))
+## (-> Text (Try Instant))
## (l.run input lex-instant))
## (structure: #export _
diff --git a/stdlib/source/lux/tool/compiler.lux b/stdlib/source/lux/tool/compiler.lux
index f855d6db0..ca9ea4a0e 100644
--- a/stdlib/source/lux/tool/compiler.lux
+++ b/stdlib/source/lux/tool/compiler.lux
@@ -1,9 +1,9 @@
(.module:
[lux (#- Module Code)
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." text]
[collection
["." dictionary (#+ Dictionary)]]]
@@ -38,8 +38,8 @@
(type: #export (Compilation s d o)
{#dependencies (List Module)
#process (-> s Archive
- (Error [s (Either (Compilation s d o)
- [[Descriptor (Document d)] (Output o)])]))})
+ (Try [s (Either (Compilation s d o)
+ [[Descriptor (Document d)] (Output o)])]))})
(type: #export (Compiler s d o)
(-> Input (Compilation s d o)))
diff --git a/stdlib/source/lux/tool/compiler/analysis.lux b/stdlib/source/lux/tool/compiler/analysis.lux
index 05bb2be01..f2e1cb978 100644
--- a/stdlib/source/lux/tool/compiler/analysis.lux
+++ b/stdlib/source/lux/tool/compiler/analysis.lux
@@ -4,10 +4,10 @@
[monad (#+ do)]]
[control
["." function]
+ ["." try]
["." exception (#+ Exception)]]
[data
["." product]
- ["." error]
["." maybe]
["." text ("#@." equivalence)
["%" format (#+ Format format)]]
@@ -250,12 +250,12 @@
(function (_ [bundle state])
(let [old-source (get@ #.source state)]
(case (action [bundle (set@ #.source source state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' (set@ #.source old-source state')]
- output])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (set@ #.source old-source state')]
+ output])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: fresh-bindings
(All [k v] (Bindings k v))
@@ -273,17 +273,17 @@
(All [a] (-> (Operation a) (Operation [Scope a])))
(function (_ [bundle state])
(case (action [bundle (update@ #.scopes (|>> (#.Cons fresh-scope)) state)])
- (#error.Success [[bundle' state'] output])
+ (#try.Success [[bundle' state'] output])
(case (get@ #.scopes state')
(#.Cons head tail)
- (#error.Success [[bundle' (set@ #.scopes tail state')]
- [head output]])
+ (#try.Success [[bundle' (set@ #.scopes tail state')]
+ [head output]])
#.Nil
- (#error.Failure "Impossible error: Drained scopes!"))
+ (#try.Failure "Impossible error: Drained scopes!"))
- (#error.Failure error)
- (#error.Failure error))))
+ (#try.Failure error)
+ (#try.Failure error))))
(def: #export (with-current-module name)
(All [a] (-> Text (Operation a) (Operation a)))
@@ -298,12 +298,12 @@
(function (_ [bundle state])
(let [old-cursor (get@ #.cursor state)]
(case (action [bundle (set@ #.cursor cursor state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' (set@ #.cursor old-cursor state')]
- output])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (set@ #.cursor old-cursor state')]
+ output])
- (#error.Failure error)
- (#error.Failure error))))))
+ (#try.Failure error)
+ (#try.Failure error))))))
(def: (locate-error cursor error)
(-> Cursor Text Text)
@@ -313,7 +313,7 @@
(def: #export (fail error)
(-> Text Operation)
(function (_ [bundle state])
- (#error.Failure (locate-error (get@ #.cursor state) error))))
+ (#try.Failure (locate-error (get@ #.cursor state) error))))
(def: #export (throw exception parameters)
(All [e] (-> (Exception e) e Operation))
@@ -322,7 +322,7 @@
(def: #export (fail' error)
(-> Text (phase.Operation Lux))
(function (_ state)
- (#error.Failure (locate-error (get@ #.cursor state) error))))
+ (#try.Failure (locate-error (get@ #.cursor state) error))))
(def: #export (throw' exception parameters)
(All [e] (-> (Exception e) e (phase.Operation Lux)))
@@ -332,14 +332,14 @@
(All [e o] (-> (Exception e) e (Operation o) (Operation o)))
(function (_ bundle,state)
(case (action bundle,state)
- (#error.Success output)
- (#error.Success output)
+ (#try.Success output)
+ (#try.Success output)
- (#error.Failure error)
+ (#try.Failure error)
(let [[bundle state] bundle,state]
- (#error.Failure (<| (locate-error (get@ #.cursor state))
- (exception.decorate (exception.construct exception message))
- error))))))
+ (#try.Failure (<| (locate-error (get@ #.cursor state))
+ (exception.decorate (exception.construct exception message))
+ error))))))
(template [<name> <type> <field> <value>]
[(def: #export (<name> value)
diff --git a/stdlib/source/lux/tool/compiler/default/evaluation.lux b/stdlib/source/lux/tool/compiler/default/evaluation.lux
index 72065a3c8..36e5678db 100644
--- a/stdlib/source/lux/tool/compiler/default/evaluation.lux
+++ b/stdlib/source/lux/tool/compiler/default/evaluation.lux
@@ -2,8 +2,9 @@
[lux #*
[abstract
[monad (#+ do)]]
+ [control
+ ["." try]]
[data
- ["." error]
[text
["%" format (#+ format)]]]]
[///
@@ -32,7 +33,7 @@
(do phase.monad
[exprA (type.with-type type
(analyze exprC))]
- (phase.lift (do error.monad
+ (phase.lift (do try.monad
[exprS (|> exprA synthesisP.phase (phase.run synthesis-state))]
(phase.run generation-state
(do phase.monad
diff --git a/stdlib/source/lux/tool/compiler/default/init.lux b/stdlib/source/lux/tool/compiler/default/init.lux
index f59a171dd..d24c2828d 100644
--- a/stdlib/source/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/lux/tool/compiler/default/init.lux
@@ -3,10 +3,10 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]]
[data
["." product]
- ["." error (#+ Error)]
["." text ("#@." hash)]
[collection
["." list ("#@." functor)]
@@ -78,22 +78,22 @@
(def: (reader current-module aliases [cursor offset source-code])
(-> Module Aliases Source (///analysis.Operation Reader))
(function (_ [bundle state])
- (#error.Success [[bundle state]
- (//syntax.parse current-module aliases ("lux text size" source-code))])))
+ (#try.Success [[bundle state]
+ (//syntax.parse current-module aliases ("lux text size" source-code))])))
(def: (read source reader)
(-> Source Reader (///analysis.Operation [Source Code]))
(function (_ [bundle compiler])
(case (reader source)
(#.Left [source' error])
- (#error.Failure error)
+ (#try.Failure error)
(#.Right [source' output])
(let [[cursor _] output]
- (#error.Success [[bundle (|> compiler
- (set@ #.source source')
- (set@ #.cursor cursor))]
- [source' output]])))))
+ (#try.Success [[bundle (|> compiler
+ (set@ #.source source')
+ (set@ #.cursor cursor))]
+ [source' output]])))))
(type: (Operation a)
(All [anchor expression statement]
@@ -170,13 +170,13 @@
(..reader module aliases source))]
(function (_ state)
(case (///phase.run' state (..iteration expander reader source pre-buffer))
- (#error.Success [state source&requirements&buffer])
- (#error.Success [state (#.Some source&requirements&buffer)])
+ (#try.Success [state source&requirements&buffer])
+ (#try.Success [state (#.Some source&requirements&buffer)])
- (#error.Failure error)
+ (#try.Failure error)
(if (ex.match? //syntax.end-of-file error)
- (#error.Success [state #.None])
- (ex.with-stack ///.cannot-compile module (#error.Failure error)))))))
+ (#try.Success [state #.None])
+ (ex.with-stack ///.cannot-compile module (#try.Failure error)))))))
(def: (default-dependencies prelude input)
(-> Module ///.Input (List Module))
@@ -197,7 +197,7 @@
(let [dependencies (default-dependencies prelude input)]
{#///.dependencies dependencies
#///.process (function (_ state archive)
- (do error.monad
+ (do try.monad
[#let [hash (text@hash (get@ #///.code input))]
[state [source buffer]] (<| (///phase.run' state)
(..begin dependencies hash input))
diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux
index ab24a52a7..ad82d860b 100644
--- a/stdlib/source/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/lux/tool/compiler/default/platform.lux
@@ -3,10 +3,11 @@
[type (#+ :share)]
[abstract
["." monad (#+ Monad do)]]
+ [control
+ ["." try (#+ Try)]]
[data
["." bit]
["." product]
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]
[collection
@@ -44,7 +45,7 @@
## (def: (write-module target-dir file-name module-name module outputs)
## (-> File Text Text Module Outputs (Process Any))
-## (do (error.with io.monad)
+## (do (try.with io.monad)
## [_ (monad.map @ (product.uncurry (&io.write target-dir))
## (dictionary.entries outputs))]
## (&io.write target-dir
@@ -65,7 +66,7 @@
<Bundle>
(///statement.Bundle anchor expression statement)
(-> expression statement)
- (! (Error <State+>))))
+ (! (Try <State+>))))
(|> platform
(get@ #runtime)
///statement.lift-generation
@@ -77,13 +78,13 @@
generation-bundle
host-statement-bundle
program))
- (:: error.functor map product.left)
+ (:: try.functor map product.left)
(:: (get@ #&monad platform) wrap))
## (case (runtimeT.generate ## (initL.compiler (io.run js.init))
## (initL.compiler (io.run hostL.init-host))
## )
- ## ## (#error.Success [state disk-write])
+ ## ## (#try.Success [state disk-write])
## ## (do @
## ## [_ (&io.prepare-target target)
## ## _ disk-write
@@ -92,7 +93,7 @@
## ## (wrap (|> state
## ## (set@ [#.info #.mode] #.Build))))
- ## (#error.Success [state [runtime-bc function-bc]])
+ ## (#try.Success [state [runtime-bc function-bc]])
## (do @
## [_ (&io.prepare-target target)
## ## _ (&io.write target (format hostL.runtime-class ".class") runtime-bc)
@@ -102,13 +103,13 @@
## (wrap (|> state
## (set@ [#.info #.mode] #.Build))))
- ## (#error.Failure error)
+ ## (#try.Failure error)
## (io.fail error))
)
(def: #export (compile partial-host-extension expander platform configuration archive state)
(All <type-vars>
- (-> Text Expander <Platform> Configuration Archive <State+> (! (Error [Archive <State+>]))))
+ (-> Text Expander <Platform> Configuration Archive <State+> (! (Try [Archive <State+>]))))
(let [monad (get@ #&monad platform)
source-module (get@ #cli.module configuration)
compiler (:share [anchor expression statement]
@@ -119,14 +120,14 @@
(loop [module source-module
[archive state] [archive state]]
(if (archive.archived? archive module)
- (:: monad wrap (#error.Success [archive state]))
+ (:: monad wrap (#try.Success [archive state]))
(let [import! (:share <type-vars>
{<Platform>
platform}
{(-> Module [Archive <State+>]
- (! (Error [Archive <State+>])))
+ (! (Try [Archive <State+>])))
recur})]
- (do (error.with monad)
+ (do (try.with monad)
[input (context.read monad
(get@ #&file-system platform)
(get@ #cli.sources configuration)
@@ -154,7 +155,7 @@
{<Platform>
platform}
{(-> Archive <State+> (///.Compilation <State+> .Module Any)
- (! (Error [Archive <State+>])))
+ (! (Try [Archive <State+>])))
recur})]]
(case ((get@ #///.process compilation)
(case dependencies
@@ -166,22 +167,22 @@
(|> (///analysis.set-current-module module)
///statement.lift-analysis
(///phase.run' state)
- error.assume
+ try.assume
product.left))
archive)
- (#error.Success [state more|done])
+ (#try.Success [state more|done])
(case more|done
(#.Left more)
(continue! archive state more)
(#.Right [descriptor+document output])
(case (archive.add module descriptor+document archive)
- (#error.Success archive)
+ (#try.Success archive)
(wrap [archive state])
- (#error.Failure error)
- (:: monad wrap (#error.Failure error))))
+ (#try.Failure error)
+ (:: monad wrap (#try.Failure error))))
- (#error.Failure error)
- (:: monad wrap (#error.Failure error)))))))))))
+ (#try.Failure error)
+ (:: monad wrap (#try.Failure error)))))))))))
)
diff --git a/stdlib/source/lux/tool/compiler/default/syntax.lux b/stdlib/source/lux/tool/compiler/default/syntax.lux
index d9a82695b..16a7b4771 100644
--- a/stdlib/source/lux/tool/compiler/default/syntax.lux
+++ b/stdlib/source/lux/tool/compiler/default/syntax.lux
@@ -34,7 +34,6 @@
[text (#+ Offset)]]]
[data
["." maybe]
- ["." error (#+ Error)]
[number
["." nat]
["." int]
diff --git a/stdlib/source/lux/tool/compiler/meta/archive.lux b/stdlib/source/lux/tool/compiler/meta/archive.lux
index 9953a7b2f..06323df9c 100644
--- a/stdlib/source/lux/tool/compiler/meta/archive.lux
+++ b/stdlib/source/lux/tool/compiler/meta/archive.lux
@@ -4,9 +4,9 @@
["." equivalence (#+ Equivalence)]
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." name]
["." text]
[collection
@@ -44,24 +44,24 @@
(:abstraction (dictionary.new text.hash)))
(def: #export (add module [descriptor document] archive)
- (-> Module [Descriptor (Document Any)] Archive (Error Archive))
+ (-> Module [Descriptor (Document Any)] Archive (Try Archive))
(case (dictionary.get module (:representation archive))
(#.Some [existing-descriptor existing-document])
(if (is? document existing-document)
- (#error.Success archive)
+ (#try.Success archive)
(ex.throw cannot-replace-document [module existing-document document]))
#.None
- (#error.Success (|> archive
- :representation
- (dictionary.put module [descriptor document])
- :abstraction))))
+ (#try.Success (|> archive
+ :representation
+ (dictionary.put module [descriptor document])
+ :abstraction))))
(def: #export (find module archive)
- (-> Module Archive (Error [Descriptor (Document Any)]))
+ (-> Module Archive (Try [Descriptor (Document Any)]))
(case (dictionary.get module (:representation archive))
(#.Some document)
- (#error.Success document)
+ (#try.Success document)
#.None
(ex.throw unknown-document [module])))
@@ -69,10 +69,10 @@
(def: #export (archived? archive module)
(-> Archive Module Bit)
(case (find module archive)
- (#error.Success _)
+ (#try.Success _)
yes
- (#error.Failure _)
+ (#try.Failure _)
no))
(def: #export archived
@@ -80,8 +80,8 @@
(|>> :representation dictionary.keys))
(def: #export (merge additions archive)
- (-> Archive Archive (Error Archive))
- (monad.fold error.monad
+ (-> Archive Archive (Try Archive))
+ (monad.fold try.monad
(function (_ [module' descriptor+document'] archive')
(..add module' descriptor+document' archive'))
archive
diff --git a/stdlib/source/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/lux/tool/compiler/meta/archive/document.lux
index 505170efb..e6d5c0dfe 100644
--- a/stdlib/source/lux/tool/compiler/meta/archive/document.lux
+++ b/stdlib/source/lux/tool/compiler/meta/archive/document.lux
@@ -1,9 +1,9 @@
(.module:
[lux (#- Module)
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
[collection
["." dictionary (#+ Dictionary)]]]
[type (#+ :share)
@@ -24,16 +24,16 @@
#content d}
(def: #export (read key document)
- (All [d] (-> (Key d) (Document Any) (Error d)))
+ (All [d] (-> (Key d) (Document Any) (Try d)))
(let [[document//signature document//content] (:representation document)]
(if (:: signature.equivalence =
(key.signature key)
document//signature)
- (#error.Success (:share [e]
- {(Key e)
- key}
- {e
- document//content}))
+ (#try.Success (:share [e]
+ {(Key e)
+ key}
+ {e
+ document//content}))
(ex.throw invalid-signature [(key.signature key)
document//signature]))))
diff --git a/stdlib/source/lux/tool/compiler/meta/cache.lux b/stdlib/source/lux/tool/compiler/meta/cache.lux
index 382ca7bfd..31cf37b9a 100644
--- a/stdlib/source/lux/tool/compiler/meta/cache.lux
+++ b/stdlib/source/lux/tool/compiler/meta/cache.lux
@@ -2,12 +2,12 @@
[lux (#- Module)
[control
["." monad (#+ Monad do)]
+ ["." try]
["ex" exception (#+ exception:)]
pipe]
[data
["." bit ("#;." equivalence)]
["." maybe]
- ["." error]
["." product]
[format
["." binary (#+ Format)]]
@@ -124,7 +124,7 @@
[document' (:: System<m> read (//io/archive.document System<m> root module))
[module' source-code] (//io/context.read System<m> contexts module)
#let [current-hash (:: text.hash hash source-code)]]
- (case (do error.monad
+ (case (do try.monad
[[signature descriptor content] (binary.read (..document binary) document')
#let [[document-hash _file references _state] descriptor]
_ (ex.assert mismatched-signature [module (get@ #//archive.signature key) signature]
@@ -135,10 +135,10 @@
(n/= current-hash document-hash))
document (//archive.write key signature descriptor content)]
(wrap [[module references] document]))
- (#error.Success [dependency document])
+ (#try.Success [dependency document])
(wrap (#.Some [dependency document]))
- (#error.Failure error)
+ (#try.Failure error)
(do @
[_ (un-install System<m> root module)]
(wrap #.None)))))
diff --git a/stdlib/source/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/lux/tool/compiler/meta/io/archive.lux
index bad568cb6..5b33e60a3 100644
--- a/stdlib/source/lux/tool/compiler/meta/io/archive.lux
+++ b/stdlib/source/lux/tool/compiler/meta/io/archive.lux
@@ -2,9 +2,9 @@
[lux (#- Module)
[control
monad
+ ["." try]
["ex" exception (#+ exception:)]]
[data
- ["." error]
["." text
["%" format (#+ format)]]]
[world
@@ -52,10 +52,10 @@
(do @
[outcome (:: System<m> try (:: System<m> make-directory document))]
(case outcome
- (#error.Success output)
+ (#try.Success output)
(wrap output)
- (#error.Failure _)
+ (#try.Failure _)
(:: System<m> throw cannot-prepare [archive module]))))))
(def: #export (write System<m> root content name)
diff --git a/stdlib/source/lux/tool/compiler/meta/io/context.lux b/stdlib/source/lux/tool/compiler/meta/io/context.lux
index 7ee9c063d..2e4b355bd 100644
--- a/stdlib/source/lux/tool/compiler/meta/io/context.lux
+++ b/stdlib/source/lux/tool/compiler/meta/io/context.lux
@@ -4,11 +4,11 @@
[abstract
[monad (#+ Monad do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ Exception exception:)]
[security
["!" capability]]]
[data
- ["." error (#+ Error)]
["." text ("#;." hash)
["%" format (#+ format)]
["." encoding]]]
@@ -45,7 +45,7 @@
(def: (find-source-file monad system contexts module extension)
(All [!]
(-> (Monad !) (file.System !) (List Context) Module Extension
- (! (Error [Path (File !)]))))
+ (! (Try [Path (File !)]))))
(case contexts
#.Nil
(:: monad wrap (ex.throw ..cannot-find-module [module]))
@@ -55,36 +55,36 @@
[#let [path (format (..path system context module) extension)]
file (!.use (:: system file) path)]
(case file
- (#error.Success file)
- (wrap (#error.Success [path file]))
+ (#try.Success file)
+ (wrap (#try.Success [path file]))
- (#error.Failure error)
+ (#try.Failure _)
(find-source-file monad system contexts' module extension)))))
(def: #export (find-any-source-file monad system contexts partial-host-extension module)
(All [!]
(-> (Monad !) (file.System !) (List Context) Text Module
- (! (Error [Path (File !)]))))
+ (! (Try [Path (File !)]))))
(let [full-host-extension (format partial-host-extension lux-extension)]
(do monad
[outcome (find-source-file monad system contexts module full-host-extension)]
(case outcome
- (#error.Success output)
+ (#try.Success output)
(wrap outcome)
- (#error.Failure error)
+ (#try.Failure _)
(find-source-file monad system contexts module ..lux-extension)))))
(def: #export (read monad system contexts partial-host-extension module)
(All [!]
(-> (Monad !) (file.System !) (List Context) Text Module
- (! (Error Input))))
- (do (error.with monad)
+ (! (Try Input))))
+ (do (try.with monad)
[## TODO: Get rid of both ":share"s ASAP
path,file (:share [!]
{(Monad !)
monad}
- {(! (Error [Path (File !)]))
+ {(! (Try [Path (File !)]))
(find-any-source-file monad system contexts partial-host-extension module)})
#let [[path file] (:share [!]
{(Monad !)
@@ -93,11 +93,11 @@
path,file})]
binary (!.use (:: file content) [])]
(case (encoding.from-utf8 binary)
- (#error.Success code)
+ (#try.Success code)
(wrap {#////.module module
#////.file path
#////.hash (text;hash code)
#////.code code})
- (#error.Failure _)
+ (#try.Failure _)
(:: monad wrap (ex.throw ..cannot-read-module [module])))))
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]))))
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis.lux b/stdlib/source/lux/tool/compiler/phase/analysis.lux
index 9281046c1..fbdb18f16 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis.lux
@@ -5,7 +5,6 @@
[control
["ex" exception (#+ exception:)]]
[data
- ["." error]
[text
["%" format (#+ format)]]]
["." macro]]
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/case.lux b/stdlib/source/lux/tool/compiler/phase/analysis/case.lux
index 85be37a90..dd45ab734 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/case.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/case.lux
@@ -3,10 +3,10 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try]
["ex" exception (#+ exception:)]]
[data
["." product]
- ["." error]
["." maybe]
[text
["%" format (#+ format)]]
@@ -304,12 +304,12 @@
branchesT)
outputHC (|> outputH product.left /coverage.determine)
outputTC (monad.map @ (|>> product.left /coverage.determine) outputT)
- _ (.case (monad.fold error.monad /coverage.merge outputHC outputTC)
- (#error.Success coverage)
+ _ (.case (monad.fold try.monad /coverage.merge outputHC outputTC)
+ (#try.Success coverage)
(///.assert non-exhaustive-pattern-matching [inputC branches coverage]
(/coverage.exhaustive? coverage))
- (#error.Failure error)
+ (#try.Failure error)
(/.fail error))]
(wrap (#/.Case inputA [outputH outputT])))
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/case/coverage.lux b/stdlib/source/lux/tool/compiler/phase/analysis/case/coverage.lux
index 067ce0972..af43a0e53 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/case/coverage.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/case/coverage.lux
@@ -4,10 +4,10 @@
equivalence
["." monad (#+ do)]]
[control
+ ["." try (#+ Try) ("#@." monad)]
["ex" exception (#+ exception:)]]
[data
["." bit ("#@." equivalence)]
- ["." error (#+ Error) ("#@." monad)]
["." maybe]
[number
["." nat]]
@@ -214,15 +214,15 @@
## pattern-matching expression is exhaustive and whether it contains
## redundant patterns.
(def: #export (merge addition so-far)
- (-> Coverage Coverage (Error Coverage))
+ (-> Coverage Coverage (Try Coverage))
(case [addition so-far]
[#Partial #Partial]
- (error@wrap #Partial)
+ (try@wrap #Partial)
## 2 bit coverages are exhaustive if they complement one another.
(^multi [(#Bit sideA) (#Bit sideSF)]
(xor sideA sideSF))
- (error@wrap #Exhaustive)
+ (try@wrap #Exhaustive)
[(#Variant allA casesA) (#Variant allSF casesSF)]
(let [addition-cases (cases allSF)
@@ -236,7 +236,7 @@
(ex.throw redundant-pattern [so-far addition])
## else
- (do error.monad
+ (do try.monad
[casesM (monad.fold @
(function (_ [tagA coverageA] casesSF')
(case (dictionary.get tagA casesSF')
@@ -266,7 +266,7 @@
(case [(coverage/= leftSF leftA) (coverage/= rightSF rightA)]
## Same prefix
[#1 #0]
- (do error.monad
+ (do try.monad
[rightM (merge rightA rightSF)]
(if (exhaustive? rightM)
## If all that follows is exhaustive, then it can be safely dropped
@@ -277,13 +277,13 @@
## Same suffix
[#0 #1]
- (do error.monad
+ (do try.monad
[leftM (merge leftA leftSF)]
(wrap (#Seq leftM rightA)))
## The 2 sequences cannot possibly be merged.
[#0 #0]
- (error@wrap (#Alt so-far addition))
+ (try@wrap (#Alt so-far addition))
## There is nothing the addition adds to the coverage.
[#1 #1]
@@ -295,7 +295,7 @@
## The addition completes the coverage.
[#Exhaustive _]
- (error@wrap #Exhaustive)
+ (try@wrap #Exhaustive)
## The left part will always match, so the addition is redundant.
(^multi [(#Seq left right) single]
@@ -305,7 +305,7 @@
## The right part is not necessary, since it can always match the left.
(^multi [single (#Seq left right)]
(coverage/= left single))
- (error@wrap single)
+ (try@wrap single)
## When merging a new coverage against one based on Alt, it may be
## that one of the many coverages in the Alt is complementary to
@@ -317,10 +317,10 @@
## This process must be repeated until no further productive
## merges can be done.
[_ (#Alt leftS rightS)]
- (do error.monad
+ (do try.monad
[#let [fuse-once (: (-> Coverage (List Coverage)
- (Error [(Maybe Coverage)
- (List Coverage)]))
+ (Try [(Maybe Coverage)
+ (List Coverage)]))
(function (_ coverageA possibilitiesSF)
(loop [altsSF possibilitiesSF]
(case altsSF
@@ -329,7 +329,7 @@
(#.Cons altSF altsSF')
(case (merge coverageA altSF)
- (#error.Success altMSF)
+ (#try.Success altMSF)
(case altMSF
(#Alt _)
(do @
@@ -339,8 +339,8 @@
_
(wrap [(#.Some altMSF) altsSF']))
- (#error.Failure error)
- (error.fail error))
+ (#try.Failure error)
+ (try.fail error))
))))]
[successA possibilitiesSF] (fuse-once addition (flatten-alt so-far))]
(loop [successA successA
@@ -366,4 +366,4 @@
## The addition cannot possibly improve the coverage.
(ex.throw redundant-pattern [so-far addition])
## There are now 2 alternative paths.
- (error@wrap (#Alt so-far addition)))))
+ (try@wrap (#Alt so-far addition)))))
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
index c6280e4b3..bb1094b2a 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
@@ -4,11 +4,11 @@
["." monad (#+ do)]]
[control
pipe
+ ["." try]
["ex" exception (#+ exception:)]]
[data
["." text ("#@." equivalence)
["%" format (#+ format)]]
- ["." error]
[collection
["." list ("#@." fold functor)]
[dictionary
@@ -72,10 +72,10 @@
(case (get@ #.module-annotations self)
#.None
(function (_ state)
- (#error.Success [(update@ #.modules
- (plist.put self-name (set@ #.module-annotations (#.Some annotations) self))
- state)
- []]))
+ (#try.Success [(update@ #.modules
+ (plist.put self-name (set@ #.module-annotations (#.Some annotations) self))
+ state)
+ []]))
(#.Some old)
(/.throw' cannot-set-module-annotations-more-than-once [self-name old annotations])))))
@@ -86,14 +86,14 @@
(do ///.monad
[self-name macro.current-module-name]
(function (_ state)
- (#error.Success [(update@ #.modules
- (plist.update self-name (update@ #.imports (function (_ current)
- (if (list.any? (text@= module)
- current)
- current
- (#.Cons module current)))))
- state)
- []])))))
+ (#try.Success [(update@ #.modules
+ (plist.update self-name (update@ #.imports (function (_ current)
+ (if (list.any? (text@= module)
+ current)
+ current
+ (#.Cons module current)))))
+ state)
+ []])))))
(def: #export (alias alias module)
(-> Text Text (Operation Any))
@@ -101,11 +101,11 @@
(do ///.monad
[self-name macro.current-module-name]
(function (_ state)
- (#error.Success [(update@ #.modules
- (plist.update self-name (update@ #.module-aliases (: (-> (List [Text Text]) (List [Text Text]))
- (|>> (#.Cons [alias module])))))
- state)
- []])))))
+ (#try.Success [(update@ #.modules
+ (plist.update self-name (update@ #.module-aliases (: (-> (List [Text Text]) (List [Text Text]))
+ (|>> (#.Cons [alias module])))))
+ state)
+ []])))))
(def: #export (exists? module)
(-> Text (Operation Bit))
@@ -115,7 +115,7 @@
(get@ #.modules)
(plist.get module)
(case> (#.Some _) #1 #.None #0)
- [state] #error.Success))))
+ [state] #try.Success))))
(def: #export (define name definition)
(-> Text Global (Operation Any))
@@ -126,14 +126,14 @@
(function (_ state)
(case (plist.get name (get@ #.definitions self))
#.None
- (#error.Success [(update@ #.modules
- (plist.put self-name
- (update@ #.definitions
- (: (-> (List [Text Global]) (List [Text Global]))
- (|>> (#.Cons [name definition])))
- self))
- state)
- []])
+ (#try.Success [(update@ #.modules
+ (plist.put self-name
+ (update@ #.definitions
+ (: (-> (List [Text Global]) (List [Text Global]))
+ (|>> (#.Cons [name definition])))
+ self))
+ state)
+ []])
(#.Some already-existing)
((/.throw' cannot-define-more-than-once [self-name name]) state))))))
@@ -143,10 +143,10 @@
(///extension.lift
(function (_ state)
(let [module (new hash)]
- (#error.Success [(update@ #.modules
- (plist.put name module)
- state)
- []])))))
+ (#try.Success [(update@ #.modules
+ (plist.put name module)
+ state)
+ []])))))
(def: #export (with-module hash name action)
(All [a] (-> Nat Text (Operation a) (Operation [Module a])))
@@ -168,10 +168,10 @@
#.Active #1
_ #0)]
(if active?
- (#error.Success [(update@ #.modules
- (plist.put module-name (set@ #.module-state <tag> module))
- state)
- []])
+ (#try.Success [(update@ #.modules
+ (plist.put module-name (set@ #.module-state <tag> module))
+ state)
+ []])
((/.throw' can-only-change-state-of-active-module [module-name <tag>])
state)))
@@ -184,10 +184,10 @@
(function (_ state)
(case (|> state (get@ #.modules) (plist.get module-name))
(#.Some module)
- (#error.Success [state
- (case (get@ #.module-state module)
- <tag> #1
- _ #0)])
+ (#try.Success [state
+ (case (get@ #.module-state module)
+ <tag> #1
+ _ #0)])
#.None
((/.throw' unknown-module module-name) state)))))]
@@ -204,7 +204,7 @@
(function (_ state)
(case (|> state (get@ #.modules) (plist.get module-name))
(#.Some module)
- (#error.Success [state (get@ <tag> module)])
+ (#try.Success [state (get@ <tag> module)])
#.None
((/.throw' unknown-module module-name) state)))))]
@@ -247,15 +247,15 @@
(case (|> state (get@ #.modules) (plist.get self-name))
(#.Some module)
(let [namespaced-tags (list@map (|>> [self-name]) tags)]
- (#error.Success [(update@ #.modules
- (plist.update self-name
- (|>> (update@ #.tags (function (_ tag-bindings)
- (list@fold (function (_ [idx tag] table)
- (plist.put tag [idx namespaced-tags exported? type] table))
- tag-bindings
- (list.enumerate tags))))
- (update@ #.types (plist.put type-name [namespaced-tags exported? type]))))
- state)
- []]))
+ (#try.Success [(update@ #.modules
+ (plist.update self-name
+ (|>> (update@ #.tags (function (_ tag-bindings)
+ (list@fold (function (_ [idx tag] table)
+ (plist.put tag [idx namespaced-tags exported? type] table))
+ tag-bindings
+ (list.enumerate tags))))
+ (update@ #.types (plist.put type-name [namespaced-tags exported? type]))))
+ state)
+ []]))
#.None
((/.throw' unknown-module self-name) state))))))
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/scope.lux b/stdlib/source/lux/tool/compiler/phase/analysis/scope.lux
index 104001da9..e5d145a54 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/scope.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/scope.lux
@@ -3,12 +3,12 @@
[abstract
monad]
[control
+ ["e" try]
["ex" exception (#+ exception:)]]
[data
["." text ("#;." equivalence)]
["." maybe ("#;." monad)]
["." product]
- ["e" error]
[collection
["." list ("#;." functor fold monoid)]
[dictionary
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/structure.lux b/stdlib/source/lux/tool/compiler/phase/analysis/structure.lux
index a630a8fab..eeb2cf9e0 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/structure.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/structure.lux
@@ -9,7 +9,6 @@
["." name]
["." product]
["." maybe]
- ["." error]
[number
["." nat]]
[text
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/type.lux b/stdlib/source/lux/tool/compiler/phase/analysis/type.lux
index d7ebbe2a3..20b313381 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/type.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/type.lux
@@ -3,9 +3,8 @@
[abstract
[monad (#+ do)]]
[control
- ["." function]]
- [data
- ["." error]]
+ ["." function]
+ ["." try]]
[type
["." check (#+ Check)]]
["." macro]]
@@ -23,11 +22,11 @@
(All [a] (-> (Check a) (Operation a)))
(function (_ (^@ stateE [bundle state]))
(case (action (get@ #.type-context state))
- (#error.Success [context' output])
- (#error.Success [[bundle (set@ #.type-context context' state)]
- output])
+ (#try.Success [context' output])
+ (#try.Success [[bundle (set@ #.type-context context' state)]
+ output])
- (#error.Failure error)
+ (#try.Failure error)
((/.fail error) stateE))))
(def: #export with-fresh-env
diff --git a/stdlib/source/lux/tool/compiler/phase/extension.lux b/stdlib/source/lux/tool/compiler/phase/extension.lux
index 4b00c946f..a0564cedd 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension.lux
@@ -4,9 +4,9 @@
[monad (#+ do)]]
[control
["." function]
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." text ("#@." order)
["%" format (#+ Format format)]]
[collection
@@ -67,8 +67,8 @@
(function (_ [bundle state])
(case (dictionary.get name bundle)
#.None
- (#error.Success [[(dictionary.put name handler bundle) state]
- []])
+ (#try.Success [[(dictionary.put name handler bundle) state]
+ []])
_
(exception.throw cannot-overwrite name))))
@@ -93,11 +93,11 @@
(function (_ [bundle state])
(let [old (get state)]
(case (operation [bundle (set (transform old) state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' (set old state')] output])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (set old state')] output])
- (#error.Failure error)
- (#error.Failure error))))))
+ (#try.Failure error)
+ (#try.Failure error))))))
(def: #export (temporary transform)
(All [s i o v]
@@ -106,11 +106,11 @@
(function (_ operation)
(function (_ [bundle state])
(case (operation [bundle (transform state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' state] output])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' state] output])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: #export (with-state state)
(All [s i o v]
@@ -121,13 +121,13 @@
(All [s i o v]
(-> (-> s v) (Operation s i o v)))
(function (_ [bundle state])
- (#error.Success [[bundle state] (get state)])))
+ (#try.Success [[bundle state] (get state)])))
(def: #export (update transform)
(All [s i o]
(-> (-> s s) (Operation s i o Any)))
(function (_ [bundle state])
- (#error.Success [[bundle (transform state)] []])))
+ (#try.Success [[bundle (transform state)] []])))
(def: #export (lift action)
(All [s i o v]
@@ -135,8 +135,8 @@
(//.Operation [(Bundle s i o) s] v)))
(function (_ [bundle state])
(case (action state)
- (#error.Success [state' output])
- (#error.Success [[bundle state'] output])
+ (#try.Success [state' output])
+ (#try.Success [[bundle state'] output])
- (#error.Failure error)
- (#error.Failure error))))
+ (#try.Failure error)
+ (#try.Failure error))))
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
index fa31254c8..3acecec11 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/jvm.lux
@@ -5,13 +5,13 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try) ("#@." monad)]
["<>" parser
["<c>" code (#+ Parser)]
["<t>" text]]
["." exception (#+ exception:)]
pipe]
[data
- ["." error (#+ Error) ("#@." monad)]
["." maybe]
["." product]
["." text ("#@." equivalence)
@@ -829,7 +829,7 @@
(function (_ extension-name analyse [class field])
(do ////.monad
[[final? fieldJT] (////.lift
- (do error.monad
+ (do try.monad
[class (reflection!.load class)]
(reflection!.static-field field class)))
fieldT (reflection-type luxT.fresh fieldJT)
@@ -847,7 +847,7 @@
(do ////.monad
[_ (typeA.infer Any)
[final? fieldJT] (////.lift
- (do error.monad
+ (do try.monad
[class (reflection!.load class)]
(reflection!.static-field field class)))
fieldT (reflection-type luxT.fresh fieldJT)
@@ -869,7 +869,7 @@
[[objectT objectA] (typeA.with-inference
(analyse objectC))
[mapping fieldJT] (////.lift
- (do error.monad
+ (do try.monad
[class (reflection!.load class)
[final? fieldJT] (reflection!.virtual-field field class)
mapping (reflection!.correspond class objectT)]
@@ -892,7 +892,7 @@
(analyse objectC))
_ (typeA.infer objectT)
[final? mapping fieldJT] (////.lift
- (do error.monad
+ (do try.monad
[class (reflection!.load class)
[final? fieldJT] (reflection!.virtual-field field class)
mapping (reflection!.correspond class objectT)]
@@ -921,8 +921,8 @@
(do ////.monad
[parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method)
array.to-list
- (monad.map error.monad reflection!.type)
- (:: error.monad map (list@map jvm.descriptor))
+ (monad.map try.monad reflection!.type)
+ (:: try.monad map (list@map jvm.descriptor))
////.lift)
#let [modifiers (java/lang/reflect/Method::getModifiers method)
correct-class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method))
@@ -958,8 +958,8 @@
(do ////.monad
[parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor)
array.to-list
- (monad.map error.monad reflection!.type)
- (:: error.monad map (list@map jvm.descriptor))
+ (monad.map try.monad reflection!.type)
+ (:: try.monad map (list@map jvm.descriptor))
////.lift)]
(wrap (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor))
(n/= (list.size arg-classes) (list.size parameters))
@@ -1401,13 +1401,13 @@
(template [<name> <filter>]
[(def: <name>
(-> (java/lang/Class java/lang/Object)
- (Error (List [Text Method])))
+ (Try (List [Text Method])))
(|>> java/lang/Class::getDeclaredMethods
array.to-list
<filter>
- (monad.map error.monad
+ (monad.map try.monad
(function (_ method)
- (do error.monad
+ (do try.monad
[inputs (|> (java/lang/reflect/Method::getGenericParameterTypes method)
array.to-list
(monad.map @ reflection!.type))
@@ -1428,11 +1428,11 @@
(template [<name> <methods>]
[(def: <name>
- (-> (List Class) (Error (List [Text Method])))
- (|>> (monad.map error.monad (|>> product.left reflection!.load))
- (error@map (monad.map error.monad <methods>))
- error@join
- (error@map list@join)))]
+ (-> (List Class) (Try (List [Text Method])))
+ (|>> (monad.map try.monad (|>> product.left reflection!.load))
+ (try@map (monad.map try.monad <methods>))
+ try@join
+ (try@map list@join)))]
[all-abstract-methods ..abstract-methods]
[all-methods ..methods]
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/lux.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/lux.lux
index 2086a0fea..efd917bd2 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/lux.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/lux.lux
@@ -4,12 +4,12 @@
["." monad (#+ do)]]
[control
[io (#+ IO)]
+ ["." try]
["." exception (#+ exception:)]
["<>" parser
["<c>" code (#+ Parser)]]]
[data
["." maybe]
- ["." error]
["." text
["%" format (#+ format)]]
[collection
@@ -37,10 +37,10 @@
Handler))
(function (_ extension-name analyse args)
(case (<c>.run syntax args)
- (#error.Success inputs)
+ (#try.Success inputs)
(handler extension-name analyse inputs)
- (#error.Failure error)
+ (#try.Failure _)
(/////analysis.throw ///.invalid-syntax [extension-name %.code args]))))
(def: (simple inputsT+ outputT)
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement/lux.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement/lux.lux
index e4cf0140e..56067c845 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/statement/lux.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/statement/lux.lux
@@ -4,13 +4,13 @@
["." monad (#+ do)]]
[control
[io (#+ IO)]
+ ["." try]
["." exception (#+ exception:)]
["p" parser
["s" code (#+ Parser)]]]
[data
["." product]
["." maybe]
- ["." error]
[text
["%" format (#+ format)]]
[collection
@@ -46,10 +46,10 @@
(Handler anchor expression statement)))
(function (_ extension-name phase inputs)
(case (s.run syntax inputs)
- (#error.Success inputs)
+ (#try.Success inputs)
(handler extension-name phase inputs)
- (#error.Failure error)
+ (#try.Failure error)
(////.throw ///.invalid-syntax [extension-name %.code inputs]))))
## TODO: Inline "evaluate!'" into "evaluate!" ASAP
diff --git a/stdlib/source/lux/tool/compiler/phase/generation.lux b/stdlib/source/lux/tool/compiler/phase/generation.lux
index 93dc97518..aa7d09d66 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation.lux
@@ -3,10 +3,10 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
["." product]
- ["." error (#+ Error)]
["." name ("#@." equivalence)]
["." text
["%" format (#+ format)]]
@@ -60,11 +60,11 @@
#inner-functions Nat})
(signature: #export (Host expression statement)
- (: (-> Text expression (Error Any))
+ (: (-> Text expression (Try Any))
evaluate!)
- (: (-> Text statement (Error Any))
+ (: (-> Text statement (Try Any))
execute!)
- (: (-> Name expression (Error [Text Any statement]))
+ (: (-> Name expression (Try [Text Any statement]))
define!))
(type: #export (Buffer statement) (Row [Name statement]))
@@ -111,12 +111,12 @@
(let [[old-scope old-inner] (get@ #context state)
new-scope (format old-scope "c" (%.nat old-inner))]
(case (expr [bundle (set@ #context [new-scope 0] state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' (set@ #context [old-scope (inc old-inner)] state')]
- [new-scope output]])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (set@ #context [old-scope (inc old-inner)] state')]
+ [new-scope output]])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: #export context
(All [anchor expression statement]
@@ -136,12 +136,12 @@
(function (_ body)
(function (_ [bundle state])
(case (body [bundle (set@ <tag> (#.Some <with-value>) state)])
- (#error.Success [[bundle' state'] output])
- (#error.Success [[bundle' (set@ <tag> (get@ <tag> state) state')]
- output])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (set@ <tag> (get@ <tag> state) state')]
+ output])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(def: #export <get>
(All [anchor expression statement]
@@ -149,7 +149,7 @@
(function (_ (^@ stateE [bundle state]))
(case (get@ <tag> state)
(#.Some output)
- (#error.Success [stateE output])
+ (#try.Success [stateE output])
#.None
(exception.throw <exception> []))))
@@ -158,8 +158,8 @@
(All [anchor expression statement]
(-> <get-type> (Operation anchor expression statement Any)))
(function (_ [bundle state])
- (#error.Success [[bundle (set@ <tag> (#.Some value) state)]
- []])))]
+ (#try.Success [[bundle (set@ <tag> (#.Some value) state)]
+ []])))]
[#anchor
(with-anchor anchor)
@@ -200,10 +200,10 @@
(-> Text <inputT> (Operation anchor expression statement Any)))
(function (_ (^@ state+ [bundle state]))
(case (:: (get@ #host state) <name> label code)
- (#error.Success output)
- (#error.Success [state+ output])
+ (#try.Success output)
+ (#try.Success [state+ output])
- (#error.Failure error)
+ (#try.Failure error)
(exception.throw cannot-interpret error))))]
[evaluate! expression]
@@ -215,10 +215,10 @@
(-> Name expression (Operation anchor expression statement [Text Any statement])))
(function (_ (^@ stateE [bundle state]))
(case (:: (get@ #host state) define! name code)
- (#error.Success output)
- (#error.Success [stateE output])
+ (#try.Success output)
+ (#try.Success [stateE output])
- (#error.Failure error)
+ (#try.Failure error)
(exception.throw cannot-interpret error))))
(def: #export (save! execute? name code)
@@ -253,7 +253,7 @@
(let [cache (get@ #name-cache state)]
(case (dictionary.get lux-name cache)
(#.Some host-name)
- (#error.Success [stateE host-name])
+ (#try.Success [stateE host-name])
#.None
(exception.throw unknown-lux-name [lux-name cache])))))
@@ -265,11 +265,11 @@
(let [cache (get@ #name-cache state)]
(case (dictionary.get lux-name cache)
#.None
- (#error.Success [[bundle
- (update@ #name-cache
- (dictionary.put lux-name host-name)
- state)]
- []])
+ (#try.Success [[bundle
+ (update@ #name-cache
+ (dictionary.put lux-name host-name)
+ state)]
+ []])
(#.Some old-host-name)
(exception.throw cannot-overwrite-lux-name [lux-name old-host-name host-name])))))
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/extension/common.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/extension/common.lux
index f2d22f57b..9baf594da 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/extension/common.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/extension/common.lux
@@ -4,11 +4,11 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try]
["<>" parser
["<s>" synthesis (#+ Parser)]]]
[data
["." product]
- ["." error]
[collection
["." list ("#@." functor)]
["." dictionary]]]
@@ -33,10 +33,10 @@
Handler))
(function (_ extension-name phase input)
(case (<s>.run input parser)
- (#error.Success input')
+ (#try.Success input')
(handler extension-name phase input')
- (#error.Failure error)
+ (#try.Failure error)
(/////.throw extension.invalid-syntax [extension-name %synthesis input]))))
## [Procedures]
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/extension/host.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/extension/host.lux
index 423f0a58d..c44e1bdff 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/extension/host.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/extension/host.lux
@@ -7,7 +7,6 @@
["<>" parser
["<s>" synthesis (#+ Parser)]]]
[data
- ["." error]
[collection
["." dictionary]]]
[target
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/scheme/extension/common.lux b/stdlib/source/lux/tool/compiler/phase/generation/scheme/extension/common.lux
index 42c1d196d..e23692e88 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/scheme/extension/common.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/scheme/extension/common.lux
@@ -8,7 +8,6 @@
[parser
["s" code]]]
[data
- ["e" error]
["." product]
["." text]
[number (#+ hex)]
diff --git a/stdlib/source/lux/tool/compiler/phase/macro.lux b/stdlib/source/lux/tool/compiler/phase/macro.lux
index 10d3cd332..db384c727 100644
--- a/stdlib/source/lux/tool/compiler/phase/macro.lux
+++ b/stdlib/source/lux/tool/compiler/phase/macro.lux
@@ -3,9 +3,9 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[collection
@@ -27,18 +27,18 @@
["Outputs" (exception.enumerate %.code outputs)]))
(type: #export Expander
- (-> Macro (List Code) Lux (Error (Error [Lux (List Code)]))))
+ (-> Macro (List Code) Lux (Try (Try [Lux (List Code)]))))
(def: #export (expand expander name macro inputs)
(-> Expander Name Macro (List Code) (Meta (List Code)))
(function (_ state)
- (do error.monad
+ (do try.monad
[output (expander macro inputs state)]
(case output
- (#error.Success output)
- (#error.Success output)
+ (#try.Success output)
+ (#try.Success output)
- (#error.Failure error)
+ (#try.Failure error)
((//.throw expansion-failed [name inputs error]) state)))))
(def: #export (expand-one expander name macro inputs)
diff --git a/stdlib/source/lux/tool/compiler/phase/synthesis.lux b/stdlib/source/lux/tool/compiler/phase/synthesis.lux
index 1b92abf97..45372e46b 100644
--- a/stdlib/source/lux/tool/compiler/phase/synthesis.lux
+++ b/stdlib/source/lux/tool/compiler/phase/synthesis.lux
@@ -3,10 +3,10 @@
[abstract
["." monad (#+ do)]]
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." try]]
[data
["." maybe]
- ["." error]
[collection
["." list ("#;." functor)]
["." dictionary (#+ Dictionary)]]]]
@@ -77,10 +77,10 @@
(function (_ state)
(|> (//extension.apply phase [name args])
(//.run' state)
- (case> (#error.Success output)
- (#error.Success output)
+ (case> (#try.Success output)
+ (#try.Success output)
- (#error.Failure error)
+ (#try.Failure _)
(<| (//.run' state)
(do //.monad
[argsS+ (monad.map @ phase args)]
diff --git a/stdlib/source/lux/tool/interpreter.lux b/stdlib/source/lux/tool/interpreter.lux
index b836e4139..44f14f0ab 100644
--- a/stdlib/source/lux/tool/interpreter.lux
+++ b/stdlib/source/lux/tool/interpreter.lux
@@ -2,9 +2,9 @@
[lux #*
[control
[monad (#+ Monad do)]
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
["." text ("#;." equivalence)
["%" format (#+ format)]]]
[type (#+ :share)
@@ -129,10 +129,10 @@
state}
{<Interpretation>
(interpret-statement code)}))
- (#error.Success [state' output])
- (#error.Success [state' output])
+ (#try.Success [state' output])
+ (#try.Success [state' output])
- (#error.Failure error)
+ (#try.Failure error)
(if (ex.match? total.not-a-statement error)
(<| (phase.run' state)
(:share [anchor expression statement]
@@ -140,7 +140,7 @@
state}
{<Interpretation>
(interpret-expression code)}))
- (#error.Failure error)))))
+ (#try.Failure error)))))
)
(def: (execute configuration code)
@@ -164,8 +164,8 @@
(with-expansions [<Context> (as-is (Context anchor expression statement))]
(def: (read-eval-print context)
(All [anchor expression statement]
- (-> <Context> (Error [<Context> Text])))
- (do error.monad
+ (-> <Context> (Try [<Context> Text])))
+ (do try.monad
[#let [[_where _offset _code] (get@ #source context)]
[source' input] (syntax.parse ..module syntax.no-aliases (text.size _code) (get@ #source context))
[state' representation] (let [## TODO: Simplify ASAP
@@ -208,12 +208,12 @@
(text;= ..exit-command line))
(:: Console<!> write ..farewell-message)
(case (read-eval-print (update@ #source (add-line line) context))
- (#error.Success [context' representation])
+ (#try.Success [context' representation])
(do @
[_ (:: Console<!> write representation)]
(recur context' #0))
- (#error.Failure error)
+ (#try.Failure error)
(if (ex.match? syntax.end-of-file error)
(recur context #1)
(exec (log! (ex.construct ..error error))
diff --git a/stdlib/source/lux/tool/mediator.lux b/stdlib/source/lux/tool/mediator.lux
index 4481b6e2e..5beb217e0 100644
--- a/stdlib/source/lux/tool/mediator.lux
+++ b/stdlib/source/lux/tool/mediator.lux
@@ -1,7 +1,5 @@
(.module:
[lux (#- Source Module)
- [data
- ["." error (#+ Error)]]
[world
["." binary (#+ Binary)]
["." file (#+ File)]]]
diff --git a/stdlib/source/lux/tool/mediator/parallelism.lux b/stdlib/source/lux/tool/mediator/parallelism.lux
index c45c1aeb5..10aaa0b0e 100644
--- a/stdlib/source/lux/tool/mediator/parallelism.lux
+++ b/stdlib/source/lux/tool/mediator/parallelism.lux
@@ -2,13 +2,13 @@
[lux (#- Source Module)
[control
["." monad (#+ Monad do)]
+ ["." try (#+ Try) ("#;." monad)]
["ex" exception (#+ exception:)]]
[concurrency
["." promise (#+ Promise) ("#;." functor)]
["." task (#+ Task)]
["." stm (#+ Var STM)]]
[data
- ["." error (#+ Error) ("#;." monad)]
["." text ("#;." equivalence)]
[collection
["." list ("#;." functor)]
@@ -32,7 +32,7 @@
["Dependency" dependency]))
(type: Pending-Compilation
- (Promise (Error (Ex [d] (Document d)))))
+ (Promise (Try (Ex [d] (Document d)))))
(type: Active-Compilations
(Dictionary Module [Descriptor Pending-Compilation]))
@@ -72,9 +72,9 @@
(def: (share-compilation archive pending)
(-> Active-Compilations Pending-Compilation (Task Archive))
- (promise;map (|>> (error;map (function (_ document)
- (archive.add module document archive)))
- error;join)
+ (promise;map (|>> (try;map (function (_ document)
+ (archive.add module document archive)))
+ try;join)
pending))
(def: (import Monad<!> mediate archive dependencies)
@@ -87,8 +87,8 @@
(All [d o] (-> Archive (List Archive) (Compilation d o)
[Archive (Either (Compilation d o)
[(Document d) (Output o)])]))
- (do error.monad
- [archive' (monad.fold error.monad archive.merge archive imports)
+ (do try.monad
+ [archive' (monad.fold try.monad archive.merge archive imports)
outcome (process archive')]
(case outcome
(#.Right [document output])
@@ -128,7 +128,7 @@
#descriptor.file (get@ #compiler.file input)
#descriptor.references (list)
#descriptor.state #.Active}
- pending (promise.promise (: (Maybe (Error (Ex [d] (Document d))))
+ pending (promise.promise (: (Maybe (Try (Ex [d] (Document d))))
#.None))]
updated (stm.update (dictionary.put (get@ #compiler.module input)
[base-descriptor pending])
@@ -150,7 +150,7 @@
(recur archive' continue)
(#.Right [document output])
- (exec (io.run (promise.resolve (#error.Success document) pending))
+ (exec (io.run (promise.resolve (#try.Success document) pending))
(wrap archive'))))))
(def: #export (mediator file-system sources compiler)
diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux
index 23abe544a..ffbd8af09 100644
--- a/stdlib/source/lux/type/check.lux
+++ b/stdlib/source/lux/type/check.lux
@@ -5,11 +5,11 @@
[apply (#+ Apply)]
["." monad (#+ Monad do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ Exception exception:)]]
[data
["." maybe]
["." product]
- ["." error (#+ Error)]
[number
["." nat ("#@." decimal)]]
["." text ("#@." monoid equivalence)]
@@ -53,7 +53,7 @@
(type: #export Assumption [Type Type])
(type: #export (Check a)
- (-> Type-Context (Error [Type-Context a])))
+ (-> Type-Context (Try [Type-Context a])))
(type: #export (Checker a)
(-> (List Assumption) a a (Check (List Assumption))))
@@ -65,11 +65,11 @@
(def: (map f fa)
(function (_ context)
(case (fa context)
- (#error.Success [context' output])
- (#error.Success [context' (f output)])
+ (#try.Success [context' output])
+ (#try.Success [context' (f output)])
- (#error.Failure error)
- (#error.Failure error)))))
+ (#try.Failure error)
+ (#try.Failure error)))))
(structure: #export apply (Apply Check)
(def: &functor ..functor)
@@ -77,16 +77,16 @@
(def: (apply ff fa)
(function (_ context)
(case (ff context)
- (#error.Success [context' f])
+ (#try.Success [context' f])
(case (fa context')
- (#error.Success [context'' a])
- (#error.Success [context'' (f a)])
+ (#try.Success [context'' a])
+ (#try.Success [context'' (f a)])
- (#error.Failure error)
- (#error.Failure error))
+ (#try.Failure error)
+ (#try.Failure error))
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
)))
)
@@ -95,21 +95,21 @@
(def: (wrap x)
(function (_ context)
- (#error.Success [context x])))
+ (#try.Success [context x])))
(def: (join ffa)
(function (_ context)
(case (ffa context)
- (#error.Success [context' fa])
+ (#try.Success [context' fa])
(case (fa context')
- (#error.Success [context'' a])
- (#error.Success [context'' a])
+ (#try.Success [context'' a])
+ (#try.Success [context'' a])
- (#error.Failure error)
- (#error.Failure error))
+ (#try.Failure error)
+ (#try.Failure error))
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
)))
)
@@ -146,25 +146,25 @@
(var::put id value plist')))))
(def: #export (run context proc)
- (All [a] (-> Type-Context (Check a) (Error a)))
+ (All [a] (-> Type-Context (Check a) (Try a)))
(case (proc context)
- (#error.Success [context' output])
- (#error.Success output)
+ (#try.Success [context' output])
+ (#try.Success output)
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
(def: #export (fail message)
(All [a] (-> Text (Check a)))
(function (_ context)
- (#error.Failure message)))
+ (#try.Failure message)))
(def: #export (assert message test)
(-> Text Bit (Check Any))
(function (_ context)
(if test
- (#error.Success [context []])
- (#error.Failure message))))
+ (#try.Success [context []])
+ (#try.Failure message))))
(def: #export (throw exception message)
(All [e a] (-> (Exception e) e (Check a)))
@@ -175,8 +175,8 @@
(Check [Nat Type])
(function (_ context)
(let [id (get@ #.ex-counter context)]
- (#error.Success [(update@ #.ex-counter inc context)
- [id (#.Ex id)]]))))
+ (#try.Success [(update@ #.ex-counter inc context)
+ [id (#.Ex id)]]))))
(template [<name> <outputT> <fail> <succeed>]
[(def: #export (<name> id)
@@ -185,10 +185,10 @@
(case (|> context (get@ #.var-bindings) (var::get id))
(^or (#.Some (#.Some (#.Var _)))
(#.Some #.None))
- (#error.Success [context <fail>])
+ (#try.Success [context <fail>])
(#.Some (#.Some bound))
- (#error.Success [context <succeed>])
+ (#try.Success [context <succeed>])
#.None
(exception.throw unknown-type-var id))))]
@@ -213,7 +213,7 @@
(function (_ context)
(case (|> context (get@ #.var-bindings) (var::get id))
(#.Some (#.Some bound))
- (#error.Success [context bound])
+ (#try.Success [context bound])
(#.Some _)
(exception.throw unbound-type-var id)
@@ -226,8 +226,8 @@
(function (_ context)
(case (|> context (get@ #.var-bindings) (var::get id))
(#.Some #.None)
- (#error.Success [(update@ #.var-bindings (var::put id (#.Some type)) context)
- []])
+ (#try.Success [(update@ #.var-bindings (var::put id (#.Some type)) context)
+ []])
(#.Some (#.Some bound))
(exception.throw cannot-rebind-var [id type bound])
@@ -240,8 +240,8 @@
(function (_ context)
(case (|> context (get@ #.var-bindings) (var::get id))
(#.Some _)
- (#error.Success [(update@ #.var-bindings (var::put id (#.Some type)) context)
- []])
+ (#try.Success [(update@ #.var-bindings (var::put id (#.Some type)) context)
+ []])
_
(exception.throw unknown-type-var id))))
@@ -250,10 +250,10 @@
(Check [Var Type])
(function (_ context)
(let [id (get@ #.var-counter context)]
- (#error.Success [(|> context
- (update@ #.var-counter inc)
- (update@ #.var-bindings (var::new id)))
- [id (#.Var id)]]))))
+ (#try.Success [(|> context
+ (update@ #.var-counter inc)
+ (update@ #.var-bindings (var::new id)))
+ [id (#.Var id)]]))))
(def: (apply-type! funcT argT)
(-> Type Type (Check Type))
@@ -296,14 +296,14 @@
(case type
(#.Var post)
(if (!n/= start post)
- (#error.Success [context output])
+ (#try.Success [context output])
(recur post (set.add post output)))
_
- (#error.Success [context empty-ring]))
+ (#try.Success [context empty-ring]))
(#.Some #.None)
- (#error.Success [context output])
+ (#try.Success [context output])
#.None
(exception.throw unknown-type-var current)))))
@@ -318,17 +318,17 @@
(All [a] (-> (Check a) (Check (Maybe a))))
(function (_ context)
(case (op context)
- (#error.Success [context' output])
- (#error.Success [context' (#.Some output)])
+ (#try.Success [context' output])
+ (#try.Success [context' (#.Some output)])
- (#error.Failure _)
- (#error.Success [context #.None]))))
+ (#try.Failure _)
+ (#try.Success [context #.None]))))
(def: (either left right)
(All [a] (-> (Check a) (Check a) (Check a)))
(function (_ context)
(case (left context)
- (#error.Failure _)
+ (#try.Failure _)
(right context)
output
@@ -486,10 +486,10 @@
[expected-function' (read! id)]
(check' assumptions (#.Apply expected-input expected-function') (#.Apply actual)))
context)
- (#error.Success output)
- (#error.Success output)
+ (#try.Success output)
+ (#try.Success output)
- (#error.Failure error)
+ (#try.Failure _)
(case actual-function
(#.UnivQ _ _)
((do ..monad
@@ -517,8 +517,8 @@
[actual-function' (read! id)]
(check' assumptions (#.Apply expected) (#.Apply actual-input actual-function')))
context)
- (#error.Success output)
- (#error.Success output)
+ (#try.Success output)
+ (#try.Success output)
_
((do ..monad
@@ -653,16 +653,16 @@
{#.doc "A simple type-checking function that just returns a yes/no answer."}
(-> Type Type Bit)
(case (run fresh-context (check' (list) expected actual))
- (#error.Failure _)
+ (#try.Failure _)
false
- (#error.Success _)
+ (#try.Success _)
true))
(def: #export context
(Check Type-Context)
(function (_ context)
- (#error.Success [context context])))
+ (#try.Success [context context])))
(def: #export (clean inputT)
(-> Type (Check Type))
diff --git a/stdlib/source/lux/type/dynamic.lux b/stdlib/source/lux/type/dynamic.lux
index 32b4c7f70..bd72e30b3 100644
--- a/stdlib/source/lux/type/dynamic.lux
+++ b/stdlib/source/lux/type/dynamic.lux
@@ -2,9 +2,9 @@
[lux #*
["." debug]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]]
[macro (#+ with-gensyms)
@@ -33,18 +33,18 @@
((~! ..dynamic-abstraction) [(:of (~ g!value)) (~ g!value)])))))))
(syntax: #export (:check type value)
- {#.doc (doc (: (error.Error Nat)
+ {#.doc (doc (: (try.Try Nat)
(:check Nat (:dynamic 123))))}
(with-gensyms [g!type g!value]
(wrap (list (` (let [[(~ g!type) (~ g!value)] ((~! ..dynamic-representation) (~ value))]
- (: ((~! error.Error) (~ type))
+ (: ((~! try.Try) (~ type))
(if (:: (~! type.equivalence) (~' =)
(.type (~ type)) (~ g!type))
- (#error.Success (:coerce (~ type) (~ g!value)))
+ (#try.Success (:coerce (~ type) (~ g!value)))
((~! exception.throw) ..wrong-type [(.type (~ type)) (~ g!type)])))))))))
(def: #export (print value)
- (-> Dynamic (Error Text))
+ (-> Dynamic (Try Text))
(let [[type value] (:representation value)]
(debug.represent type value)))
)
diff --git a/stdlib/source/lux/world/console.lux b/stdlib/source/lux/world/console.lux
index f880fc5f9..89d36be8a 100644
--- a/stdlib/source/lux/world/console.lux
+++ b/stdlib/source/lux/world/console.lux
@@ -5,6 +5,7 @@
[abstract
[monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
["." io (#+ IO io)]
[concurrency
@@ -12,7 +13,6 @@
[security
["!" capability (#+ capability:)]]]
[data
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]]])
@@ -25,13 +25,13 @@
)
(capability: #export (Can-Read ! o)
- (can-read [] (! (Error o))))
+ (can-read [] (! (Try o))))
(capability: #export (Can-Write ! i)
- (can-write i (! (Error Any))))
+ (can-write i (! (Try Any))))
(capability: #export (Can-Close !)
- (can-close [] (! (Error Any))))
+ (can-close [] (! (Try Any))))
(signature: #export (Console !)
(: (Can-Read ! Nat)
@@ -72,7 +72,7 @@
(#static out java/io/PrintStream))
(def: #export system
- (IO (Error (Console IO)))
+ (IO (Try (Console IO)))
(do io.monad
[?jvm-console (System::console)]
(case ?jvm-console
@@ -91,7 +91,7 @@
(function (_ _)
(|> jvm-input
InputStream::read
- (:: (error.with io.monad) map .nat)))))
+ (:: (try.with io.monad) map .nat)))))
(def: can-read-line
(..can-read
diff --git a/stdlib/source/lux/world/db/jdbc.lux b/stdlib/source/lux/world/db/jdbc.lux
index 624f8b510..d2a6f3db2 100644
--- a/stdlib/source/lux/world/db/jdbc.lux
+++ b/stdlib/source/lux/world/db/jdbc.lux
@@ -4,6 +4,7 @@
[functor (#+ Functor)]
[apply (#+ Apply)]
[monad (#+ Monad do)]
+ ["." try (#+ Try)]
["ex" exception]
[concurrency
["." promise (#+ Promise) ("#;." monad)]]
@@ -11,7 +12,6 @@
["!" capability (#+ capability:)]]]
[data
["." product]
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]
[collection
@@ -63,17 +63,17 @@
(template [<name> <forge> <output>]
[(capability: #export (<name> ! i)
- (<forge> (Statement i) (! (Error <output>))))]
+ (<forge> (Statement i) (! (Try <output>))))]
[Can-Execute can-execute Nat]
[Can-Insert can-insert (List ID)]
)
(capability: #export (Can-Query ! i o)
- (can-query [(Statement i) (Output o)] (! (Error (List o)))))
+ (can-query [(Statement i) (Output o)] (! (Try (List o)))))
(capability: #export (Can-Close !)
- (can-close Any (! (Error Any))))
+ (can-close Any (! (Try Any))))
(signature: #export (DB !)
(: (Can-Execute !)
@@ -88,9 +88,9 @@
(def: (with-statement statement conn action)
(All [i a]
(-> (Statement i) java/sql/Connection
- (-> java/sql/PreparedStatement (IO (Error a)))
- (IO (Error a))))
- (do (error.with io.monad)
+ (-> java/sql/PreparedStatement (IO (Try a)))
+ (IO (Try a))))
+ (do (try.with io.monad)
[prepared (io.io (java/sql/Connection::prepareStatement (sql.sql (get@ #sql statement))
(java/sql/Statement::RETURN_GENERATED_KEYS)
conn))
@@ -111,8 +111,8 @@
[query can-query])))))
(def: #export (connect creds)
- (-> Credentials (IO (Error (DB IO))))
- (do (error.with io.monad)
+ (-> Credentials (IO (Try (DB IO))))
+ (do (try.with io.monad)
[connection (java/sql/DriverManager::getConnection (get@ #url creds)
(get@ #user creds)
(get@ #password creds))]
@@ -123,7 +123,7 @@
(function (execute statement)
(with-statement statement connection
(function (_ prepared)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[row-count (java/sql/PreparedStatement::executeUpdate prepared)]
(wrap (.nat row-count))))))))
@@ -132,7 +132,7 @@
(function (insert statement)
(with-statement statement connection
(function (_ prepared)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[_ (java/sql/PreparedStatement::executeUpdate prepared)
result-set (io.io (java/sql/Statement::getGeneratedKeys prepared))]
(/output.rows /output.long result-set)))))))
@@ -147,7 +147,7 @@
(function (query [statement output])
(with-statement statement connection
(function (_ prepared)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[result-set (java/sql/PreparedStatement::executeQuery prepared)]
(/output.rows output result-set)))))))
)))))
@@ -155,9 +155,9 @@
(def: #export (with-db creds action)
(All [a]
(-> Credentials
- (-> (DB IO) (IO (Error a)))
- (IO (Error a))))
- (do (error.with io.monad)
+ (-> (DB IO) (IO (Try a)))
+ (IO (Try a))))
+ (do (try.with io.monad)
[db (..connect creds)
result (action db)
_ (!.use (:: db close) [])]
@@ -166,9 +166,9 @@
(def: #export (with-async-db creds action)
(All [a]
(-> Credentials
- (-> (DB Promise) (Promise (Error a)))
- (Promise (Error a))))
- (do (error.with promise.monad)
+ (-> (DB Promise) (Promise (Try a)))
+ (Promise (Try a))))
+ (do (try.with promise.monad)
[db (promise.future (..connect creds))
result (action (..async db))
_ (promise;wrap (io.run (!.use (:: db close) [])))]
diff --git a/stdlib/source/lux/world/db/jdbc/input.lux b/stdlib/source/lux/world/db/jdbc/input.lux
index b160c5a5c..30634a3df 100644
--- a/stdlib/source/lux/world/db/jdbc/input.lux
+++ b/stdlib/source/lux/world/db/jdbc/input.lux
@@ -2,9 +2,9 @@
[lux (#- and int)
[control
[functor (#+ Contravariant)]
- [monad (#+ Monad do)]]
+ [monad (#+ Monad do)]
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
[collection
["." list ("#;." fold)]]]
[time
@@ -47,7 +47,7 @@
(type: #export (Input a)
(-> a [Nat java/sql/PreparedStatement]
- (Error [Nat java/sql/PreparedStatement])))
+ (Try [Nat java/sql/PreparedStatement])))
(structure: #export contravariant (Contravariant Input)
(def: (map-1 f fb)
@@ -57,25 +57,25 @@
(def: #export (and pre post)
(All [l r] (-> (Input l) (Input r) (Input [l r])))
(function (_ [left right] context)
- (do error.monad
+ (do try.monad
[context (pre left context)]
(post right context))))
(def: #export (fail error)
(All [a] (-> Text (Input a)))
(function (_ value [idx context])
- (#error.Failure error)))
+ (#try.Failure error)))
(def: #export empty
(Input Any)
(function (_ value context)
- (#error.Success context)))
+ (#try.Success context)))
(template [<function> <type> <setter>]
[(def: #export <function>
(Input <type>)
(function (_ value [idx statement])
- (do error.monad
+ (do try.monad
[_ (<setter> (.int idx) value statement)]
(wrap [(.inc idx) statement]))))]
@@ -97,7 +97,7 @@
[(def: #export <function>
(Input Instant)
(function (_ value [idx statement])
- (do error.monad
+ (do try.monad
[_ (<setter> (.int idx)
(<constructor> (instant.to-millis value))
statement)]
diff --git a/stdlib/source/lux/world/db/jdbc/output.lux b/stdlib/source/lux/world/db/jdbc/output.lux
index 8c461bb68..5d76b69bc 100644
--- a/stdlib/source/lux/world/db/jdbc/output.lux
+++ b/stdlib/source/lux/world/db/jdbc/output.lux
@@ -4,9 +4,8 @@
[functor (#+ Functor)]
[apply (#+ Apply)]
[monad (#+ Monad do)]
- ["ex" exception]]
- [data
- ["." error (#+ Error)]]
+ ["ex" exception]
+ ["." try (#+ Try)]]
[time
["." instant (#+ Instant)]]
["." io (#+ IO)]
@@ -48,17 +47,17 @@
(close [] #io #try void)))
(type: #export (Output a)
- (-> [Nat java/sql/ResultSet] (Error [Nat a])))
+ (-> [Nat java/sql/ResultSet] (Try [Nat a])))
(structure: #export functor (Functor Output)
(def: (map f fa)
(function (_ idx+rs)
(case (fa idx+rs)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [idx' value])
- (#error.Success [idx' (f value)])))))
+ (#try.Success [idx' value])
+ (#try.Success [idx' (f value)])))))
(structure: #export apply (Apply Output)
(def: &functor ..functor)
@@ -66,16 +65,16 @@
(def: (apply ff fa)
(function (_ [idx rs])
(case (ff [idx rs])
- (#error.Success [idx' f])
+ (#try.Success [idx' f])
(case (fa [idx' rs])
- (#error.Success [idx'' a])
- (#error.Success [idx'' (f a)])
+ (#try.Success [idx'' a])
+ (#try.Success [idx'' (f a)])
- (#error.Failure msg)
- (#error.Failure msg))
+ (#try.Failure msg)
+ (#try.Failure msg))
- (#error.Failure msg)
- (#error.Failure msg)))))
+ (#try.Failure msg)
+ (#try.Failure msg)))))
(structure: #export monad (Monad Output)
(def: &functor ..functor)
@@ -87,16 +86,16 @@
(def: (join mma)
(function (_ [idx rs])
(case (mma [idx rs])
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success [idx' ma])
+ (#try.Success [idx' ma])
(ma [idx' rs])))))
(def: #export (fail error)
(All [a] (-> Text (Output a)))
(function (_ [idx result-set])
- (#error.Failure error)))
+ (#try.Failure error)))
(def: #export (and left right)
(All [a b]
@@ -111,11 +110,11 @@
(Output <type>)
(function (_ [idx result-set])
(case (<method-name> [(.int idx)] result-set)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success value)
- (#error.Success [(inc idx) value]))))]
+ (#try.Success value)
+ (#try.Success [(inc idx) value]))))]
[boolean java/sql/ResultSet::getBoolean Bit]
@@ -136,12 +135,12 @@
(Output Instant)
(function (_ [idx result-set])
(case (<method-name> [(.int idx)] result-set)
- (#error.Failure error)
- (#error.Failure error)
+ (#try.Failure error)
+ (#try.Failure error)
- (#error.Success value)
- (#error.Success [(inc idx)
- (instant.from-millis (java/util/Date::getTime value))]))))]
+ (#try.Success value)
+ (#try.Success [(inc idx)
+ (instant.from-millis (java/util/Date::getTime value))]))))]
[date java/sql/ResultSet::getDate]
[time java/sql/ResultSet::getTime]
@@ -149,41 +148,41 @@
)
(def: #export (rows output results)
- (All [a] (-> (Output a) java/sql/ResultSet (IO (Error (List a)))))
+ (All [a] (-> (Output a) java/sql/ResultSet (IO (Try (List a)))))
(case (java/sql/ResultSet::next results)
- (#error.Success has-next?)
+ (#try.Success has-next?)
(if has-next?
(case (output [1 results])
(#.Some [_ head])
(do io.monad
[?tail (rows output results)]
(case ?tail
- (#error.Success tail)
+ (#try.Success tail)
(wrap (ex.return (#.Cons head tail)))
- (#error.Failure error)
+ (#try.Failure error)
(do io.monad
[temp (java/sql/ResultSet::close results)]
- (wrap (do error.monad
+ (wrap (do try.monad
[_ temp]
- (error.fail error))))))
+ (try.fail error))))))
- (#error.Failure error)
+ (#try.Failure error)
(do io.monad
[temp (java/sql/ResultSet::close results)]
- (wrap (do error.monad
+ (wrap (do try.monad
[_ temp]
- (error.fail error)))))
+ (try.fail error)))))
(do io.monad
[temp (java/sql/ResultSet::close results)]
- (wrap (do error.monad
+ (wrap (do try.monad
[_ temp]
(wrap (list))))))
- (#error.Failure error)
+ (#try.Failure error)
(do io.monad
[temp (java/sql/ResultSet::close results)]
- (wrap (do error.monad
+ (wrap (do try.monad
[_ temp]
- (error.fail error))))
+ (try.fail error))))
))
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 8c79ca0e8..5a1903a31 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -5,6 +5,7 @@
[abstract
["." monad (#+ Monad do)]]
[control
+ ["." try (#+ Try) ("#;." functor)]
["." exception (#+ Exception exception:)]
["." io (#+ IO) ("#;." functor)]
[concurrency
@@ -14,7 +15,6 @@
[data
["." product]
["." maybe]
- ["." error (#+ Error) ("#;." functor)]
["." binary (#+ Binary)]
["." text
["%" format (#+ format)]]
@@ -30,16 +30,16 @@
(type: #export Path Text)
(capability: #export (Can-Open ! capability)
- (can-open Path (! (Error (capability !)))))
+ (can-open Path (! (Try (capability !)))))
(capability: #export (Can-Query ! o)
- (can-query [] (! (Error o))))
+ (can-query [] (! (Try o))))
(capability: #export (Can-Modify ! i)
- (can-modify [i] (! (Error Any))))
+ (can-modify [i] (! (Try Any))))
(capability: #export (Can-Delete !)
- (can-delete [] (! (Error Any))))
+ (can-delete [] (! (Try Any))))
(`` (signature: #export (File !)
(~~ (template [<name> <output>]
@@ -113,14 +113,14 @@
[[delete]]]))
(def: move (..can-open
- (|>> (!.use (:: file move)) (io;map (error;map async-file)) promise.future))))))
+ (|>> (!.use (:: file move)) (io;map (try;map async-file)) promise.future))))))
(def: (async-directory directory)
(-> (Directory IO) (Directory Promise))
(`` (structure (~~ (template [<name> <async>]
[(def: <name> (..can-query
(|>> (!.use (:: directory <name>))
- (io;map (error;map (list@map <async>)))
+ (io;map (try;map (list@map <async>)))
promise.future)))]
[files ..async-file]
@@ -134,7 +134,7 @@
(`` (structure
(~~ (template [<name> <async>]
[(def: <name> (..can-open
- (|>> (!.use (:: system <name>)) (io;map (error;map <async>)) promise.future)))]
+ (|>> (!.use (:: system <name>)) (io;map (try;map <async>)) promise.future)))]
[file ..async-file]
[create-file ..async-file]
@@ -209,8 +209,8 @@
(do io.monad
[outcome (java/io/File::delete (java/io/File::new path))]
(case outcome
- (#error.Success #1)
- (wrap (#error.Success []))
+ (#try.Success #1)
+ (wrap (#try.Success []))
_
(io.io (exception.throw exception [path])))))
@@ -238,7 +238,7 @@
[(def: <name>
(..can-modify
(function (<name> data)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[stream (FileOutputStream::new (java/io/File::new path) <flag>)
_ (OutputStream::write data stream)
_ (OutputStream::flush stream)]
@@ -251,7 +251,7 @@
(def: content
(..can-query
(function (content _)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[#let [file (java/io/File::new path)]
size (java/io/File::length file)
#let [data (binary.create (.nat size))]
@@ -268,7 +268,7 @@
(|> path
java/io/File::new
java/io/File::length
- (:: (error.with io.monad) map .nat)))))
+ (:: (try.with io.monad) map .nat)))))
(def: last-modified
(..can-query
@@ -276,7 +276,7 @@
(|> path
java/io/File::new
(java/io/File::lastModified)
- (:: (error.with io.monad) map (|>> duration.from-millis instant.absolute))))))
+ (:: (try.with io.monad) map (|>> duration.from-millis instant.absolute))))))
(def: can-execute?
(..can-query
@@ -292,8 +292,8 @@
[outcome (java/io/File::renameTo (java/io/File::new destination)
(java/io/File::new path))]
(case outcome
- (#error.Success #1)
- (wrap (#error.Success (file destination)))
+ (#try.Success #1)
+ (wrap (#try.Success (file destination)))
_
(io.io (exception.throw cannot-move [destination path])))))))
@@ -305,8 +305,8 @@
[outcome (java/io/File::setLastModified (|> time-stamp instant.relative duration.to-millis)
(java/io/File::new path))]
(case outcome
- (#error.Success #1)
- (wrap (#error.Success []))
+ (#try.Success #1)
+ (wrap (#try.Success []))
_
(io.io (exception.throw cannot-modify [time-stamp path])))))))
@@ -323,7 +323,7 @@
[(def: <name>
(..can-query
(function (<name> _)
- (do (error.with io.monad)
+ (do (try.with io.monad)
[?children (java/io/File::listFiles (java/io/File::new path))]
(case ?children
(#.Some children)
@@ -354,8 +354,8 @@
[#let [file (java/io/File::new path)]
outcome (<method> file)]
(case outcome
- (#error.Success #1)
- (wrap (#error.Success (<capability> path)))
+ (#try.Success #1)
+ (wrap (#try.Success (<capability> path)))
_
(wrap (exception.throw <exception> [path])))))))]
@@ -378,9 +378,6 @@
(as-is (import: Buffer
(#static from [Binary] ..Buffer))
- (import: NodeJsError
- (code host.String))
-
(import: FileDescriptor)
(import: Stats
@@ -439,35 +436,35 @@
(..can-query
(function (size _)
(|> (Fs::statSync [path] (!fs))
- (:: error.monad map (|>> Stats::size frac-to-nat))
+ (:: try.monad map (|>> Stats::size frac-to-nat))
io.io))))
(def: last-modified
(..can-query
(function (last-modified _)
(|> (Fs::statSync [path] (!fs))
- (:: error.monad map (|>> Stats::mtimeMs
- frac-to-int
- duration.from-millis
- instant.absolute))
+ (:: try.monad map (|>> Stats::mtimeMs
+ frac-to-int
+ duration.from-millis
+ instant.absolute))
io.io))))
(def: can-execute?
(..can-query
(function (can-execute? _)
- (io.io (do error.monad
+ (io.io (do try.monad
[_ (Fs::accessSync [path (|> (!fs) Fs::constants FsConstants::F_OK)] (!fs))]
(wrap (case (Fs::accessSync [path (|> (!fs) Fs::constants FsConstants::X_OK)] (!fs))
- (#error.Success _)
+ (#try.Success _)
true
- (#error.Failure _)
+ (#try.Failure _)
false)))))))
(def: move
(..can-open
(function (move destination)
- (io.io (do error.monad
+ (io.io (do try.monad
[_ (Fs::renameSync [path destination] (!fs))]
(wrap (file destination)))))))
@@ -490,7 +487,7 @@
(..can-query
(function (<name> _)
(io.io (let [fs (!fs)]
- (do error.monad
+ (do try.monad
[subs (Fs::readdirSync [path] fs)
subs (monad.map @ (function (_ sub)
(do @
@@ -516,7 +513,7 @@
[(def: <name>
(..can-open
(function (<name> path)
- (io.io (do error.monad
+ (io.io (do try.monad
[stats (Fs::statSync [path] (!fs))
verdict (<method> [] stats)]
(if verdict
@@ -533,11 +530,11 @@
(function (<name> path)
(io.io (let [fs (!fs)]
(case (Fs::accessSync [path (|> (!fs) Fs::constants FsConstants::F_OK)] fs)
- (#error.Success _)
+ (#try.Success _)
(exception.throw <exception> [path])
- (#error.Failure _)
- (do error.monad
+ (#try.Failure _)
+ (do try.monad
[_ (|> fs <prep>)]
(wrap (<capability> path)))))))))]
@@ -557,17 +554,17 @@
(template [<get> <signature> <create> <find> <exception>]
[(def: #export (<get> monad system path)
- (All [!] (-> (Monad !) (System !) Path (! (Error (<signature> !)))))
+ (All [!] (-> (Monad !) (System !) Path (! (Try (<signature> !)))))
(do monad
[outcome (!.use (:: system <create>) path)]
(case outcome
- (#error.Success file)
- (wrap (#error.Success file))
+ (#try.Success file)
+ (wrap (#try.Success file))
- (#error.Failure error)
+ (#try.Failure error)
(if (exception.match? <exception> error)
(!.use (:: system <find>) path)
- (wrap (#error.Failure error))))))]
+ (wrap (#try.Failure error))))))]
[get-file File create-file file ..cannot-create-file]
[get-directory Directory create-directory directory ..cannot-create-directory]
@@ -578,15 +575,15 @@
(do monad
[?file (!.use (:: system file) path)]
(case ?file
- (#error.Success file)
+ (#try.Success file)
(wrap true)
- (#error.Failure _)
+ (#try.Failure _)
(do monad
[?directory (!.use (:: system directory) path)]
(case ?directory
- (#error.Success directory)
+ (#try.Success directory)
(wrap true)
- (#error.Failure _)
+ (#try.Failure _)
(wrap false))))))
diff --git a/stdlib/source/lux/world/net.lux b/stdlib/source/lux/world/net.lux
index ff753f527..ca46b72ba 100644
--- a/stdlib/source/lux/world/net.lux
+++ b/stdlib/source/lux/world/net.lux
@@ -1,8 +1,7 @@
(.module:
[lux #*
- [data
- [error (#+ Error)]]
[control
+ [try (#+ Try)]
[security
["!" capability (#+ capability:)]]]])
@@ -17,10 +16,10 @@
#port Port})
(capability: #export (Can-Read ! o)
- (can-read Nat (! (Error o))))
+ (can-read Nat (! (Try o))))
(capability: #export (Can-Write ! i)
- (can-write i (! (Error Any))))
+ (can-write i (! (Try Any))))
(capability: #export (Can-Close !)
- (can-close [] (! (Error Any))))
+ (can-close [] (! (Try Any))))
diff --git a/stdlib/source/lux/world/net/http.lux b/stdlib/source/lux/world/net/http.lux
index d3bbf5a37..67acbde6b 100644
--- a/stdlib/source/lux/world/net/http.lux
+++ b/stdlib/source/lux/world/net/http.lux
@@ -1,11 +1,11 @@
(.module:
[lux #*
[control
+ [try (#+ Try)]
[concurrency
[promise (#+ Promise)]
[frp (#+ Channel)]]]
[data
- [error (#+ Error)]
[format
[context (#+ Context)]]]
[world
@@ -75,4 +75,4 @@
(-> Request (Promise Response)))
(type: #export Client
- (-> [Method URL Context Data] (Promise (Error Response))))
+ (-> [Method URL Context Data] (Promise (Try Response))))
diff --git a/stdlib/source/lux/world/net/http/cookie.lux b/stdlib/source/lux/world/net/http/cookie.lux
index 73f73ffff..aac87c822 100644
--- a/stdlib/source/lux/world/net/http/cookie.lux
+++ b/stdlib/source/lux/world/net/http/cookie.lux
@@ -2,10 +2,10 @@
[lux #*
[control
[monad (#+ do)]
+ ["." try (#+ Try)]
["p" parser ("#;." monad)
["l" text (#+ Parser)]]]
[data
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]
[format
@@ -81,5 +81,5 @@
(p;wrap context)))
(def: #export (get header)
- (-> Text (Error Context))
+ (-> Text (Try Context))
(l.run header (..cookies context.empty)))
diff --git a/stdlib/source/lux/world/net/http/query.lux b/stdlib/source/lux/world/net/http/query.lux
index a0854d1e9..e5793021a 100644
--- a/stdlib/source/lux/world/net/http/query.lux
+++ b/stdlib/source/lux/world/net/http/query.lux
@@ -3,10 +3,10 @@
[control
pipe
[monad (#+ do)]
+ ["." try (#+ Try)]
["p" parser
["l" text (#+ Parser)]]]
[data
- ["." error (#+ Error)]
[number
["." nat]]
["." text
@@ -60,5 +60,5 @@
(:: p.monad wrap context)))
(def: #export (parameters raw)
- (-> Text (Error Context))
+ (-> Text (Try Context))
(l.run raw (..form context.empty)))
diff --git a/stdlib/source/lux/world/net/http/request.lux b/stdlib/source/lux/world/net/http/request.lux
index 15f3f33e3..67dfeec6c 100644
--- a/stdlib/source/lux/world/net/http/request.lux
+++ b/stdlib/source/lux/world/net/http/request.lux
@@ -3,6 +3,7 @@
[control
pipe
["." monad (#+ do)]
+ ["." try (#+ Try)]
[concurrency
["." promise (#+ Promise)]
["." frp]]
@@ -10,7 +11,6 @@
["<.>" json]]]
[data
["." maybe]
- ["." error (#+ Error)]
["." number]
["." text
["." encoding]]
@@ -29,11 +29,11 @@
(def: (merge inputs)
(-> (List Binary) Binary)
- (let [[_ output] (error.assume
- (monad.fold error.monad
+ (let [[_ output] (try.assume
+ (monad.fold try.monad
(function (_ input [offset output])
(let [amount (binary.size input)]
- (:: error.functor map (|>> [(n/+ amount offset)])
+ (:: try.functor map (|>> [(n/+ amount offset)])
(binary.copy amount 0 input offset output))))
[0 (|> inputs
(list;map binary.size)
@@ -43,7 +43,7 @@
output))
(def: (read-text-body body)
- (-> Body (Promise (Error Text)))
+ (-> Body (Promise (Try Text)))
(do promise.monad
[blobs (frp.consume body)]
(wrap (encoding.from-utf8 (merge blobs)))))
@@ -55,14 +55,14 @@
(function (_ (^@ request [identification protocol resource message]))
(do promise.monad
[?raw (read-text-body (get@ #//.body message))]
- (case (do error.monad
+ (case (do try.monad
[raw ?raw
content (:: json.codec decode raw)]
(json.run content reader))
- (#error.Success input)
+ (#try.Success input)
(server input request)
- (#error.Failure error)
+ (#try.Failure error)
(promise.resolved ..failure)))))
(def: #export (text server)
@@ -71,10 +71,10 @@
(do promise.monad
[?raw (read-text-body (get@ #//.body message))]
(case ?raw
- (#error.Success content)
+ (#try.Success content)
(server content request)
- (#error.Failure error)
+ (#try.Failure error)
(promise.resolved ..failure)))))
(def: #export (query property server)
@@ -84,15 +84,15 @@
[uri query] (|> full
(text.split-with "?")
(maybe.default [full ""]))]
- (case (do error.monad
+ (case (do try.monad
[query (//query.parameters query)
input (context.run query property)]
(wrap [[identification protocol (set@ #//.uri uri resource) message]
input]))
- (#error.Success [request input])
+ (#try.Success [request input])
(server input request)
- (#error.Failure error)
+ (#try.Failure error)
(promise.resolved ..failure)))))
(def: #export (form property server)
@@ -100,27 +100,27 @@
(function (_ (^@ request [identification protocol resource message]))
(do promise.monad
[?body (read-text-body (get@ #//.body message))]
- (case (do error.monad
+ (case (do try.monad
[body ?body
form (//query.parameters body)]
(context.run form property))
- (#error.Success input)
+ (#try.Success input)
(server input request)
- (#error.Failure error)
+ (#try.Failure error)
(promise.resolved ..failure)))))
(def: #export (cookies property server)
(All [a] (-> (Property a) (-> a Server) Server))
(function (_ (^@ request [identification protocol resource message]))
- (case (do error.monad
+ (case (do try.monad
[cookies (|> (get@ #//.headers message)
(dictionary.get "Cookie")
(maybe.default "")
//cookie.get)]
(context.run cookies property))
- (#error.Success input)
+ (#try.Success input)
(server input request)
- (#error.Failure error)
+ (#try.Failure error)
(promise.resolved ..failure))))
diff --git a/stdlib/source/lux/world/service/authentication.lux b/stdlib/source/lux/world/service/authentication.lux
index 2cd35f7dd..a9acda426 100644
--- a/stdlib/source/lux/world/service/authentication.lux
+++ b/stdlib/source/lux/world/service/authentication.lux
@@ -1,22 +1,21 @@
(.module:
[lux #*
[control
+ [try (#+ Try)]
[security
- [capability (#+ Capability)]]]
- [data
- [error (#+ Error)]]])
+ [capability (#+ Capability)]]]])
(type: #export (Can-Register ! account secret value)
- (Capability [account secret value] (! (Error Any))))
+ (Capability [account secret value] (! (Try Any))))
(type: #export (Can-Authenticate ! account secret value)
- (Capability [account secret] (! (Error value))))
+ (Capability [account secret] (! (Try value))))
(type: #export (Can-Reset ! account secret)
- (Capability [account secret] (! (Error Any))))
+ (Capability [account secret] (! (Try Any))))
(type: #export (Can-Forget ! account)
- (Capability [account] (! (Error Any))))
+ (Capability [account] (! (Try Any))))
(type: #export (Service ! account secret value)
{#can-register (Can-Register ! account secret value)
diff --git a/stdlib/source/lux/world/service/crud.lux b/stdlib/source/lux/world/service/crud.lux
index 8e1e99277..82fee2c75 100644
--- a/stdlib/source/lux/world/service/crud.lux
+++ b/stdlib/source/lux/world/service/crud.lux
@@ -1,10 +1,9 @@
(.module:
[lux #*
[control
+ ["." try (#+ Try)]
[security
["!" capability (#+ capability:)]]]
- [data
- ["." error (#+ Error)]]
[time
["." instant (#+ Instant)]]])
@@ -15,16 +14,16 @@
#updated Instant})
(capability: #export (Can-Create ! entity)
- (can-create [Instant entity] (! (Error ID))))
+ (can-create [Instant entity] (! (Try ID))))
(capability: #export (Can-Retrieve ! entity)
- (can-retrieve ID (! (Error [Time entity]))))
+ (can-retrieve ID (! (Try [Time entity]))))
(capability: #export (Can-Update ! entity)
- (can-update [ID Instant entity] (! (Error Any))))
+ (can-update [ID Instant entity] (! (Try Any))))
(capability: #export (Can-Delete ! entity)
- (can-delete ID (! (Error Any))))
+ (can-delete ID (! (Try Any))))
(type: #export (CRUD ! entity)
{#can-create (Can-Create ! entity)
diff --git a/stdlib/source/lux/world/service/inventory.lux b/stdlib/source/lux/world/service/inventory.lux
index 0e3fae6be..dbdc93d6d 100644
--- a/stdlib/source/lux/world/service/inventory.lux
+++ b/stdlib/source/lux/world/service/inventory.lux
@@ -1,10 +1,9 @@
(.module:
[lux #*
[control
+ [try (#+ Try)]
[security
- ["!" capability (#+ capability:)]]]
- [data
- [error (#+ Error)]]])
+ ["!" capability (#+ capability:)]]]])
(type: #export ID Nat)
@@ -13,16 +12,16 @@
#property ID})
(capability: #export (Can-Own !)
- (can-own Ownership (! (Error Any))))
+ (can-own Ownership (! (Try Any))))
(capability: #export (Can-Disown !)
- (can-disown Ownership (! (Error Any))))
+ (can-disown Ownership (! (Try Any))))
(capability: #export (Can-Check !)
- (can-check Ownership (! (Error Bit))))
+ (can-check Ownership (! (Try Bit))))
(capability: #export (Can-List-Property !)
- (can-list-property ID (! (Error (List ID)))))
+ (can-list-property ID (! (Try (List ID)))))
(type: #export (Inventory !)
{#can-own (Can-Own !)
diff --git a/stdlib/source/lux/world/service/journal.lux b/stdlib/source/lux/world/service/journal.lux
index 4a3c7b62f..f4476a37f 100644
--- a/stdlib/source/lux/world/service/journal.lux
+++ b/stdlib/source/lux/world/service/journal.lux
@@ -3,10 +3,10 @@
[control
[equivalence (#+ Equivalence)]
[interval (#+ Interval)]
+ [try (#+ Try)]
[security
["!" capability (#+ capability:)]]]
[data
- [error (#+ Error)]
["." text ("#@." equivalence)]]
[time
["." instant (#+ Instant) ("#@." equivalence)]]])
@@ -40,10 +40,10 @@
(instant@= (get@ #when reference) (get@ #when sample)))))
(capability: #export (Can-Write ! a)
- (can-write (Entry a) (! (Error Any))))
+ (can-write (Entry a) (! (Try Any))))
(capability: #export (Can-Read ! a)
- (can-read Range (! (Error (List (Entry a))))))
+ (can-read Range (! (Try (List (Entry a))))))
(type: #export (Journal ! a)
{#can-write (Can-Write ! a)
diff --git a/stdlib/source/lux/world/service/mail.lux b/stdlib/source/lux/world/service/mail.lux
index ce5eb91b3..eb49c6131 100644
--- a/stdlib/source/lux/world/service/mail.lux
+++ b/stdlib/source/lux/world/service/mail.lux
@@ -1,18 +1,17 @@
(.module:
[lux #*
[control
+ [try (#+ Try)]
[concurrency
[frp (#+ Channel)]]
[security
- ["!" capability (#+ capability:)]]]
- [data
- [error (#+ Error)]]])
+ ["!" capability (#+ capability:)]]]])
(capability: #export (Can-Send ! address message)
- (can-send [address message] (! (Error Any))))
+ (can-send [address message] (! (Try Any))))
(capability: #export (Can-Subscribe ! address message)
- (can-subscribe [address] (! (Error (Channel message)))))
+ (can-subscribe [address] (! (Try (Channel message)))))
(type: #export (Service ! address message)
{#can-send (Can-Send ! address message)
diff --git a/stdlib/source/lux/world/shell.lux b/stdlib/source/lux/world/shell.lux
index 7668efb0d..f62654091 100644
--- a/stdlib/source/lux/world/shell.lux
+++ b/stdlib/source/lux/world/shell.lux
@@ -3,12 +3,12 @@
["." io (#+ IO)]
["jvm" host (#+ import:)]
[control
- [monad (#+ do)]]
+ [monad (#+ do)]
+ ["." try (#+ Try)]]
[data
[number (#+ hex)]
["." product]
["." maybe]
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]
["." encoding]]
@@ -104,8 +104,8 @@
(destroy [] #io #try void))
(def: (process-console process)
- (-> java/lang/Process (IO (Error (Console IO))))
- (do (error.with io.monad)
+ (-> java/lang/Process (IO (Try (Console IO))))
+ (do (try.with io.monad)
[jvm-input (java/lang/Process::getInputStream process)
#let [jvm-input (|> jvm-input
java/io/InputStreamReader::new
@@ -118,7 +118,7 @@
(function (_ _)
(|> jvm-input
java/io/Reader::read
- (:: (error.with io.monad) map .nat)))))
+ (:: (try.with io.monad) map .nat)))))
(def: can-read-line
(console.can-read
@@ -148,9 +148,9 @@
)}))
(def: #export (execute environment command arguments)
- (-> Context Text (List Text) (IO (Error (Console IO))))
+ (-> Context Text (List Text) (IO (Try (Console IO))))
(`` (for {(~~ (static host.old))
- (do (error.with io.monad)
+ (do (try.with io.monad)
[windows? (:: @ map (|>> java/lang/String::toLowerCase ..windows?)
(java/lang/System::getProperty "os.name"))
#let [builder (java/lang/ProcessBuilder::new (arguments-array (list& (sanitize-command windows? command)
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index ef11ab060..2a6f9bfd4 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -5,13 +5,13 @@
[monad (#+ do)]]
[control
["." io (#+ IO io)]
+ ["." try (#+ Try)]
[parser
[cli (#+ program:)]]
[security
["!" capability]]]
[data
["." product]
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[collection
@@ -44,24 +44,24 @@
(def: (or-crash! failure-description action)
(All [a]
- (-> Text (IO (Error a)) (IO a)))
+ (-> Text (IO (Try a)) (IO a)))
(do io.monad
[?output action]
(case ?output
- (#error.Failure error)
+ (#try.Failure error)
(exec (log! (format text.new-line
failure-description text.new-line
error text.new-line))
(io.exit +1))
- (#error.Success output)
+ (#try.Success output)
(wrap output))))
(def: (save-artifacts! system state)
(All [anchor expression statement]
(-> (file.System IO)
(statement.State+ anchor expression statement)
- (IO (Error Any))))
+ (IO (Try Any))))
(let [?outcome (phase.run' state
(:share [anchor expression statement]
{(statement.State+ anchor expression statement)
@@ -70,14 +70,14 @@
(generation.Output statement))
(statement.lift-generation generation.output)}))]
(case ?outcome
- (#error.Success [state output])
- (do (error.with io.monad)
- [file (: (IO (Error (File IO)))
+ (#try.Success [state output])
+ (do (try.with io.monad)
+ [file (: (IO (Try (File IO)))
(file.get-file io.monad system "program.js"))]
(!.use (:: file over-write) (script.package output)))
- (#error.Failure error)
- (:: io.monad wrap (#error.Failure error)))))
+ (#try.Failure error)
+ (:: io.monad wrap (#try.Failure error)))))
(def: #export (compiler target partial-host-extension expander host-analysis platform generation-bundle host-statement-bundle program service)
(All [anchor expression statement]
@@ -93,20 +93,20 @@
(IO Any)))
(do io.monad
[platform platform
- console (:: @ map error.assume console.system)]
+ console (:: @ map try.assume console.system)]
(case service
(#cli.Compilation configuration)
(<| (or-crash! "Compilation failed:")
- (do (error.with io.monad)
+ (do (try.with io.monad)
[state (:share [anchor expression statement]
{(Platform IO anchor expression statement)
platform}
- {(IO (Error (statement.State+ anchor expression statement)))
+ {(IO (Try (statement.State+ anchor expression statement)))
(platform.initialize target expander host-analysis platform generation-bundle host-statement-bundle program)})
[archive state] (:share [anchor expression statement]
{(Platform IO anchor expression statement)
platform}
- {(IO (Error [Archive (statement.State+ anchor expression statement)]))
+ {(IO (Try [Archive (statement.State+ anchor expression statement)]))
(platform.compile partial-host-extension expander platform configuration archive.empty state)})
_ (save-artifacts! (get@ #platform.&file-system platform) state)
## _ (cache/io.clean target ...)
@@ -117,5 +117,5 @@
## TODO: Fix the interpreter...
(undefined)
## (<| (or-crash! "Interpretation failed:")
- ## (interpreter.run (error.with io.monad) console platform configuration generation-bundle))
+ ## (interpreter.run (try.with io.monad) console platform configuration generation-bundle))
)))
diff --git a/stdlib/source/program/licentia.lux b/stdlib/source/program/licentia.lux
index 7f19a829c..5021eb5bb 100644
--- a/stdlib/source/program/licentia.lux
+++ b/stdlib/source/program/licentia.lux
@@ -17,12 +17,12 @@
[monad (#+ do)]]
[control
[remember (#+ to-do)]
+ ["." try (#+ Try)]
["." parser]
[security
["!" capability]]]
[data
["." maybe]
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]
["." encoding]]
@@ -55,11 +55,11 @@
{output (parser.default ..default-output-file
(cli.named "--output" cli.any))}]
(do io.monad
- [?done (: (IO (Error Any))
- (do (error.with io.monad)
+ [?done (: (IO (Try Any))
+ (do (try.with io.monad)
[file (!.use (:: file.system file) input)
blob (!.use (:: file content) [])
- document (io;wrap (do error.monad
+ document (io;wrap (do try.monad
[raw-json (encoding.from-utf8 blob)
json (|> raw-json
(:coerce java/lang/String)
@@ -67,12 +67,12 @@
(:: json.codec decode))
license (json.run json /input.license)]
(wrap (/output.license license))))
- output-file (: (IO (Error (File IO)))
+ output-file (: (IO (Try (File IO)))
(file.get-file io.monad file.system output))]
(!.use (:: output-file over-write) (encoding.to-utf8 document))))]
(case ?done
- (#error.Success _)
+ (#try.Success _)
(wrap (log! (success-message output)))
- (#error.Failure message)
+ (#try.Failure message)
(wrap (log! message)))))
diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux
index 569371900..3775fd006 100644
--- a/stdlib/source/program/scriptum.lux
+++ b/stdlib/source/program/scriptum.lux
@@ -4,6 +4,7 @@
["." monad (#+ do)]]
[control
[pipe (#+ when>)]
+ ["." try (#+ Try)]
["ex" exception (#+ exception:)]
[security
["!" capability]]]
@@ -11,7 +12,6 @@
[data
["." maybe]
["." product]
- ["." error (#+ Error)]
[format
["md" markdown (#+ Markdown Span Block)]]
["." text ("#;." equivalence)
@@ -484,15 +484,15 @@
(-> [Text (Markdown Block)] (IO Any))
(let [path (format (text.replace-all "/" "_" module-name) ".md")]
(do io.monad
- [outcome (do (error.with io.monad)
- [target (: (IO (Error (File IO)))
+ [outcome (do (try.with io.monad)
+ [target (: (IO (Try (File IO)))
(file.get-file io.monad file.system path))]
(!.use (:: target over-write) (encoding.to-utf8 (md.markdown documentation))))]
(case outcome
- (#error.Failure error)
+ (#try.Failure error)
(wrap (log! (ex.construct io-error error)))
- (#error.Success _)
+ (#try.Success _)
(wrap [])))))
(macro: (gen-documentation! _)
diff --git a/stdlib/source/spec/compositor.lux b/stdlib/source/spec/compositor.lux
index 75818c3cf..903097950 100644
--- a/stdlib/source/spec/compositor.lux
+++ b/stdlib/source/spec/compositor.lux
@@ -4,9 +4,8 @@
[abstract
[monad (#+ do)]]
[control
- ["." io (#+ IO)]]
- [data
- ["." error]]
+ ["." io (#+ IO)]
+ ["." try]]
[math
["r" random]]
[tool
@@ -59,10 +58,10 @@
expander
program))]]
(case ?state,runner,definer
- (#error.Success [[statement-bundle statement-state] runner definer])
+ (#try.Success [[statement-bundle statement-state] runner definer])
(..test runner definer
(get@ [#statement.analysis #statement.state] statement-state)
expander)
- (#error.Failure error)
+ (#try.Failure error)
(_.fail error))))
diff --git a/stdlib/source/spec/compositor/analysis/type.lux b/stdlib/source/spec/compositor/analysis/type.lux
index a6105bbde..b2daee77a 100644
--- a/stdlib/source/spec/compositor/analysis/type.lux
+++ b/stdlib/source/spec/compositor/analysis/type.lux
@@ -6,9 +6,9 @@
[monad (#+ do)]]
[control
[pipe (#+ case>)]
- ["." io]]
+ ["." io]
+ ["." try]]
[data
- ["." error]
["." bit ("#@." equivalence)]
["." text ("#@." equivalence)]]
[math
@@ -30,10 +30,10 @@
(analysis/type.with-type output-type
(analysis.phase expander (` ((~ (code.text extension)) (~+ params))))))
(phase.run state)
- (case> (#error.Success _)
+ (case> (#try.Success _)
true
- (#error.Failure error)
+ (#try.Failure _)
false)))
(def: check
diff --git a/stdlib/source/spec/compositor/common.lux b/stdlib/source/spec/compositor/common.lux
index df332df57..7b1c940fb 100644
--- a/stdlib/source/spec/compositor/common.lux
+++ b/stdlib/source/spec/compositor/common.lux
@@ -3,9 +3,8 @@
[abstract
[monad (#+ do)]]
[control
- ["." io (#+ IO)]]
- [data
- ["." error (#+ Error)]]
+ ["." io (#+ IO)]
+ ["." try (#+ Try)]]
[tool
[compiler
["." reference]
@@ -19,8 +18,8 @@
[default
["." platform (#+ Platform)]]]]])
-(type: #export Runner (-> Text Synthesis (Error Any)))
-(type: #export Definer (-> Name Synthesis (Error Any)))
+(type: #export Runner (-> Text Synthesis (Try Any)))
+(type: #export Definer (-> Name Synthesis (Try Any)))
(type: #export (Instancer what)
(All [anchor expression statement]
@@ -31,7 +30,7 @@
(def: (runner (^slots [#platform.runtime #platform.phase #platform.host]) state)
(Instancer Runner)
(function (_ evaluation-name expressionS)
- (do error.monad
+ (do try.monad
[expressionG (<| (phase.run state)
generation.with-buffer
(do phase.monad
@@ -43,7 +42,7 @@
state)
(Instancer Definer)
(function (_ lux-name expressionS)
- (do error.monad
+ (do try.monad
[definitionG (<| (phase.run state)
generation.with-buffer
(do phase.monad
@@ -60,12 +59,12 @@
(Bundle anchor expression statement)
Expander
(-> expression statement)
- (IO (Error [(statement.State+ anchor expression statement)
- Runner
- Definer]))))
+ (IO (Try [(statement.State+ anchor expression statement)
+ Runner
+ Definer]))))
(do io.monad
[?state (platform.initialize expander platform bundle program)]
- (wrap (do error.monad
+ (wrap (do try.monad
[[statement-bundle statement-state] ?state
#let [generation-state (get@ [#statement.generation
#statement.state]
diff --git a/stdlib/source/spec/compositor/generation/case.lux b/stdlib/source/spec/compositor/generation/case.lux
index 5b1187210..43069bcb4 100644
--- a/stdlib/source/spec/compositor/generation/case.lux
+++ b/stdlib/source/spec/compositor/generation/case.lux
@@ -4,9 +4,9 @@
[abstract
[monad (#+ do)]]
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." text ("#@." equivalence)
["%" format (#+ format)]]
[collection
@@ -36,11 +36,11 @@
(n/= (dec size) idx))
(def: #export (verify expected)
- (-> Frac (Error Any) Bit)
- (|>> (case> (#error.Success actual)
+ (-> Frac (Try Any) Bit)
+ (|>> (case> (#try.Success actual)
(f/= expected (:coerce Frac actual))
- (#error.Failure error)
+ (#try.Failure _)
false)))
(def: case
@@ -228,7 +228,7 @@
(def: special-pattern-path
Path
($_ synthesis.path/alt
- (<| error.assume
+ (<| try.assume
(phase.run [extension/synthesis.bundle
synthesis.init])
(case.path phase/synthesis.phase
@@ -250,28 +250,28 @@
(_.test "CODE"
(|> special-input
(run "special-input")
- (case> (#error.Success output)
+ (case> (#try.Success output)
true
- (#error.Failure error)
+ (#try.Failure _)
false)))
(_.test "PATTERN-MATCHING 0"
(|> (synthesis.branch/case [special-input
special-path])
(run "special-path")
- (case> (#error.Success output)
+ (case> (#try.Success output)
true
- (#error.Failure error)
+ (#try.Failure _)
false)))
(_.test "PATTERN-MATCHING 1"
(|> (synthesis.branch/case [special-input
special-pattern-path])
(run "special-pattern-path")
- (case> (#error.Success output)
+ (case> (#try.Success output)
true
- (#error.Failure error)
+ (#try.Failure _)
false)))
))
diff --git a/stdlib/source/spec/compositor/generation/common.lux b/stdlib/source/spec/compositor/generation/common.lux
index a4037c9d4..f10f2a2ef 100644
--- a/stdlib/source/spec/compositor/generation/common.lux
+++ b/stdlib/source/spec/compositor/generation/common.lux
@@ -4,9 +4,9 @@
[abstract
[monad (#+ do)]]
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." bit ("#@." equivalence)]
[number
["." i64]]
@@ -39,10 +39,10 @@
(|> (#synthesis.Extension <extension> (list (synthesis.i64 param)
(synthesis.i64 subject)))
(run (..sanitize <extension>))
- (case> (#error.Success valueT)
+ (case> (#try.Success valueT)
(n/= (<reference> param subject) (:coerce Nat valueT))
- (#error.Failure error)
+ (#try.Failure _)
false)
(let [param <param-expr>])))]
@@ -59,12 +59,12 @@
(list (synthesis.i64 subject)
(synthesis.i64 param)))
(run (..sanitize "lux i64 arithmetic-right-shift"))
- (case> (#error.Success valueT)
+ (case> (#try.Success valueT)
("lux i64 ="
(i64.arithmetic-right-shift param subject)
(:coerce I64 valueT))
- (#error.Failure error)
+ (#try.Failure _)
false)
(let [param (n/% 64 param)])))
))))
@@ -79,10 +79,10 @@
[(_.test <extension>
(|> (#synthesis.Extension <extension> (list (synthesis.i64 subject)))
(run (..sanitize <extension>))
- (case> (#error.Success valueT)
+ (case> (#try.Success valueT)
(<comp> (<prepare> subject) (:coerce <type> valueT))
- (#error.Failure error)
+ (#try.Failure _)
false)
(let [subject <subject-expr>])))]
@@ -97,10 +97,10 @@
(|> (#synthesis.Extension <extension> (list (synthesis.i64 param)
(synthesis.i64 subject)))
(run (..sanitize <extension>))
- (case> (#error.Success valueT)
+ (case> (#try.Success valueT)
(<comp> (<reference> param subject) (:coerce <outputT> valueT))
- (#error.Failure error)
+ (#try.Failure _)
false)))]
["lux i64 +" i/+ Int i/=]
@@ -141,7 +141,7 @@
(|> (#synthesis.Extension <extension> (list (synthesis.f64 param)
(synthesis.f64 subject)))
(run (..sanitize <extension>))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(bit@= (<text> param subject)
(:coerce Bit valueV))
@@ -190,14 +190,14 @@
(_.test "Can compare texts for equality."
(and (|> (#synthesis.Extension "lux text =" (list sample-lowerS sample-lowerS))
(run (..sanitize "lux text ="))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(:coerce Bit valueV)
_
false))
(|> (#synthesis.Extension "lux text =" (list sample-upperS sample-lowerS))
(run (..sanitize "lux text ="))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(not (:coerce Bit valueV))
_
@@ -205,15 +205,15 @@
(_.test "Can compare texts for order."
(|> (#synthesis.Extension "lux text <" (list sample-lowerS sample-upperS))
(run (..sanitize "lux text <"))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(:coerce Bit valueV)
- (#error.Failure error)
+ (#try.Failure _)
false)))
(_.test "Can get length of text."
(|> (#synthesis.Extension "lux text size" (list sample-lowerS))
(run (..sanitize "lux text size"))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(n/= sample-size (:coerce Nat valueV))
_
@@ -221,7 +221,7 @@
(_.test "Can concatenate text."
(|> (#synthesis.Extension "lux text size" (list concatenatedS))
(run (..sanitize "lux text size"))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(n/= (n/* 2 sample-size) (:coerce Nat valueV))
_
@@ -231,7 +231,7 @@
(list concatenatedS sample-lowerS
(synthesis.i64 +0)))
(run (..sanitize "lux text index"))
- (case> (^multi (#error.Success valueV)
+ (case> (^multi (#try.Success valueV)
[(:coerce (Maybe Nat) valueV) (#.Some valueV)])
(n/= 0 valueV)
@@ -241,7 +241,7 @@
(list concatenatedS sample-upperS
(synthesis.i64 +0)))
(run (..sanitize "lux text index"))
- (case> (^multi (#error.Success valueV)
+ (case> (^multi (#try.Success valueV)
[(:coerce (Maybe Nat) valueV) (#.Some valueV)])
(n/= sample-size valueV)
@@ -254,7 +254,7 @@
(synthesis.i64 from)
(synthesis.i64 to)))
(run (..sanitize "lux text clip"))
- (case> (^multi (#error.Success valueV)
+ (case> (^multi (#try.Success valueV)
[(:coerce (Maybe Text) valueV) (#.Some valueV)])
(text@= expected valueV)
@@ -268,7 +268,7 @@
(list sample-lowerS
(synthesis.i64 char-idx)))
(run (..sanitize "lux text char"))
- (case> (^multi (#error.Success valueV)
+ (case> (^multi (#try.Success valueV)
[(:coerce (Maybe Int) valueV) (#.Some valueV)])
(text.contains? ("lux i64 char" valueV)
sample-lower)
@@ -286,10 +286,10 @@
(|> (#synthesis.Extension "lux io log"
(list (synthesis.text (format "LOG: " message))))
(run (..sanitize "lux io log"))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
true
- (#error.Failure error)
+ (#try.Failure _)
false)))
(_.test "Can throw runtime errors."
(and (|> (#synthesis.Extension "lux try"
@@ -299,8 +299,8 @@
#synthesis.body (#synthesis.Extension "lux io error"
(list (synthesis.text message)))})))
(run (..sanitize "lux try"))
- (case> (^multi (#error.Success valueV)
- [(:coerce (Error Text) valueV) (#error.Failure error)])
+ (case> (^multi (#try.Success valueV)
+ [(:coerce (Try Text) valueV) (#try.Failure error)])
(text.contains? message error)
_
@@ -311,8 +311,8 @@
#synthesis.arity 1
#synthesis.body (synthesis.text message)})))
(run (..sanitize "lux try"))
- (case> (^multi (#error.Success valueV)
- [(:coerce (Error Text) valueV) (#error.Success valueV)])
+ (case> (^multi (#try.Success valueV)
+ [(:coerce (Try Text) valueV) (#try.Success valueV)])
(text@= message valueV)
_
@@ -321,11 +321,11 @@
(|> (synthesis.tuple (list (#synthesis.Extension "lux io current-time" (list))
(#synthesis.Extension "lux io current-time" (list))))
(run (..sanitize "lux io current-time"))
- (case> (#error.Success valueV)
+ (case> (#try.Success valueV)
(let [[pre post] (:coerce [Nat Nat] valueV)]
(n/>= pre post))
- (#error.Failure error)
+ (#try.Failure _)
false)))
)))
diff --git a/stdlib/source/spec/compositor/generation/function.lux b/stdlib/source/spec/compositor/generation/function.lux
index 0f12906a0..0b8810620 100644
--- a/stdlib/source/spec/compositor/generation/function.lux
+++ b/stdlib/source/spec/compositor/generation/function.lux
@@ -7,7 +7,6 @@
[pipe (#+ case>)]]
[data
["." maybe]
- ["." error (#+ Error)]
[collection
["." list ("#@." functor)]]]
[math
diff --git a/stdlib/source/spec/compositor/generation/primitive.lux b/stdlib/source/spec/compositor/generation/primitive.lux
index 48ff99933..e3068a50a 100644
--- a/stdlib/source/spec/compositor/generation/primitive.lux
+++ b/stdlib/source/spec/compositor/generation/primitive.lux
@@ -4,9 +4,9 @@
[abstract
[monad (#+ do)]]
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." try]]
[data
- ["." error]
["." bit ("#@." equivalence)]
[number
["." frac]]
@@ -34,10 +34,10 @@
[expected <gen>]
(_.test (%.name (name-of <synthesis>))
(|> (run <evaluation-name> (<synthesis> expected))
- (case> (#error.Success actual)
+ (case> (#try.Success actual)
(<test> expected (:assume actual))
- (#error.Failure error)
+ (#try.Failure _)
false))))]
["bit" synthesis.bit r.bit bit@=]
diff --git a/stdlib/source/spec/compositor/generation/reference.lux b/stdlib/source/spec/compositor/generation/reference.lux
index 066b604dc..eb5e3bf92 100644
--- a/stdlib/source/spec/compositor/generation/reference.lux
+++ b/stdlib/source/spec/compositor/generation/reference.lux
@@ -4,9 +4,8 @@
[abstract
[monad (#+ do)]]
[control
- [pipe (#+ case>)]]
- [data
- ["." error]]
+ [pipe (#+ case>)]
+ ["." try]]
[tool
[compiler
["." reference]
@@ -28,10 +27,10 @@
expected r.safe-frac]
(_.test "Definitions."
(|> (define name (synthesis.f64 expected))
- (case> (#error.Success actual)
+ (case> (#try.Success actual)
(f/= expected (:coerce Frac actual))
- (#error.Failure error)
+ (#try.Failure _)
false)))))
(def: (variable run)
@@ -44,10 +43,10 @@
register
(synthesis.variable/local register)])
(run "variable")
- (case> (#error.Success actual)
+ (case> (#try.Success actual)
(f/= expected (:coerce Frac actual))
- (#error.Failure error)
+ (#try.Failure _)
false)))))
(def: #export (spec runner definer)
diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux
index d22775a43..619f3921f 100644
--- a/stdlib/source/spec/compositor/generation/structure.lux
+++ b/stdlib/source/spec/compositor/generation/structure.lux
@@ -4,9 +4,9 @@
[abstract
[monad (#+ do)]]
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." try]]
[data
- ["." error]
["." maybe]
["." text ("#@." equivalence)
["%" format (#+ format)]]
@@ -39,7 +39,7 @@
#analysis.right? last?-in
#analysis.value (synthesis.i64 value-in)})
(run "variant")
- (case> (#error.Success valueT)
+ (case> (#try.Success valueT)
(let [valueT (:coerce (Array Any) valueT)]
(and (n/= 3 (array.size valueT))
(let [tag-out (:coerce java/lang/Integer (maybe.assume (array.read 0 valueT)))
@@ -57,7 +57,7 @@
same-flag?
same-value?))))
- (#error.Failure error)
+ (#try.Failure _)
false)))))
(def: (tuple run)
@@ -68,14 +68,14 @@
(_.test (%.name (name-of synthesis.tuple))
(|> (synthesis.tuple (list@map (|>> synthesis.i64) tuple-in))
(run "tuple")
- (case> (#error.Success tuple-out)
+ (case> (#try.Success tuple-out)
(let [tuple-out (:coerce (Array Any) tuple-out)]
(and (n/= size (array.size tuple-out))
(list.every? (function (_ [left right])
(i/= left (:coerce Int right)))
(list.zip2 tuple-in (array.to-list tuple-out)))))
- (#error.Failure error)
+ (#try.Failure _)
false)))))
(def: #export (spec runner)
diff --git a/stdlib/source/test/lux/abstract/codec.lux b/stdlib/source/test/lux/abstract/codec.lux
index 99afe290f..b6bbdd91e 100644
--- a/stdlib/source/test/lux/abstract/codec.lux
+++ b/stdlib/source/test/lux/abstract/codec.lux
@@ -2,9 +2,10 @@
[lux #*
["_" test (#+ Test)]
[abstract/monad (#+ do)]
+ [control
+ ["." try]]
[data
- ["%" text/format (#+ format)]
- ["." error]]
+ ["%" text/format (#+ format)]]
[math
["r" random (#+ Random)]]]
{1
@@ -19,8 +20,8 @@
(<| (_.context (%.name (name-of /.Codec)))
(_.test "Isomorphism."
(case (|> expected /@encode /@decode)
- (#error.Success actual)
+ (#try.Success actual)
(/@= expected actual)
- (#error.Failure error)
+ (#try.Failure _)
false)))))
diff --git a/stdlib/source/test/lux/control.lux b/stdlib/source/test/lux/control.lux
index 26fd02ab9..12c906664 100644
--- a/stdlib/source/test/lux/control.lux
+++ b/stdlib/source/test/lux/control.lux
@@ -3,6 +3,7 @@
["_" test (#+ Test)]]
["." / #_
["#." continuation]
+ ["#." try]
["#." exception]
["#." io]
["#." parser]
@@ -52,6 +53,7 @@
Test
($_ _.and
/continuation.test
+ /try.test
/exception.test
/io.test
/parser.test
diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux
index 017ee60ef..cc7456292 100644
--- a/stdlib/source/test/lux/control/concurrency/actor.lux
+++ b/stdlib/source/test/lux/control/concurrency/actor.lux
@@ -3,10 +3,10 @@
["_" test (#+ Test)]
[abstract/monad (#+ do)]
[control
+ ["." try]
["ex" exception]
["." io (#+ IO io)]]
[data
- ["." error]
[text
["%" format (#+ format)]]]
[math
@@ -20,7 +20,7 @@
Nat
((handle message state self)
- (do (error.with promise.monad)
+ (do (try.with promise.monad)
[#let [_ (log! "BEFORE")]
output (message state self)
#let [_ (log! "AFTER")]]
@@ -34,7 +34,7 @@
(message: #export Counter
(count! {increment Nat} state self Nat)
(let [state' (n/+ increment state)]
- (promise;wrap (#error.Success [state' state']))))
+ (promise;wrap (#try.Success [state' state']))))
(def: #export test
Test
@@ -64,7 +64,7 @@
(:: r.monad wrap
(do promise.monad
- [result (do (error.with promise.monad)
+ [result (do (try.with promise.monad)
[#let [counter (io.run (new@Counter 0))]
output-1 (count! 1 counter)
output-2 (count! 1 counter)
@@ -74,9 +74,9 @@
(n/= 3 output-3))))]
(_.assert "Can send messages to actors."
(case result
- (#error.Success outcome)
+ (#try.Success outcome)
outcome
- (#error.Failure error)
+ (#try.Failure _)
#0))))
))))
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index d9ea8865b..fc8de4828 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -10,10 +10,10 @@
["$." apply]
["$." monad]]}]
[control
+ ["." try (#+ Try)]
[parser
["s" code]]]
[data
- ["." error (#+ Error)]
[number
["." nat]]
["." text ("#;." equivalence)
@@ -29,9 +29,9 @@
["." / (#+ Parser)]})
(def: (should-fail expected input)
- (All [a] (-> Text (Error a) Bit))
+ (All [a] (-> Text (Try a) Bit))
(case input
- (#error.Failure actual)
+ (#try.Failure actual)
(text;= expected actual)
_
@@ -40,7 +40,7 @@
(def: (enforced? parser input)
(All [s] (-> (Parser s Any) s Bit))
(case (/.run parser input)
- (#error.Success [_ []])
+ (#try.Success [_ []])
#1
_
@@ -49,16 +49,16 @@
(def: (found? parser input)
(All [s] (-> (Parser s Bit) s Bit))
(case (/.run parser input)
- (#error.Success [_ #1])
+ (#try.Success [_ #1])
#1
_
#0))
(def: (fails? input)
- (All [a] (-> (Error a) Bit))
+ (All [a] (-> (Try a) Bit))
(case input
- (#error.Failure _)
+ (#try.Failure _)
#1
_
@@ -66,7 +66,7 @@
(syntax: (match pattern then input)
(wrap (list (` (case (~ input)
- (^ (#error.Success [(~' _) (~ pattern)]))
+ (^ (#try.Success [(~' _) (~ pattern)]))
(~ then)
(~' _)
@@ -216,7 +216,7 @@
(Comparison (All [a i] (Parser i a)))
(function (_ == left right)
(case [(/.run left []) (/.run right [])]
- [(#error.Success [_ left]) (#error.Success [_ right])]
+ [(#try.Success [_ left]) (#try.Success [_ right])]
(== left right)
_
diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux
index 5c87513d4..b304a2ab2 100644
--- a/stdlib/source/test/lux/control/parser/cli.lux
+++ b/stdlib/source/test/lux/control/parser/cli.lux
@@ -7,9 +7,9 @@
["r" math/random]
[control
pipe
+ ["." try]
["p" parser]]
[data
- ["." error]
[number
["." nat ("#@." decimal)]]
["." text ("#@." equivalence)]
@@ -33,44 +33,44 @@
($_ _.and
(_.test "Can read any argument."
(|> (/.run /.any (list yes))
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
#0
- (#error.Success arg)
+ (#try.Success arg)
(text@= arg yes))))
(_.test "Can test tokens."
(and (|> (/.run (/.this yes) (list yes))
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
#0
- (#error.Success _)
+ (#try.Success _)
#1))
(|> (/.run (/.this yes) (list no))
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
#1
- (#error.Success _)
+ (#try.Success _)
#0))))
(_.test "Can use custom token parsers."
(|> (/.run (/.parse nat@decode) (list yes))
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
#0
- (#error.Success parsed)
+ (#try.Success parsed)
(text@= (nat@encode parsed)
yes))))
(_.test "Can query if there are any more inputs."
(and (|> (/.run /.end (list))
- (case> (#error.Success []) #1 _ #0))
+ (case> (#try.Success []) #1 _ #0))
(|> (/.run (p.not /.end) (list yes))
- (case> (#error.Success []) #0 _ #1))))
+ (case> (#try.Success []) #0 _ #1))))
(_.test "Can parse CLI input anywhere."
(|> (/.run (|> (/.somewhere (/.this yes))
(p.before (p.some /.any)))
(list.concat (list pre-ignore (list yes) post-ignore)))
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
#0
- (#error.Success _)
+ (#try.Success _)
#1)))
))))
diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux
index b263a20b6..8917e63fa 100644
--- a/stdlib/source/test/lux/control/parser/text.lux
+++ b/stdlib/source/test/lux/control/parser/text.lux
@@ -6,9 +6,9 @@
[abstract/monad (#+ do)]
[control
pipe
+ ["." try (#+ Try)]
["p" parser]]
[data
- ["." error (#+ Error)]
["." text ("#@." equivalence)]
[collection
["." list]]]
@@ -18,19 +18,19 @@
["." /]})
(def: (should-fail input)
- (All [a] (-> (Error a) Bit))
+ (All [a] (-> (Try a) Bit))
(case input
- (#error.Failure _)
+ (#try.Failure _)
true
_
false))
(def: (should-pass reference sample)
- (-> Text (Error Text) Bit)
+ (-> Text (Try Text) Bit)
(|> sample
- (:: error.functor map (text@= reference))
- (error.default false)))
+ (:: try.functor map (text@= reference))
+ (try.default false)))
(def: #export test
Test
diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux
index 25ea20ab3..9ecf520c2 100644
--- a/stdlib/source/test/lux/control/region.lux
+++ b/stdlib/source/test/lux/control/region.lux
@@ -3,8 +3,9 @@
["_" test (#+ Test)]
[abstract
["." monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
[text
["%" format (#+ format)]]
[collection
@@ -21,16 +22,16 @@
(template [<name> <success> <error>]
[(def: (<name> result)
- (All [a] (-> (Error a) Bit))
+ (All [a] (-> (Try a) Bit))
(case result
- (#error.Success _)
+ (#try.Success _)
<success>
- (#error.Failure _)
+ (#try.Failure _)
<error>))]
[success? #1 #0]
- [error? #0 #1]
+ [failure? #0 #1]
)
(def: #export test
@@ -47,7 +48,7 @@
count-clean-up (function (_ value)
(do @
[_ (thread.update inc clean-up-counter)]
- (wrap (#error.Success []))))]
+ (wrap (#try.Success []))))]
outcome (/.run @
(do (/.monad @)
[_ (monad.map @ (/.acquire @@ count-clean-up)
@@ -65,7 +66,7 @@
count-clean-up (function (_ value)
(do @
[_ (thread.update inc clean-up-counter)]
- (wrap (#error.Success []))))]
+ (wrap (#try.Success []))))]
outcome (/.run @
(do (/.monad @)
[_ (monad.map @ (/.acquire @@ count-clean-up)
@@ -73,7 +74,7 @@
_ (/.throw @@ oops [])]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
- (wrap (and (error? outcome)
+ (wrap (and (failure? outcome)
(n/= expected-clean-ups
actual-clean-ups))))))
(_.test "Errors can propagate from the cleaners."
@@ -84,7 +85,7 @@
count-clean-up (function (_ value)
(do @
[_ (thread.update inc clean-up-counter)]
- (wrap (: (Error Any) (ex.throw oops [])))))]
+ (wrap (: (Try Any) (ex.throw oops [])))))]
outcome (/.run @
(do (/.monad @)
[_ (monad.map @ (/.acquire @@ count-clean-up)
@@ -92,7 +93,7 @@
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
(wrap (and (or (n/= 0 expected-clean-ups)
- (error? outcome))
+ (failure? outcome))
(n/= expected-clean-ups
actual-clean-ups))))))
(_.test "Can lift operations."
diff --git a/stdlib/source/test/lux/data/error.lux b/stdlib/source/test/lux/control/try.lux
index 340b4b73b..40015c5df 100644
--- a/stdlib/source/test/lux/data/error.lux
+++ b/stdlib/source/test/lux/control/try.lux
@@ -19,19 +19,19 @@
[math
["r" random (#+ Random)]]]
{1
- ["." / (#+ Error)]})
+ ["." / (#+ Try)]})
(def: injection
- (Injection Error)
+ (Injection Try)
(|>> #/.Success))
(def: comparison
- (Comparison Error)
+ (Comparison Try)
(function (_ ==)
(:: (/.equivalence ==) =)))
-(def: #export (error element)
- (All [a] (-> (Random a) (Random (Error a))))
+(def: #export (try element)
+ (All [a] (-> (Random a) (Random (Try a))))
($_ r.or
(r.unicode 1)
element))
@@ -40,7 +40,7 @@
Test
(<| (_.context (%.name (name-of /._)))
($_ _.and
- ($equivalence.spec (/.equivalence nat.equivalence) (..error r.nat))
+ ($equivalence.spec (/.equivalence nat.equivalence) (..try r.nat))
($functor.spec ..injection ..comparison /.functor)
($apply.spec ..injection ..comparison /.apply)
($monad.spec ..injection ..comparison /.monad)
@@ -49,7 +49,7 @@
right r.nat
#let [expected (n/+ left right)
(^open "io@.") io.monad]]
- (_.test "Can add error functionality to any monad."
+ (_.test "Can add try functionality to any monad."
(let [lift (/.lift io.monad)]
(|> (do (/.with io.monad)
[a (lift (io@wrap left))
diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux
index 65d43e5e6..4b0f02903 100644
--- a/stdlib/source/test/lux/data.lux
+++ b/stdlib/source/test/lux/data.lux
@@ -5,7 +5,6 @@
["#." binary]
["#." bit]
["#." color]
- ["#." error]
["#." identity]
["#." lazy]
["#." maybe]
@@ -57,7 +56,6 @@
/binary.test
/bit.test
/color.test
- /error.test
/identity.test
/lazy.test
/maybe.test
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux
index 8fb17114e..4b1ff0c54 100644
--- a/stdlib/source/test/lux/data/binary.lux
+++ b/stdlib/source/test/lux/data/binary.lux
@@ -8,8 +8,9 @@
{[0 #test]
[/
["$." equivalence]]}]
+ [control
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
[number
["." i64]
["." nat]]
@@ -19,12 +20,12 @@
["." / (#+ Binary)]})
(def: (succeed result)
- (-> (Error Bit) Bit)
+ (-> (Try Bit) Bit)
(case result
- (#error.Failure _)
+ (#try.Failure _)
#0
- (#error.Success output)
+ (#try.Success output)
output))
(def: #export (binary size)
@@ -34,19 +35,19 @@
(if (n/< size idx)
(do r.monad
[byte r.nat]
- (exec (error.assume (/.write/8 idx byte output))
+ (exec (try.assume (/.write/8 idx byte output))
(recur (inc idx))))
(:: r.monad wrap output)))))
(def: (bits-io bytes read write value)
- (-> Nat (-> Nat Binary (Error Nat)) (-> Nat Nat Binary (Error Any)) Nat Bit)
+ (-> Nat (-> Nat Binary (Try Nat)) (-> Nat Nat Binary (Try Any)) Nat Bit)
(let [binary (/.create bytes)
cap (case bytes
8 (dec 0)
_ (|> 1 (i64.left-shift (n/* 8 bytes)) dec))
capped-value (i64.and cap value)]
(succeed
- (do error.monad
+ (do try.monad
[_ (write 0 value binary)
output (read 0 binary)]
(wrap (n/= capped-value output))))))
@@ -76,13 +77,13 @@
(bits-io 8 /.read/64 /.write/64 value))
(_.test "Can slice binaries."
(let [slice-size (|> to (n/- from) inc)
- random-slice (error.assume (/.slice from to random-binary))
+ random-slice (try.assume (/.slice from to random-binary))
idxs (list.n/range 0 (dec slice-size))
reader (function (_ binary idx) (/.read/8 idx binary))]
(and (n/= slice-size (/.size random-slice))
- (case [(monad.map error.monad (reader random-slice) idxs)
- (monad.map error.monad (|>> (n/+ from) (reader random-binary)) idxs)]
- [(#error.Success slice-vals) (#error.Success binary-vals)]
+ (case [(monad.map try.monad (reader random-slice) idxs)
+ (monad.map try.monad (|>> (n/+ from) (reader random-binary)) idxs)]
+ [(#try.Success slice-vals) (#try.Success binary-vals)]
(:: (list.equivalence nat.equivalence) = slice-vals binary-vals)
_
diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux
index 61cf67a6c..4ccd4e337 100644
--- a/stdlib/source/test/lux/data/format/json.lux
+++ b/stdlib/source/test/lux/data/format/json.lux
@@ -14,7 +14,6 @@
pipe
["p" parser]]
[data
- ["." error]
["." bit]
["." maybe]
["." text]
diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux
index 6ca73269a..a7236ede6 100644
--- a/stdlib/source/test/lux/data/format/xml.lux
+++ b/stdlib/source/test/lux/data/format/xml.lux
@@ -10,11 +10,11 @@
["$." codec]]}]
[control
pipe
+ ["E" try]
["p" parser
["</>" xml]]]
[data
["." name]
- ["E" error]
["." maybe]
["." text ("#@." equivalence)]
[collection
diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux
index 9b25ae6af..37df07567 100644
--- a/stdlib/source/test/lux/data/number/rev.lux
+++ b/stdlib/source/test/lux/data/number/rev.lux
@@ -14,7 +14,6 @@
["$." monoid]
["$." codec]]}]
[data
- ["." error]
[number
["." i64]]]
[math
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 61e1df77a..7789cc9bf 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -5,12 +5,12 @@
[abstract/monad (#+ do)]
[control
pipe
+ ["." try]
["p" parser
["<.>" text (#+ Parser)]
["s" code]]]
[data
[number (#+ hex)]
- ["." error]
["." text ("#@." equivalence)]]
[math
["r" random]]
@@ -23,7 +23,7 @@
(-> (Parser Text) Text Bit)
(|> input
(<text>.run regex)
- (case> (#error.Success parsed)
+ (case> (#try.Success parsed)
(text@= parsed input)
_
@@ -33,7 +33,7 @@
(-> Text (Parser Text) Text Bit)
(|> input
(<text>.run regex)
- (case> (#error.Success parsed)
+ (case> (#try.Success parsed)
(text@= test parsed)
_
@@ -43,7 +43,7 @@
(All [a] (-> (Parser a) Text Bit))
(|> input
(<text>.run regex)
- (case> (#error.Failure _)
+ (case> (#try.Failure _)
true
_
@@ -53,10 +53,10 @@
(macro.with-gensyms [g!message g!_]
(wrap (list (` (|> (~ input)
(<text>.run (~ regex))
- (case> (^ (#error.Success (~ pattern)))
+ (case> (^ (#try.Success (~ pattern)))
true
- (#error.Failure (~ g!message))
+ (#try.Failure (~ g!message))
(exec (log! (format "{{{Failure}}} " (~ g!message)))
false)
diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux
index 469c2c2f2..0921cce9e 100644
--- a/stdlib/source/test/lux/macro/poly/json.lux
+++ b/stdlib/source/test/lux/macro/poly/json.lux
@@ -16,7 +16,6 @@
## TODO: Get rid of this import ASAP
[json (#+)]]]
[data
- ["." error]
["." bit]
["." maybe]
["." text]
diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux
index b09f45b1d..549967643 100644
--- a/stdlib/source/test/lux/macro/syntax.lux
+++ b/stdlib/source/test/lux/macro/syntax.lux
@@ -7,12 +7,12 @@
[abstract
[equivalence (#+ Equivalence)]]
[control
+ ["." try (#+ Try)]
["p" parser
["s" code (#+ Parser)]]]
[data
["." bit]
["." name]
- ["." error (#+ Error)]
["." text]
[number
["." nat]
@@ -52,7 +52,7 @@
#0))
(def: (fails? input)
- (All [a] (-> (Error a) Bit))
+ (All [a] (-> (Try a) Bit))
(case input
(#.Left _)
#1
diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux
index 45c1b4b65..a600acfab 100644
--- a/stdlib/source/test/lux/math/modular.lux
+++ b/stdlib/source/test/lux/math/modular.lux
@@ -4,10 +4,11 @@
["_" test (#+ Test)]
["r" math/random]
[abstract/monad (#+ do)]
+ [control
+ ["." try]]
[data
["." product]
- ["." bit ("#@." equivalence)]
- ["." error]]
+ ["." bit ("#@." equivalence)]]
["." type ("#@." equivalence)]]
{1
["." /]})
@@ -63,11 +64,11 @@
(do r.monad
[_normalM modulusR
_alternativeM (|> modulusR (r.filter (|>> (i/= _normalM) not)))
- #let [normalM (|> _normalM /.from-int error.assume)
- alternativeM (|> _alternativeM /.from-int error.assume)]
+ #let [normalM (|> _normalM /.from-int try.assume)
+ alternativeM (|> _alternativeM /.from-int try.assume)]
[_param param] (modR normalM)
[_subject subject] (modR normalM)
- #let [copyM (|> normalM /.to-int /.from-int error.assume)]]
+ #let [copyM (|> normalM /.to-int /.from-int try.assume)]]
($_ _.and
(_.test "Every modulus has a unique type, even if the numeric value is the same as another."
(and (type@= (:of normalM)
@@ -110,26 +111,26 @@
(_.test "Can encode/decode to text."
(let [(^open "mod/.") (/.codec normalM)]
(case (|> subject mod/encode mod/decode)
- (#error.Success output)
+ (#try.Success output)
(/.m/= subject output)
- (#error.Failure error)
+ (#try.Failure error)
false)))
(_.test "Can equalize 2 moduli if they are equal."
(case (/.equalize (/.mod normalM _subject)
(/.mod copyM _param))
- (#error.Success paramC)
+ (#try.Success paramC)
(/.m/= param paramC)
- (#error.Failure error)
+ (#try.Failure error)
false))
(_.test "Cannot equalize 2 moduli if they are the different."
(case (/.equalize (/.mod normalM _subject)
(/.mod alternativeM _param))
- (#error.Success paramA)
+ (#try.Success paramA)
false
- (#error.Failure error)
+ (#try.Failure error)
true))
(_.test "All numbers are congruent to themselves."
(/.congruent? normalM _subject _subject))
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index 873d32e09..f044b74d0 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -3,6 +3,7 @@
[abstract/monad (#+ do)]
[control
["." io (#+ IO)]
+ ["." try (#+ Try)]
[parser
["<2>" binary]]
[concurrency
@@ -11,7 +12,6 @@
["!" capability]]]
[data
[binary (#+ Binary)]
- ["." error (#+ Error)]
["." text
["%" format (#+ format)]]
[format
@@ -26,6 +26,8 @@
["_" test (#+ Test)]]
{1
["." / #_
+ ["#." program]
+
["#." loader (#+ Library)]
["#." version]
["#." descriptor (#+ Descriptor Value)]
@@ -40,15 +42,15 @@
## (-> Text Binary (IO Text))
## (let [file-path (format name ".class")]
## (do io.monad
-## [outcome (do (error.with @)
-## [file (: (IO (Error (File IO)))
+## [outcome (do (try.with @)
+## [file (: (IO (Try (File IO)))
## (file.get-file io.monad file.system file-path))]
## (!.use (:: file over-write) bytecode))]
## (wrap (case outcome
-## (#error.Success definition)
+## (#try.Success definition)
## (format "Wrote: " (%.text file-path))
-## (#error.Failure error)
+## (#try.Failure error)
## error)))))
(def: descriptor
@@ -102,17 +104,17 @@
($_ _.and
(_.test "Can read a generated class."
(case (<2>.run /class.parser bytecode)
- (#error.Success output)
+ (#try.Success output)
(:: /class.equivalence = input output)
- (#error.Failure error)
+ (#try.Failure _)
false))
(_.test "Can generate a class."
(case (/loader.define full-name bytecode loader)
- (#error.Success definition)
+ (#try.Success definition)
true
- (#error.Failure error)
+ (#try.Failure _)
false))
)))
diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux
index 851267c59..8ec82dc70 100644
--- a/stdlib/source/test/lux/time/duration.lux
+++ b/stdlib/source/test/lux/time/duration.lux
@@ -10,8 +10,6 @@
["$." order]
["$." monoid]
["$." codec]]}]
- [data
- ["E" error]]
[math
["r" random (#+ Random)]]]
{1
diff --git a/stdlib/source/test/lux/tool/compiler/default/syntax.lux b/stdlib/source/test/lux/tool/compiler/default/syntax.lux
index a9744dfb6..1b9e5c7a4 100644
--- a/stdlib/source/test/lux/tool/compiler/default/syntax.lux
+++ b/stdlib/source/test/lux/tool/compiler/default/syntax.lux
@@ -7,10 +7,10 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
+ ["." try]
[parser
["l" text]]]
[data
- ["." error]
["." text]
[collection
["." list]
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
index 08346c47b..7d5046571 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/function.lux
@@ -7,9 +7,9 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
+ pipe
+ ["." try]]
[data
- ["." error]
["." maybe]
["." product]
["." text ("#@." equivalence)]
@@ -36,11 +36,11 @@
(|> analysis
(//type.with-type expectedT)
(///.run _primitive.state)
- (case> (#error.Success applyA)
+ (case> (#try.Success applyA)
(let [[funcA argsA] (////analysis.application applyA)]
(n/= num-args (list.size argsA)))
- (#error.Failure error)
+ (#try.Failure _)
false)))
(def: abstraction
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/primitive.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/primitive.lux
index 1a7aec26f..57c3152d9 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/primitive.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/primitive.lux
@@ -9,9 +9,8 @@
["_" test (#+ Test)]
[control
pipe
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
- [data
- ["." error (#+ Error)]]
["." type ("#@." equivalence)]
[macro
["." code]]]
@@ -32,12 +31,12 @@
(def: #export (expander macro inputs state)
Expander
- (#error.Failure "NOPE"))
+ (#try.Failure "NOPE"))
(def: #export (eval count type expression)
Eval
(function (_ state)
- (#error.Failure "NO!")))
+ (#try.Failure "NO!")))
(def: #export phase
////analysis.Phase
@@ -69,24 +68,24 @@
["Inferred" (%.type inferred)]))
(def: (infer expected-type analysis)
- (-> Type (Operation Analysis) (Error Analysis))
+ (-> Type (Operation Analysis) (Try Analysis))
(|> analysis
//type.with-inference
(///.run ..state)
- (case> (#error.Success [inferred-type output])
+ (case> (#try.Success [inferred-type output])
(if (is? expected-type inferred-type)
- (#error.Success output)
+ (#try.Success output)
(exception.throw wrong-inference [expected-type inferred-type]))
- (#error.Failure error)
- (#error.Failure error))))
+ (#try.Failure error)
+ (#try.Failure error))))
(def: #export test
(<| (_.context (name.module (name-of /._)))
(`` ($_ _.and
(_.test (%.name (name-of #////analysis.Unit))
(|> (infer Any (..phase (' [])))
- (case> (^ (#error.Success (#////analysis.Primitive (#////analysis.Unit output))))
+ (case> (^ (#try.Success (#////analysis.Primitive (#////analysis.Unit output))))
(is? [] output)
_
@@ -96,7 +95,7 @@
[sample <random>]
(_.test (%.name (name-of <tag>))
(|> (infer <type> (..phase (<constructor> sample)))
- (case> (#error.Success (#////analysis.Primitive (<tag> output)))
+ (case> (#try.Success (#////analysis.Primitive (<tag> output)))
(is? sample output)
_
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
index 427e0dc2c..777fe152f 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/reference.lux
@@ -6,9 +6,9 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
+ pipe
+ ["." try (#+ Try)]]
[data
- ["." error (#+ Error)]
["." text ("#@." equivalence)]]
["." type ("#@." equivalence)]
[macro
@@ -26,15 +26,15 @@
["#." reference]
["#." analysis (#+ Analysis Variant Tag Operation)]]]]]})
-(type: Check (-> (Error Any) Bit))
+(type: Check (-> (Try Any) Bit))
(template [<name> <on-success> <on-failure>]
[(def: <name>
Check
- (|>> (case> (#error.Success _)
+ (|>> (case> (#try.Success _)
<on-success>
- (#error.Failure error)
+ (#try.Failure _)
<on-failure>)))]
[success? true false]
@@ -72,7 +72,7 @@
(//type.with-inference
(_primitive.phase (code.local-identifier var-name)))))
(///.run _primitive.state)
- (case> (^ (#error.Success [inferredT (#////analysis.Reference (////reference.local var))]))
+ (case> (^ (#try.Success [inferredT (#////analysis.Reference (////reference.local var))]))
(and (type@= expectedT inferredT)
(n/= 0 var))
@@ -86,7 +86,7 @@
(_primitive.phase (code.identifier def-name))))
(//module.with-module 0 def-module)
(///.run _primitive.state)
- (case> (^ (#error.Success [_ inferredT (#////analysis.Reference (////reference.constant constant-name))]))
+ (case> (^ (#try.Success [_ inferredT (#////analysis.Reference (////reference.constant constant-name))]))
(and (type@= expectedT inferredT)
(name@= def-name constant-name))
diff --git a/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux
index 156965a55..08344f23e 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/analysis/structure.lux
@@ -7,10 +7,10 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
+ pipe
+ ["." try]]
[data
["." bit ("#@." equivalence)]
- ["." error]
["." product]
["." maybe]
["." text]
@@ -36,7 +36,7 @@
[(def: #export <name>
(All [a] (-> (Operation a) Bit))
(|>> (///.run _primitive.state)
- (case> (#error.Success _)
+ (case> (#try.Success _)
<on-success>
_
@@ -64,7 +64,7 @@
(|> analysis
(//type.with-type type)
(///.run _primitive.state)
- (case> (^ (#error.Success (////analysis.variant variant)))
+ (case> (^ (#try.Success (////analysis.variant variant)))
(check-sum' tag size variant)
_
@@ -82,7 +82,7 @@
(with-tags module tags variantT)
(//type.with-type expectedT)
(///.run _primitive.state)
- (case> (^ (#error.Success [_ (////analysis.variant variant)]))
+ (case> (^ (#try.Success [_ (////analysis.variant variant)]))
(check-sum' tag (list.size tags) variant)
_
@@ -104,7 +104,7 @@
(with-tags module tags recordT)
(//type.with-type expectedT)
(///.run _primitive.state)
- (case> (#error.Success [_ productA])
+ (case> (#try.Success [_ productA])
(correct-size? size productA)
_
@@ -138,7 +138,7 @@
(//type.with-type varT
(/.sum _primitive.phase choice valueC)))
(///.run _primitive.state)
- (case> (^ (#error.Success (////analysis.variant variant)))
+ (case> (^ (#try.Success (////analysis.variant variant)))
(check-sum' choice size variant)
_
@@ -180,7 +180,7 @@
(|> (//type.with-type tupleT
(/.product _primitive.phase (list@map product.right primitives)))
(///.run _primitive.state)
- (case> (#error.Success tupleA)
+ (case> (#try.Success tupleA)
(correct-size? size tupleA)
_
@@ -189,7 +189,7 @@
(|> (//type.with-inference
(/.product _primitive.phase (list@map product.right primitives)))
(///.run _primitive.state)
- (case> (#error.Success [_type tupleA])
+ (case> (#try.Success [_type tupleA])
(and (check.checks? tupleT _type)
(correct-size? size tupleA))
@@ -207,7 +207,7 @@
(//type.with-type varT
(/.product _primitive.phase (list@map product.right primitives))))
(///.run _primitive.state)
- (case> (#error.Success tupleA)
+ (case> (#try.Success tupleA)
(correct-size? size tupleA)
_
diff --git a/stdlib/source/test/lux/tool/compiler/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/tool/compiler/phase/extension/analysis/lux.lux
index 1b89d30d4..c659d9db0 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/extension/analysis/lux.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/extension/analysis/lux.lux
@@ -9,10 +9,10 @@
[control
pipe
[io (#+ IO)]
+ ["." try]
[concurrency
["." atom]]]
[data
- ["." error]
["." product]]
["." type ("#@." equivalence)]
[macro
@@ -34,10 +34,10 @@
(////type.with-type output-type
(_primitive.phase (` ((~ (code.text procedure)) (~+ params))))))
(////.run _primitive.state)
- (case> (#error.Success _)
+ (case> (#try.Success _)
<success>
- (#error.Failure error)
+ (#try.Failure _)
<failure>)))]
[check-success+ true false]
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
index b5a03fd9f..d2d310fa1 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/case.lux
@@ -6,9 +6,8 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
- [data
- ["." error ("#@." functor)]]]
+ pipe
+ ["." try ("#@." functor)]]]
["." // #_
["#." primitive]]
{1
@@ -36,8 +35,8 @@
(|> maskA
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (error@map (//primitive.corresponds? maskedA))
- (error.default false)))))
+ (try@map (//primitive.corresponds? maskedA))
+ (try.default false)))))
(def: let-expr
Test
@@ -54,7 +53,7 @@
(|> letA
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.branch/let [inputS registerS outputS])))
+ (case> (^ (#try.Success (////synthesis.branch/let [inputS registerS outputS])))
(and (n/= registerA registerS)
(//primitive.corresponds? inputA inputS)
(//primitive.corresponds? outputA outputS))
@@ -82,7 +81,7 @@
(|> ifA
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.branch/if [inputS thenS elseS])))
+ (case> (^ (#try.Success (////synthesis.branch/if [inputS thenS elseS])))
(and (//primitive.corresponds? inputA inputS)
(//primitive.corresponds? thenA thenS)
(//primitive.corresponds? elseA elseS))
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
index 3ca60e77b..368b692e9 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/function.lux
@@ -6,11 +6,11 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
+ pipe
+ ["." try]]
[data
["." product]
["." maybe]
- ["." error]
[number
["." nat]]
[collection
@@ -118,7 +118,7 @@
(|> function//constant
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.function/abstraction [environment arity output])))
+ (case> (^ (#try.Success (////synthesis.function/abstraction [environment arity output])))
(and (n/= arity//constant arity)
(//primitive.corresponds? prediction//constant output))
@@ -128,7 +128,7 @@
(|> function//environment
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
+ (case> (^ (#try.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
(and (n/= arity//environment arity)
(variable@= prediction//environment output))
@@ -138,7 +138,7 @@
(|> function//local
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
+ (case> (^ (#try.Success (////synthesis.function/abstraction [environment arity (#////synthesis.Reference (////reference.variable output))])))
(and (n/= arity//local arity)
(variable@= prediction//local output))
@@ -157,7 +157,7 @@
(|> (////analysis.apply [funcA argsA])
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.function/apply [funcS argsS])))
+ (case> (^ (#try.Success (////synthesis.function/apply [funcS argsS])))
(and (//primitive.corresponds? funcA funcS)
(list.every? (product.uncurry //primitive.corresponds?)
(list.zip2 argsA argsS)))
@@ -168,7 +168,7 @@
(|> (////analysis.apply [funcA (list)])
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (#error.Success funcS)
+ (case> (#try.Success funcS)
(//primitive.corresponds? funcA funcS)
_
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/primitive.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/primitive.lux
index f54ace3d5..d9d24ea21 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/primitive.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/primitive.lux
@@ -7,9 +7,8 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
- [data
- ["." error]]]
+ pipe
+ ["." try]]]
{1
["." / #_
["/#" //
@@ -66,7 +65,7 @@
(|> (#////analysis.Primitive (<analysis> expected))
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (#error.Success (#////synthesis.Primitive (<synthesis> actual)))
+ (case> (#try.Success (#////synthesis.Primitive (<synthesis> actual)))
(is? expected actual)
_
diff --git a/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
index 0ea42a2a9..76405c771 100644
--- a/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
+++ b/stdlib/source/test/lux/tool/compiler/phase/synthesis/structure.lux
@@ -7,11 +7,11 @@
["r" math/random (#+ Random) ("#@." monad)]
["_" test (#+ Test)]
[control
- pipe]
+ pipe
+ ["." try]]
[data
["." bit ("#@." equivalence)]
["." product]
- ["." error]
[collection
["." list]]]]
["." // #_
@@ -40,7 +40,7 @@
(|> (////analysis.variant [lefts right? memberA])
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.variant [leftsS right?S valueS])))
+ (case> (^ (#try.Success (////synthesis.variant [leftsS right?S valueS])))
(let [tagS (if right?S (inc leftsS) leftsS)]
(and (n/= tagA tagS)
(|> tagS (n/= (dec size)) (bit@= right?S))
@@ -58,7 +58,7 @@
(|> (////analysis.tuple membersA)
//.phase
(///.run [///bundle.empty ////synthesis.init])
- (case> (^ (#error.Success (////synthesis.tuple membersS)))
+ (case> (^ (#try.Success (////synthesis.tuple membersS)))
(and (n/= size (list.size membersS))
(list.every? (product.uncurry //primitive.corresponds?)
(list.zip2 membersA membersS)))
diff --git a/stdlib/source/test/lux/type/dynamic.lux b/stdlib/source/test/lux/type/dynamic.lux
index 5baccd9dc..b84a6f0a3 100644
--- a/stdlib/source/test/lux/type/dynamic.lux
+++ b/stdlib/source/test/lux/type/dynamic.lux
@@ -4,8 +4,8 @@
[abstract/monad (#+ do)]
["r" math/random (#+ Random)]
["_" test (#+ Test)]
- [data
- ["." error]]]
+ [control
+ ["." try]]]
{1
["." / (#+ Dynamic :dynamic :check)]})
@@ -18,15 +18,15 @@
($_ _.and
(_.test "Can check dynamic values."
(case (:check Nat value)
- (#error.Success actual)
+ (#try.Success actual)
(n/= expected actual)
- (#error.Failure error)
+ (#try.Failure _)
false))
(_.test "Cannot confuse types."
(case (:check Text value)
- (#error.Success actual)
+ (#try.Success actual)
false
- (#error.Failure error)
+ (#try.Failure _)
true))))))
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 451f4671b..808a09e0e 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -6,13 +6,13 @@
[abstract/monad (#+ do)]
[control
["." io (#+ IO)]
+ ["." try (#+ Try)]
[concurrency
["." promise]]
[security
["!" capability]]]
[data
["." binary (#+ Binary)]
- ["." error (#+ Error)]
["." text]
[number
["." int]]
@@ -36,9 +36,9 @@
(r@wrap (do promise.monad
[#let [path (format "temp_file_" (%.nat number))]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (IO (Error Bit))
- (error.lift io.monad (/.exists? io.monad /.system path)))]
+ (do (try.with io.monad)
+ [#let [check-existence! (: (IO (Try Bit))
+ (try.lift io.monad (/.exists? io.monad /.system path)))]
pre! check-existence!
file (!.use (:: /.system create-file) path)
post! check-existence!
@@ -48,21 +48,21 @@
post!
(not remains?)))))]
(_.assert "Can create/delete files."
- (error.default #0 result)))))
+ (try.default #0 result)))))
(def: (read-and-write number data)
(-> Nat Binary Test)
(r@wrap (do promise.monad
[#let [path (format "temp_file_" (%.nat number))]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) data)
content (!.use (:: file content) [])
_ (!.use (:: file delete) [])]
(wrap (:: binary.equivalence = data content))))]
(_.assert "Can write/read files."
- (error.default #0 result)))))
+ (try.default #0 result)))))
(def: #export test
Test
@@ -81,18 +81,18 @@
(wrap (do promise.monad
[#let [path "temp_file_2"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
read-size (!.use (:: file size) [])
_ (!.use (:: file delete) [])]
(wrap (n/= file-size read-size))))]
(_.assert "Can read file size."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_file_3"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
_ (!.use (:: file append) dataR)
@@ -102,18 +102,18 @@
(wrap (and (n/= (n/* 2 file-size) read-size)
(:: binary.equivalence =
dataL
- (error.assume (binary.slice 0 (dec file-size) content)))
+ (try.assume (binary.slice 0 (dec file-size) content)))
(:: binary.equivalence =
dataR
- (error.assume (binary.slice file-size (dec read-size) content)))))))]
+ (try.assume (binary.slice file-size (dec read-size) content)))))))]
(_.assert "Can append to files."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_dir_4"]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (IO (Error Bit))
- (error.lift io.monad (/.exists? io.monad /.system path)))]
+ (do (try.with io.monad)
+ [#let [check-existence! (: (IO (Try Bit))
+ (try.lift io.monad (/.exists? io.monad /.system path)))]
pre! check-existence!
dir (!.use (:: /.system create-directory) path)
post! check-existence!
@@ -123,12 +123,12 @@
post!
(not remains?)))))]
(_.assert "Can create/delete directories."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [file-path "temp_file_5"
dir-path "temp_dir_5"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[dir (!.use (:: /.system create-directory) dir-path)
file (!.use (:: /.system create-file) (format dir-path "/" file-path))
_ (!.use (:: file over-write) dataL)
@@ -137,13 +137,13 @@
_ (!.use (:: dir discard) [])]
(wrap (n/= file-size read-size))))]
(_.assert "Can create files inside of directories."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [file-path "temp_file_6"
dir-path "temp_dir_6"
inner-dir-path "inner_temp_dir_6"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[dir (!.use (:: /.system create-directory) dir-path)
pre-files (!.use (:: dir files) [])
pre-directories (!.use (:: dir directories) [])
@@ -161,11 +161,11 @@
(and (n/= 1 (list.size post-files))
(n/= 1 (list.size post-directories)))))))]
(_.assert "Can list files/directories inside a directory."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_file_7"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
_ (!.use (:: file modify) new-modified)
@@ -173,19 +173,19 @@
_ (!.use (:: file delete) [])]
(wrap (:: instant.equivalence = new-modified old-modified))))]
(_.assert "Can change the time of last modification."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path0 (format "temp_file_8+0")
path1 (format "temp_file_8+1")]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (-> Path (IO (Error Bit)))
+ (do (try.with io.monad)
+ [#let [check-existence! (: (-> Path (IO (Try Bit)))
(|>> (/.exists? io.monad /.system)
- (error.lift io.monad)))]
+ (try.lift io.monad)))]
file0 (!.use (:: /.system create-file) path0)
_ (!.use (:: file0 over-write) dataL)
pre! (check-existence! path0)
- file1 (: (IO (Error (File IO))) ## TODO: Remove :
+ file1 (: (IO (Try (File IO))) ## TODO: Remove :
(!.use (:: file0 move) path1))
post! (check-existence! path0)
confirmed? (check-existence! path1)
@@ -194,5 +194,5 @@
(not post!)
confirmed?))))]
(_.assert "Can move a file from one path to another."
- (error.default #0 result))))
+ (try.default #0 result))))
))))