aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/compositor/generation/case.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/specification/compositor/generation/case.lux')
-rw-r--r--stdlib/source/specification/compositor/generation/case.lux240
1 files changed, 120 insertions, 120 deletions
diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux
index 80faa246f..12fa81a14 100644
--- a/stdlib/source/specification/compositor/generation/case.lux
+++ b/stdlib/source/specification/compositor/generation/case.lux
@@ -50,52 +50,52 @@
(def: case
(Random [Synthesis Path])
(<| r.rec (function (_ case))
- (`` ($_ r.either
- (do r.monad
- [value r.i64]
- (in [(synthesis.i64 value)
- synthesis.path/pop]))
- (~~ (template [<gen> <synth> <path>]
- [(do r.monad
- [value <gen>]
- (in [(<synth> value)
- (<path> value)]))]
+ (`` (all r.either
+ (do r.monad
+ [value r.i64]
+ (in [(synthesis.i64 value)
+ synthesis.path/pop]))
+ (~~ (template [<gen> <synth> <path>]
+ [(do r.monad
+ [value <gen>]
+ (in [(<synth> value)
+ (<path> value)]))]
- [r.bit synthesis.bit synthesis.path/bit]
- [r.i64 synthesis.i64 synthesis.path/i64]
- [r.frac synthesis.f64 synthesis.path/f64]
- [(r.unicode 5) synthesis.text synthesis.path/text]))
- (do [! r.monad]
- [size ..size
- idx (|> r.nat (# ! each (n.% size)))
- [subS subP] case
- .let [unitS (synthesis.text synthesis.unit)
- caseS (synthesis.tuple
- (list.together (list (list.repeated idx unitS)
- (list subS)
- (list.repeated (|> size -- (n.- idx)) unitS))))
- caseP ($_ synthesis.path/seq
- (if (tail? size idx)
- (synthesis.member/right idx)
- (synthesis.member/left idx))
- subP)]]
- (in [caseS caseP]))
- (do [! r.monad]
- [size ..size
- idx (|> r.nat (# ! each (n.% size)))
- [subS subP] case
- .let [right? (tail? size idx)
- caseS (synthesis.variant
- [analysis.#lefts idx
- analysis.#right? right?
- analysis.#value subS])
- caseP ($_ synthesis.path/seq
- (if right?
- (synthesis.side/right idx)
- (synthesis.side/left idx))
- subP)]]
- (in [caseS caseP]))
- ))))
+ [r.bit synthesis.bit synthesis.path/bit]
+ [r.i64 synthesis.i64 synthesis.path/i64]
+ [r.frac synthesis.f64 synthesis.path/f64]
+ [(r.unicode 5) synthesis.text synthesis.path/text]))
+ (do [! r.monad]
+ [size ..size
+ idx (|> r.nat (# ! each (n.% size)))
+ [subS subP] case
+ .let [unitS (synthesis.text synthesis.unit)
+ caseS (synthesis.tuple
+ (list.together (list (list.repeated idx unitS)
+ (list subS)
+ (list.repeated (|> size -- (n.- idx)) unitS))))
+ caseP (all synthesis.path/seq
+ (if (tail? size idx)
+ (synthesis.member/right idx)
+ (synthesis.member/left idx))
+ subP)]]
+ (in [caseS caseP]))
+ (do [! r.monad]
+ [size ..size
+ idx (|> r.nat (# ! each (n.% size)))
+ [subS subP] case
+ .let [right? (tail? size idx)
+ caseS (synthesis.variant
+ [analysis.#lefts idx
+ analysis.#right? right?
+ analysis.#value subS])
+ caseP (all synthesis.path/seq
+ (if right?
+ (synthesis.side/right idx)
+ (synthesis.side/left idx))
+ subP)]]
+ (in [caseS caseP]))
+ ))))
(def: (let_spec run)
(-> Runner Test)
@@ -130,11 +130,11 @@
(_.test (%.symbol (symbol synthesis.branch/case))
(|> (synthesis.branch/case
[inputS
- ($_ synthesis.path/alt
- ($_ synthesis.path/seq
- pathS
- (synthesis.path/then (synthesis.f64 on_success)))
- (synthesis.path/then (synthesis.f64 on_failure)))])
+ (all synthesis.path/alt
+ (all synthesis.path/seq
+ pathS
+ (synthesis.path/then (synthesis.f64 on_success)))
+ (synthesis.path/then (synthesis.f64 on_failure)))])
(run "case_spec")
(verify on_success)))))
@@ -189,24 +189,24 @@
_head_ (synthesis.path/member {.#Left 0})
_tail_ (synthesis.path/member {.#Right 0})
_tuple_ (synthesis.path/side {.#Left 9})]
- ($_ synthesis.path/alt
- ($_ synthesis.path/seq
- _item_
- _head_
- _head_ (synthesis.path/bind 2) synthesis.path/pop
- _tail_ _tuple_ _item_
- _head_ (synthesis.path/bind 3) synthesis.path/pop
- _tail_ (synthesis.path/bind 4) synthesis.path/pop
- synthesis.path/pop synthesis.path/pop synthesis.path/pop synthesis.path/pop
- _tail_ _item_
- _head_ (synthesis.path/bind 5) synthesis.path/pop
- _tail_ _end_
- ... THEN
- (synthesis.path/then (synthesis.bit #1)))
- ($_ synthesis.path/seq
- (synthesis.path/bind 2)
- ... THEN
- (synthesis.path/then (synthesis.bit #0))))))
+ (all synthesis.path/alt
+ (all synthesis.path/seq
+ _item_
+ _head_
+ _head_ (synthesis.path/bind 2) synthesis.path/pop
+ _tail_ _tuple_ _item_
+ _head_ (synthesis.path/bind 3) synthesis.path/pop
+ _tail_ (synthesis.path/bind 4) synthesis.path/pop
+ synthesis.path/pop synthesis.path/pop synthesis.path/pop synthesis.path/pop
+ _tail_ _item_
+ _head_ (synthesis.path/bind 5) synthesis.path/pop
+ _tail_ _end_
+ ... THEN
+ (synthesis.path/then (synthesis.bit #1)))
+ (all synthesis.path/seq
+ (synthesis.path/bind 2)
+ ... THEN
+ (synthesis.path/then (synthesis.bit #0))))))
(def: special_pattern
analysis.Pattern
@@ -227,62 +227,62 @@
(def: special_pattern_path
Path
- ($_ synthesis.path/alt
- (<| try.trusted
- (phase.result [extension/synthesis.bundle
- synthesis.init])
- (case.path phase/synthesis.phase
- special_pattern)
- (analysis.bit #1))
- ($_ synthesis.path/seq
- (synthesis.path/bind 2)
- ... THEN
- (synthesis.path/then (synthesis.bit #0)))))
+ (all synthesis.path/alt
+ (<| try.trusted
+ (phase.result [extension/synthesis.bundle
+ synthesis.init])
+ (case.path phase/synthesis.phase
+ special_pattern)
+ (analysis.bit #1))
+ (all synthesis.path/seq
+ (synthesis.path/bind 2)
+ ... THEN
+ (synthesis.path/then (synthesis.bit #0)))))
... TODO: Get rid of this ASAP
(def: (special_spec run)
(-> Runner Test)
- ($_ _.and
- (_.test "==="
- (and (text#= (synthesis.%path special_path)
- (synthesis.%path special_pattern_path))
- (# synthesis.path_equivalence = special_path special_pattern_path)))
- (_.test "CODE"
- (|> special_input
- (run "special_input")
- (pipe.case
- {try.#Success output}
- true
-
- {try.#Failure _}
- false)))
- (_.test "PATTERN_MATCHING 0"
- (|> (synthesis.branch/case [special_input
- special_path])
- (run "special_path")
- (pipe.case
- {try.#Success output}
- true
-
- {try.#Failure _}
- false)))
- (_.test "PATTERN_MATCHING 1"
- (|> (synthesis.branch/case [special_input
- special_pattern_path])
- (run "special_pattern_path")
- (pipe.case
- {try.#Success output}
- true
-
- {try.#Failure _}
- false)))
- ))
+ (all _.and
+ (_.test "==="
+ (and (text#= (synthesis.%path special_path)
+ (synthesis.%path special_pattern_path))
+ (# synthesis.path_equivalence = special_path special_pattern_path)))
+ (_.test "CODE"
+ (|> special_input
+ (run "special_input")
+ (pipe.case
+ {try.#Success output}
+ true
+
+ {try.#Failure _}
+ false)))
+ (_.test "PATTERN_MATCHING 0"
+ (|> (synthesis.branch/case [special_input
+ special_path])
+ (run "special_path")
+ (pipe.case
+ {try.#Success output}
+ true
+
+ {try.#Failure _}
+ false)))
+ (_.test "PATTERN_MATCHING 1"
+ (|> (synthesis.branch/case [special_input
+ special_pattern_path])
+ (run "special_pattern_path")
+ (pipe.case
+ {try.#Success output}
+ true
+
+ {try.#Failure _}
+ false)))
+ ))
(def: .public (spec run)
(-> Runner Test)
- ($_ _.and
- (..special_spec run)
- (..let_spec run)
- (..if_spec run)
- (..case_spec run)
- ))
+ (all _.and
+ (..special_spec run)
+ (..let_spec run)
+ (..if_spec run)
+ (..case_spec run)
+ ))