diff options
author | Eduardo Julian | 2021-07-11 01:51:04 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-07-11 01:51:04 -0400 |
commit | abe24425ced15fd784ef6c62d6f186af72b491db (patch) | |
tree | 42b6e3cbd179c83fae8941fa4b128b13afc766f5 /stdlib/source/spec/compositor | |
parent | 4610968193df10af12c91f699fec39aeb3ef703a (diff) |
Re-named ":coerce" to ":as" since it technically doesn't do coercions.
Diffstat (limited to 'stdlib/source/spec/compositor')
4 files changed, 47 insertions, 47 deletions
diff --git a/stdlib/source/spec/compositor/generation/case.lux b/stdlib/source/spec/compositor/generation/case.lux index 958110ce4..4f45a480c 100644 --- a/stdlib/source/spec/compositor/generation/case.lux +++ b/stdlib/source/spec/compositor/generation/case.lux @@ -41,7 +41,7 @@ (def: #export (verify expected) (-> Frac (Try Any) Bit) (|>> (case> (#try.Success actual) - (f.= expected (:coerce Frac actual)) + (f.= expected (:as Frac actual)) (#try.Failure _) false))) diff --git a/stdlib/source/spec/compositor/generation/common.lux b/stdlib/source/spec/compositor/generation/common.lux index baa32674a..3d377b7ca 100644 --- a/stdlib/source/spec/compositor/generation/common.lux +++ b/stdlib/source/spec/compositor/generation/common.lux @@ -43,7 +43,7 @@ (synthesis.i64 subject))) (run (..sanitize <extension>)) (case> (#try.Success valueT) - (n.= (<reference> param subject) (:coerce Nat valueT)) + (n.= (<reference> param subject) (:as Nat valueT)) (#try.Failure _) false) @@ -55,22 +55,22 @@ ["lux i64 left-shift" i64.left-shift (n.% 64 param)] ["lux i64 logical-right-shift" i64.logic-right-shift (n.% 64 param)] )] - ($_ _.and - <binary> - (_.test "lux i64 arithmetic-right-shift" - (|> (#synthesis.Extension "lux i64 arithmetic-right-shift" - (list (synthesis.i64 subject) - (synthesis.i64 param))) - (run (..sanitize "lux i64 arithmetic-right-shift")) - (case> (#try.Success valueT) - ("lux i64 =" - (i64.arithmetic-right-shift param subject) - (:coerce I64 valueT)) - - (#try.Failure _) - false) - (let [param (n.% 64 param)]))) - )))) + ($_ _.and + <binary> + (_.test "lux i64 arithmetic-right-shift" + (|> (#synthesis.Extension "lux i64 arithmetic-right-shift" + (list (synthesis.i64 subject) + (synthesis.i64 param))) + (run (..sanitize "lux i64 arithmetic-right-shift")) + (case> (#try.Success valueT) + ("lux i64 =" + (i64.arithmetic-right-shift param subject) + (:as I64 valueT)) + + (#try.Failure _) + false) + (let [param (n.% 64 param)]))) + )))) (def: (i64 run) (-> Runner Test) @@ -83,17 +83,17 @@ (|> (#synthesis.Extension <extension> (list (synthesis.i64 subject))) (run (..sanitize <extension>)) (case> (#try.Success valueT) - (<comp> (<prepare> subject) (:coerce <type> valueT)) + (<comp> (<prepare> subject) (:as <type> valueT)) (#try.Failure _) false) (let [subject <subject-expr>])))] ["lux i64 f64" Frac i.frac f.= subject] - ["lux i64 char" Text (|>> (:coerce Nat) text.from-code) text\= (|> subject - (:coerce Nat) - (n.% (i64.left-shift 8 1)) - (:coerce Int))] + ["lux i64 char" Text (|>> (:as Nat) text.from-code) text\= (|> subject + (:as Nat) + (n.% (i64.left-shift 8 1)) + (:as Int))] )) (~~ (template [<extension> <reference> <outputT> <comp>] [(_.test <extension> @@ -101,7 +101,7 @@ (synthesis.i64 subject))) (run (..sanitize <extension>)) (case> (#try.Success valueT) - (<comp> (<reference> param subject) (:coerce <outputT> valueT)) + (<comp> (<reference> param subject) (:as <outputT> valueT)) (#try.Failure _) false)))] @@ -146,7 +146,7 @@ (run (..sanitize <extension>)) (case> (#try.Success valueV) (bit\= (<text> param subject) - (:coerce Bit valueV)) + (:as Bit valueV)) _ false)))] @@ -194,14 +194,14 @@ (and (|> (#synthesis.Extension "lux text =" (list sample-lowerS sample-lowerS)) (run (..sanitize "lux text =")) (case> (#try.Success valueV) - (:coerce Bit valueV) + (:as Bit valueV) _ false)) (|> (#synthesis.Extension "lux text =" (list sample-upperS sample-lowerS)) (run (..sanitize "lux text =")) (case> (#try.Success valueV) - (not (:coerce Bit valueV)) + (not (:as Bit valueV)) _ false)))) @@ -209,7 +209,7 @@ (|> (#synthesis.Extension "lux text <" (list sample-lowerS sample-upperS)) (run (..sanitize "lux text <")) (case> (#try.Success valueV) - (:coerce Bit valueV) + (:as Bit valueV) (#try.Failure _) false))) @@ -217,7 +217,7 @@ (|> (#synthesis.Extension "lux text size" (list sample-lowerS)) (run (..sanitize "lux text size")) (case> (#try.Success valueV) - (n.= sample-size (:coerce Nat valueV)) + (n.= sample-size (:as Nat valueV)) _ false))) @@ -225,7 +225,7 @@ (|> (#synthesis.Extension "lux text size" (list concatenatedS)) (run (..sanitize "lux text size")) (case> (#try.Success valueV) - (n.= (n.* 2 sample-size) (:coerce Nat valueV)) + (n.= (n.* 2 sample-size) (:as Nat valueV)) _ false))) @@ -235,7 +235,7 @@ (synthesis.i64 +0))) (run (..sanitize "lux text index")) (case> (^multi (#try.Success valueV) - [(:coerce (Maybe Nat) valueV) (#.Some valueV)]) + [(:as (Maybe Nat) valueV) (#.Some valueV)]) (n.= 0 valueV) _ @@ -245,7 +245,7 @@ (synthesis.i64 +0))) (run (..sanitize "lux text index")) (case> (^multi (#try.Success valueV) - [(:coerce (Maybe Nat) valueV) (#.Some valueV)]) + [(:as (Maybe Nat) valueV) (#.Some valueV)]) (n.= sample-size valueV) _ @@ -258,7 +258,7 @@ (synthesis.i64 length))) (run (..sanitize "lux text clip")) (case> (^multi (#try.Success valueV) - [(:coerce (Maybe Text) valueV) (#.Some valueV)]) + [(:as (Maybe Text) valueV) (#.Some valueV)]) (text\= expected valueV) _ @@ -272,7 +272,7 @@ (synthesis.i64 char-idx))) (run (..sanitize "lux text char")) (case> (^multi (#try.Success valueV) - [(:coerce (Maybe Int) valueV) (#.Some valueV)]) + [(:as (Maybe Int) valueV) (#.Some valueV)]) (text.contains? ("lux i64 char" valueV) sample-lower) @@ -303,7 +303,7 @@ (list (synthesis.text message)))}))) (run (..sanitize "lux try")) (case> (^multi (#try.Success valueV) - [(:coerce (Try Text) valueV) (#try.Failure error)]) + [(:as (Try Text) valueV) (#try.Failure error)]) (text.contains? message error) _ @@ -315,7 +315,7 @@ #synthesis.body (synthesis.text message)}))) (run (..sanitize "lux try")) (case> (^multi (#try.Success valueV) - [(:coerce (Try Text) valueV) (#try.Success valueV)]) + [(:as (Try Text) valueV) (#try.Success valueV)]) (text\= message valueV) _ @@ -325,7 +325,7 @@ (#synthesis.Extension "lux io current-time" (list)))) (run (..sanitize "lux io current-time")) (case> (#try.Success valueV) - (let [[pre post] (:coerce [Nat Nat] valueV)] + (let [[pre post] (:as [Nat Nat] valueV)] (n.>= pre post)) (#try.Failure _) diff --git a/stdlib/source/spec/compositor/generation/reference.lux b/stdlib/source/spec/compositor/generation/reference.lux index a94824f28..665175ab4 100644 --- a/stdlib/source/spec/compositor/generation/reference.lux +++ b/stdlib/source/spec/compositor/generation/reference.lux @@ -32,7 +32,7 @@ (_.test "Definitions." (|> (define name (synthesis.f64 expected)) (case> (#try.Success actual) - (f.= expected (:coerce Frac actual)) + (f.= expected (:as Frac actual)) (#try.Failure _) false))))) @@ -48,7 +48,7 @@ (synthesis.variable/local register)]) (run "variable") (case> (#try.Success actual) - (f.= expected (:coerce Frac actual)) + (f.= expected (:as Frac actual)) (#try.Failure _) false))))) diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux index 237ff5024..7c45d2a9b 100644 --- a/stdlib/source/spec/compositor/generation/structure.lux +++ b/stdlib/source/spec/compositor/generation/structure.lux @@ -43,19 +43,19 @@ #analysis.value (synthesis.i64 value-in)}) (run "variant") (case> (#try.Success valueT) - (let [valueT (:coerce (Array Any) valueT)] + (let [valueT (:as (Array Any) valueT)] (and (n.= 3 (array.size valueT)) - (let [tag-out (:coerce java/lang/Integer (maybe.assume (array.read 0 valueT))) + (let [tag-out (:as java/lang/Integer (maybe.assume (array.read 0 valueT))) last?-out (array.read 1 valueT) - value-out (:coerce Any (maybe.assume (array.read 2 valueT))) - same-tag? (|> tag-out ffi.int-to-long (:coerce Nat) (n.= tag-in)) + value-out (:as Any (maybe.assume (array.read 2 valueT))) + same-tag? (|> tag-out ffi.int-to-long (:as Nat) (n.= tag-in)) same-flag? (case last?-out (#.Some last?-out') - (and last?-in (text\= "" (:coerce Text last?-out'))) + (and last?-in (text\= "" (:as Text last?-out'))) #.None (not last?-in)) - same-value? (|> value-out (:coerce Int) (i.= value-in))] + same-value? (|> value-out (:as Int) (i.= value-in))] (and same-tag? same-flag? same-value?)))) @@ -72,10 +72,10 @@ (|> (synthesis.tuple (list\map (|>> synthesis.i64) tuple-in)) (run "tuple") (case> (#try.Success tuple-out) - (let [tuple-out (:coerce (Array Any) tuple-out)] + (let [tuple-out (:as (Array Any) tuple-out)] (and (n.= size (array.size tuple-out)) (list.every? (function (_ [left right]) - (i.= left (:coerce Int right))) + (i.= left (:as Int right))) (list.zip/2 tuple-in (array.to-list tuple-out))))) (#try.Failure _) |