From 065e8a4d8122d4616b570496915d2c0e2c78cd6b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 11 Aug 2022 04:15:07 -0400 Subject: Re-named the "case" macro to "when". --- .../specification/compositor/generation/case.lux | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'stdlib/source/specification/compositor/generation/case.lux') diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index ba1168ad0..8043bd2e0 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except case) + [lux (.except when) [abstract [monad (.only do)]] [control @@ -23,7 +23,7 @@ ["[0]" synthesis (.only Path Synthesis)] ["[0]" phase ["[1]/[0]" synthesis - ["[0]" case]] + ["[0]" when]] ["[0]" extension/synthesis]]]] [test ["_" property (.only Test)]]]] @@ -42,16 +42,16 @@ (def .public (verify expected) (-> Frac (Try Any) Bit) - (|>> (pipe.case + (|>> (pipe.when {try.#Success actual} (f.= expected (as Frac actual)) {try.#Failure _} false))) -(def case +(def when (Random [Synthesis Path]) - (<| r.rec (function (_ case)) + (<| r.rec (function (_ when)) (`` (all r.either (do r.monad [value r.i64] @@ -70,33 +70,33 @@ (do [! r.monad] [size ..size idx (|> r.nat (at ! each (n.% size))) - [subS subP] case + [subS subP] when .let [unitS (synthesis.text synthesis.unit) - caseS (synthesis.tuple + whenS (synthesis.tuple (list.together (list (list.repeated idx unitS) (list subS) (list.repeated (|> size -- (n.- idx)) unitS)))) - caseP (all synthesis.path/seq + whenP (all synthesis.path/seq (if (tail? size idx) (synthesis.member/right idx) (synthesis.member/left idx)) subP)]] - (in [caseS caseP])) + (in [whenS whenP])) (do [! r.monad] [size ..size idx (|> r.nat (at ! each (n.% size))) - [subS subP] case + [subS subP] when .let [right? (tail? size idx) - caseS (synthesis.variant + whenS (synthesis.variant [analysis.#lefts idx analysis.#right? right? analysis.#value subS]) - caseP (all synthesis.path/seq + whenP (all synthesis.path/seq (if right? (synthesis.side/right idx) (synthesis.side/left idx)) subP)]] - (in [caseS caseP])) + (in [whenS whenP])) )))) (def (let_spec run) @@ -123,21 +123,21 @@ (run "if_spec") (verify (if verdict on_true on_false)))))) -(def (case_spec run) +(def (when_spec run) (-> Runner Test) (do r.monad - [[inputS pathS] ..case + [[inputS pathS] ..when on_success r.safe_frac on_failure (|> r.safe_frac (r.only (|>> (f.= on_success) not)))] - (_.test (%.symbol (symbol synthesis.branch/case)) - (|> (synthesis.branch/case + (_.test (%.symbol (symbol synthesis.branch/when)) + (|> (synthesis.branch/when [inputS (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") + (run "when_spec") (verify on_success))))) (def special_input @@ -233,7 +233,7 @@ (<| try.trusted (phase.result [extension/synthesis.bundle synthesis.init]) - (case.path phase/synthesis.phase + (when.path phase/synthesis.phase special_pattern) (analysis.bit #1)) (all synthesis.path/seq @@ -252,27 +252,27 @@ (_.test "CODE" (|> special_input (run "special_input") - (pipe.case + (pipe.when {try.#Success output} true {try.#Failure _} false))) (_.test "PATTERN_MATCHING 0" - (|> (synthesis.branch/case [special_input + (|> (synthesis.branch/when [special_input special_path]) (run "special_path") - (pipe.case + (pipe.when {try.#Success output} true {try.#Failure _} false))) (_.test "PATTERN_MATCHING 1" - (|> (synthesis.branch/case [special_input + (|> (synthesis.branch/when [special_input special_pattern_path]) (run "special_pattern_path") - (pipe.case + (pipe.when {try.#Success output} true @@ -286,5 +286,5 @@ (..special_spec run) (..let_spec run) (..if_spec run) - (..case_spec run) + (..when_spec run) )) -- cgit v1.2.3