diff options
Diffstat (limited to 'stdlib/source/spec/compositor')
8 files changed, 71 insertions, 74 deletions
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) |