diff options
author | Eduardo Julian | 2022-06-12 13:33:48 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-12 13:33:48 -0400 |
commit | 8c3a1afab9efeb86e2f53d743551fc689fbad257 (patch) | |
tree | 396b2fd29bac407544d2136a0d9e6e3b8b2c30af /stdlib/source/library/lux/tool/compiler | |
parent | 9c21fd1f33eb52fb971d493ad21a67036d68b841 (diff) |
De-sigil-ification: suffix : [Part 4]
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler')
20 files changed, 583 insertions, 583 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 7563bce90..669484890 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -72,47 +72,47 @@ (type: .public Match (Match' Analysis)) -(implementation: (branch_equivalence equivalence) +(def: (branch_equivalence equivalence) (-> (Equivalence Analysis) (Equivalence Branch)) + (implementation + (def: (= [reference_pattern reference_body] [sample_pattern sample_body]) + (and (at /pattern.equivalence = reference_pattern sample_pattern) + (at equivalence = reference_body sample_body))))) - (def: (= [reference_pattern reference_body] [sample_pattern sample_body]) - (and (at /pattern.equivalence = reference_pattern sample_pattern) - (at equivalence = reference_body sample_body)))) - -(implementation: .public equivalence +(def: .public equivalence (Equivalence Analysis) - - (def: (= reference sample) - (.case [reference sample] - [{#Simple reference} {#Simple sample}] - (at /simple.equivalence = reference sample) - - [{#Structure reference} {#Structure sample}] - (at (/complex.equivalence =) = reference sample) - - [{#Reference reference} {#Reference sample}] - (at reference.equivalence = reference sample) - - [{#Case [reference_analysis reference_match]} - {#Case [sample_analysis sample_match]}] - (and (= reference_analysis sample_analysis) - (at (list.equivalence (branch_equivalence =)) = {.#Item reference_match} {.#Item sample_match})) - - [{#Function [reference_environment reference_analysis]} - {#Function [sample_environment sample_analysis]}] - (and (= reference_analysis sample_analysis) - (at (list.equivalence =) = reference_environment sample_environment)) - - [{#Apply [reference_input reference_abstraction]} - {#Apply [sample_input sample_abstraction]}] - (and (= reference_input sample_input) - (= reference_abstraction sample_abstraction)) - - [{#Extension reference} {#Extension sample}] - (at (extension.equivalence =) = reference sample) - - _ - false))) + (implementation + (def: (= reference sample) + (.case [reference sample] + [{#Simple reference} {#Simple sample}] + (at /simple.equivalence = reference sample) + + [{#Structure reference} {#Structure sample}] + (at (/complex.equivalence =) = reference sample) + + [{#Reference reference} {#Reference sample}] + (at reference.equivalence = reference sample) + + [{#Case [reference_analysis reference_match]} + {#Case [sample_analysis sample_match]}] + (and (= reference_analysis sample_analysis) + (at (list.equivalence (branch_equivalence =)) = {.#Item reference_match} {.#Item sample_match})) + + [{#Function [reference_environment reference_analysis]} + {#Function [sample_environment sample_analysis]}] + (and (= reference_analysis sample_analysis) + (at (list.equivalence =) = reference_environment sample_environment)) + + [{#Apply [reference_input reference_abstraction]} + {#Apply [sample_input sample_abstraction]}] + (and (= reference_input sample_input) + (= reference_abstraction sample_abstraction)) + + [{#Extension reference} {#Extension sample}] + (at (extension.equivalence =) = reference sample) + + _ + false)))) (with_template [<name> <tag>] [(def: .public <name> diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux index 8727b6852..9be2aa322 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux @@ -49,41 +49,41 @@ [(..lefts right? pick) right?])) -(implementation: .public (equivalence (open "/#[0]")) +(def: .public (equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Complex a)))) - - (def: (= reference sample) - (case [reference sample] - [{#Variant [reference_lefts reference_right? reference_value]} - {#Variant [sample_lefts sample_right? sample_value]}] - (and (n.= reference_lefts sample_lefts) - (bit#= reference_right? sample_right?) - (/#= reference_value sample_value)) - - [{#Tuple reference} {#Tuple sample}] - (at (list.equivalence /#=) = reference sample) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Variant [reference_lefts reference_right? reference_value]} + {#Variant [sample_lefts sample_right? sample_value]}] + (and (n.= reference_lefts sample_lefts) + (bit#= reference_right? sample_right?) + (/#= reference_value sample_value)) + + [{#Tuple reference} {#Tuple sample}] + (at (list.equivalence /#=) = reference sample) - _ - false))) + _ + false)))) -(implementation: .public (hash super) +(def: .public (hash super) (All (_ a) (-> (Hash a) (Hash (Complex a)))) - - (def: equivalence - (..equivalence (at super equivalence))) - - (def: (hash value) - (case value - {#Variant [lefts right? value]} - (all n.* 2 - (at n.hash hash lefts) - (at bit.hash hash right?) - (at super hash value)) - - {#Tuple members} - (all n.* 3 - (at (list.hash super) hash members)) - ))) + (implementation + (def: equivalence + (..equivalence (at super equivalence))) + + (def: (hash value) + (case value + {#Variant [lefts right? value]} + (all n.* 2 + (at n.hash hash lefts) + (at bit.hash hash right?) + (at super hash value)) + + {#Tuple members} + (all n.* 3 + (at (list.hash super) hash members)) + )))) (def: .public (format %it it) (All (_ a) (-> (Format a) (Format (Complex a)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux index cbb1e7ea4..f7d2734bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux @@ -79,44 +79,44 @@ _ (list coverage))) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Coverage) - - (def: (= reference sample) - (case [reference sample] - [{#Exhaustive} {#Exhaustive}] - #1 - - [{#Bit sideR} {#Bit sideS}] - (bit#= sideR sideS) - - (^.with_template [<tag>] - [[{<tag> partialR} {<tag> partialS}] - (set#= partialR partialS)]) - ([#Nat] - [#Int] - [#Rev] - [#Frac] - [#Text]) - - [{#Variant allR casesR} {#Variant allS casesS}] - (and (at (maybe.equivalence n.equivalence) = allR allS) - (at (dictionary.equivalence =) = casesR casesS)) - - [{#Seq leftR rightR} {#Seq leftS rightS}] - (and (= leftR leftS) - (= rightR rightS)) - - [{#Alt _} {#Alt _}] - (let [flatR (alternatives reference) - flatS (alternatives sample)] - (and (n.= (list.size flatR) (list.size flatS)) - (list.every? (function (_ [coverageR coverageS]) - (= coverageR coverageS)) - (list.zipped_2 flatR flatS)))) - - _ - #0))) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Exhaustive} {#Exhaustive}] + #1 + + [{#Bit sideR} {#Bit sideS}] + (bit#= sideR sideS) + + (^.with_template [<tag>] + [[{<tag> partialR} {<tag> partialS}] + (set#= partialR partialS)]) + ([#Nat] + [#Int] + [#Rev] + [#Frac] + [#Text]) + + [{#Variant allR casesR} {#Variant allS casesS}] + (and (at (maybe.equivalence n.equivalence) = allR allS) + (at (dictionary.equivalence =) = casesR casesS)) + + [{#Seq leftR rightR} {#Seq leftS rightS}] + (and (= leftR leftS) + (= rightR rightS)) + + [{#Alt _} {#Alt _}] + (let [flatR (alternatives reference) + flatS (alternatives sample)] + (and (n.= (list.size flatR) (list.size flatS)) + (list.every? (function (_ [coverageR coverageS]) + (= coverageR coverageS)) + (list.zipped_2 flatR flatS)))) + + _ + #0)))) (open: "/#[0]" ..equivalence) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux index 23f8796db..3209261d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -23,22 +23,22 @@ {#Complex (Complex Pattern)} {#Bind Register}))) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Pattern) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Simple reference} {#Simple sample}] + (at //simple.equivalence = reference sample) + + [{#Complex reference} {#Complex sample}] + (at (//complex.equivalence =) = reference sample) - (def: (= reference sample) - (case [reference sample] - [{#Simple reference} {#Simple sample}] - (at //simple.equivalence = reference sample) - - [{#Complex reference} {#Complex sample}] - (at (//complex.equivalence =) = reference sample) + [{#Bind reference} {#Bind sample}] + (n.= reference sample) - [{#Bind reference} {#Bind sample}] - (n.= reference sample) - - _ - false))) + _ + false)))) (def: .public (format it) (%.Format Pattern) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux index e9d2d8b87..8001696c1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux @@ -26,26 +26,26 @@ {#Frac Frac} {#Text Text})) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Simple) - - (def: (= reference sample) - (case [reference sample] - [{#Unit} {#Unit}] - true - - (^.with_template [<tag> <=>] - [[{<tag> reference} {<tag> sample}] - (<=> reference sample)]) - ([#Bit bit#=] - [#Nat n.=] - [#Int i.=] - [#Rev r.=] - [#Frac f.=] - [#Text text#=]) - - _ - false))) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Unit} {#Unit}] + true + + (^.with_template [<tag> <=>] + [[{<tag> reference} {<tag> sample}] + (<=> reference sample)]) + ([#Bit bit#=] + [#Nat n.=] + [#Int i.=] + [#Rev r.=] + [#Frac f.=] + [#Text text#=]) + + _ + false)))) (def: .public (format it) (Format Simple) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux index 85228162f..b64f9ecbb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System (Expression Any)) - - (def: constant _.var) - (def: variable _.var)) + (implementation + (def: constant _.var) + (def: variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux index 68a3376c5..8a042db48 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant' _.var) - (def: variable' _.var)) + (implementation + (def: constant' _.var) + (def: variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux index 84c1dab75..d98a16050 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant' _.var) - (def: variable' _.var)) + (implementation + (def: constant' _.var) + (def: variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux index 68332a0ee..1fb4ce3e2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant _.global) - (def: variable _.var)) + (implementation + (def: constant _.global) + (def: variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux index 607b7127f..47b64cd94 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System (Expression Any)) - - (def: constant' _.var) - (def: variable' _.var)) + (implementation + (def: constant' _.var) + (def: variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux index fffaab6b8..5a37d97b7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant _.var) - (def: variable _.var)) + (implementation + (def: constant _.var) + (def: variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux index 84558a49f..b464719fc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant' _.global) - (def: variable' _.local)) + (implementation + (def: constant' _.global) + (def: variable' _.local))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux index 2f04921ed..7e0b61970 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(implementation: .public system +(def: .public system (System Expression) - - (def: constant _.var) - (def: variable _.var)) + (implementation + (def: constant _.var) + (def: variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 831374079..726b4f3bf 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -417,303 +417,303 @@ (Format Path) (%path' %synthesis)) -(implementation: .public (path'_equivalence equivalence) +(def: .public (path'_equivalence equivalence) (All (_ a) (-> (Equivalence a) (Equivalence (Path' a)))) - - (def: (= reference sample) - (case [reference sample] - [{#Pop} {#Pop}] - true - - [{#Bit_Fork reference_when reference_then reference_else} - {#Bit_Fork sample_when sample_then sample_else}] - (and (bit#= reference_when sample_when) - (= reference_then sample_then) - (at (maybe.equivalence =) = reference_else sample_else)) - - (^.with_template [<tag> <equivalence>] - [[{<tag> reference_item} - {<tag> sample_item}] - (at (list.equivalence (product.equivalence <equivalence> =)) = - {.#Item reference_item} - {.#Item sample_item})]) - ([#I64_Fork (is (Equivalence I64) i64.equivalence)] - [#F64_Fork f.equivalence] - [#Text_Fork text.equivalence]) - - (^.with_template [<tag> <equivalence>] - [[{<tag> reference'} {<tag> sample'}] - (at <equivalence> = reference' sample')]) - ([#Access /access.equivalence] - [#Then equivalence]) - - [{#Bind reference'} {#Bind sample'}] - (n.= reference' sample') - - (^.with_template [<tag>] - [[{<tag> leftR rightR} {<tag> leftS rightS}] - (and (= leftR leftS) - (= rightR rightS))]) - ([#Alt] - [#Seq]) - - _ - false))) - -(implementation: (path'_hash super) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Pop} {#Pop}] + true + + [{#Bit_Fork reference_when reference_then reference_else} + {#Bit_Fork sample_when sample_then sample_else}] + (and (bit#= reference_when sample_when) + (= reference_then sample_then) + (at (maybe.equivalence =) = reference_else sample_else)) + + (^.with_template [<tag> <equivalence>] + [[{<tag> reference_item} + {<tag> sample_item}] + (at (list.equivalence (product.equivalence <equivalence> =)) = + {.#Item reference_item} + {.#Item sample_item})]) + ([#I64_Fork (is (Equivalence I64) i64.equivalence)] + [#F64_Fork f.equivalence] + [#Text_Fork text.equivalence]) + + (^.with_template [<tag> <equivalence>] + [[{<tag> reference'} {<tag> sample'}] + (at <equivalence> = reference' sample')]) + ([#Access /access.equivalence] + [#Then equivalence]) + + [{#Bind reference'} {#Bind sample'}] + (n.= reference' sample') + + (^.with_template [<tag>] + [[{<tag> leftR rightR} {<tag> leftS rightS}] + (and (= leftR leftS) + (= rightR rightS))]) + ([#Alt] + [#Seq]) + + _ + false)))) + +(def: (path'_hash super) (All (_ a) (-> (Hash a) (Hash (Path' a)))) - - (def: equivalence - (..path'_equivalence (at super equivalence))) - - (def: (hash value) - (case value - {#Pop} - 2 - - {#Access access} - (n.* 3 (at /access.hash hash access)) - - {#Bind register} - (n.* 5 (at n.hash hash register)) - - {#Bit_Fork when then else} - (all n.* 7 - (at bit.hash hash when) - (hash then) - (at (maybe.hash (path'_hash super)) hash else)) - - (^.with_template [<factor> <tag> <hash>] - [{<tag> item} - (let [case_hash (product.hash <hash> - (path'_hash super)) - item_hash (product.hash case_hash (list.hash case_hash))] - (n.* <factor> (at item_hash hash item)))]) - ([11 #I64_Fork i64.hash] - [13 #F64_Fork f.hash] - [17 #Text_Fork text.hash]) - - (^.with_template [<factor> <tag>] - [{<tag> fork} - (let [again_hash (path'_hash super) - fork_hash (product.hash again_hash again_hash)] - (n.* <factor> (at fork_hash hash fork)))]) - ([19 #Alt] - [23 #Seq]) - - {#Then body} - (n.* 29 (at super hash body)) - ))) - -(implementation: (branch_equivalence (open "#[0]")) + (implementation + (def: equivalence + (..path'_equivalence (at super equivalence))) + + (def: (hash value) + (case value + {#Pop} + 2 + + {#Access access} + (n.* 3 (at /access.hash hash access)) + + {#Bind register} + (n.* 5 (at n.hash hash register)) + + {#Bit_Fork when then else} + (all n.* 7 + (at bit.hash hash when) + (hash then) + (at (maybe.hash (path'_hash super)) hash else)) + + (^.with_template [<factor> <tag> <hash>] + [{<tag> item} + (let [case_hash (product.hash <hash> + (path'_hash super)) + item_hash (product.hash case_hash (list.hash case_hash))] + (n.* <factor> (at item_hash hash item)))]) + ([11 #I64_Fork i64.hash] + [13 #F64_Fork f.hash] + [17 #Text_Fork text.hash]) + + (^.with_template [<factor> <tag>] + [{<tag> fork} + (let [again_hash (path'_hash super) + fork_hash (product.hash again_hash again_hash)] + (n.* <factor> (at fork_hash hash fork)))]) + ([19 #Alt] + [23 #Seq]) + + {#Then body} + (n.* 29 (at super hash body)) + )))) + +(def: (branch_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Branch a)))) - - (def: (= reference sample) - (case [reference sample] - [{#Let [reference_input reference_register reference_body]} - {#Let [sample_input sample_register sample_body]}] - (and (#= reference_input sample_input) - (n.= reference_register sample_register) - (#= reference_body sample_body)) - - [{#If [reference_test reference_then reference_else]} - {#If [sample_test sample_then sample_else]}] - (and (#= reference_test sample_test) - (#= reference_then sample_then) - (#= reference_else sample_else)) - - [{#Get [reference_path reference_record]} - {#Get [sample_path sample_record]}] - (and (at (list.equivalence /member.equivalence) = reference_path sample_path) - (#= reference_record sample_record)) - - [{#Case [reference_input reference_path]} - {#Case [sample_input sample_path]}] - (and (#= reference_input sample_input) - (at (path'_equivalence #=) = reference_path sample_path)) - - _ - false))) - -(implementation: (branch_hash super) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Let [reference_input reference_register reference_body]} + {#Let [sample_input sample_register sample_body]}] + (and (#= reference_input sample_input) + (n.= reference_register sample_register) + (#= reference_body sample_body)) + + [{#If [reference_test reference_then reference_else]} + {#If [sample_test sample_then sample_else]}] + (and (#= reference_test sample_test) + (#= reference_then sample_then) + (#= reference_else sample_else)) + + [{#Get [reference_path reference_record]} + {#Get [sample_path sample_record]}] + (and (at (list.equivalence /member.equivalence) = reference_path sample_path) + (#= reference_record sample_record)) + + [{#Case [reference_input reference_path]} + {#Case [sample_input sample_path]}] + (and (#= reference_input sample_input) + (at (path'_equivalence #=) = reference_path sample_path)) + + _ + false)))) + +(def: (branch_hash super) (All (_ a) (-> (Hash a) (Hash (Branch a)))) - - (def: equivalence - (..branch_equivalence (at super equivalence))) - - (def: (hash value) - (case value - {#Exec this that} - (all n.* 2 - (at super hash this) - (at super hash that)) - - {#Let [input register body]} - (all n.* 3 - (at super hash input) - (at n.hash hash register) - (at super hash body)) - - {#If [test then else]} - (all n.* 5 - (at super hash test) - (at super hash then) - (at super hash else)) - - {#Get [path record]} - (all n.* 7 - (at (list.hash /member.hash) hash path) - (at super hash record)) - - {#Case [input path]} - (all n.* 11 - (at super hash input) - (at (..path'_hash super) hash path)) - ))) - -(implementation: (loop_equivalence (open "/#[0]")) + (implementation + (def: equivalence + (..branch_equivalence (at super equivalence))) + + (def: (hash value) + (case value + {#Exec this that} + (all n.* 2 + (at super hash this) + (at super hash that)) + + {#Let [input register body]} + (all n.* 3 + (at super hash input) + (at n.hash hash register) + (at super hash body)) + + {#If [test then else]} + (all n.* 5 + (at super hash test) + (at super hash then) + (at super hash else)) + + {#Get [path record]} + (all n.* 7 + (at (list.hash /member.hash) hash path) + (at super hash record)) + + {#Case [input path]} + (all n.* 11 + (at super hash input) + (at (..path'_hash super) hash path)) + )))) + +(def: (loop_equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Loop a)))) - - (def: (= reference sample) - (case [reference sample] - [{#Scope [reference_start reference_inits reference_iteration]} - {#Scope [sample_start sample_inits sample_iteration]}] - (and (n.= reference_start sample_start) - (at (list.equivalence /#=) = reference_inits sample_inits) - (/#= reference_iteration sample_iteration)) - - [{#Again reference} {#Again sample}] - (at (list.equivalence /#=) = reference sample) - - _ - false))) - -(implementation: (loop_hash super) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Scope [reference_start reference_inits reference_iteration]} + {#Scope [sample_start sample_inits sample_iteration]}] + (and (n.= reference_start sample_start) + (at (list.equivalence /#=) = reference_inits sample_inits) + (/#= reference_iteration sample_iteration)) + + [{#Again reference} {#Again sample}] + (at (list.equivalence /#=) = reference sample) + + _ + false)))) + +(def: (loop_hash super) (All (_ a) (-> (Hash a) (Hash (Loop a)))) - - (def: equivalence - (..loop_equivalence (at super equivalence))) - - (def: (hash value) - (case value - {#Scope [start inits iteration]} - (all n.* 2 - (at n.hash hash start) - (at (list.hash super) hash inits) - (at super hash iteration)) - - {#Again resets} - (all n.* 3 - (at (list.hash super) hash resets)) - ))) - -(implementation: (function_equivalence (open "#[0]")) + (implementation + (def: equivalence + (..loop_equivalence (at super equivalence))) + + (def: (hash value) + (case value + {#Scope [start inits iteration]} + (all n.* 2 + (at n.hash hash start) + (at (list.hash super) hash inits) + (at super hash iteration)) + + {#Again resets} + (all n.* 3 + (at (list.hash super) hash resets)) + )))) + +(def: (function_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Function a)))) - - (def: (= reference sample) - (case [reference sample] - [{#Abstraction [reference_environment reference_arity reference_body]} - {#Abstraction [sample_environment sample_arity sample_body]}] - (and (at (list.equivalence #=) = reference_environment sample_environment) - (n.= reference_arity sample_arity) - (#= reference_body sample_body)) - - [{#Apply [reference_abstraction reference_arguments]} - {#Apply [sample_abstraction sample_arguments]}] - (and (#= reference_abstraction sample_abstraction) - (at (list.equivalence #=) = reference_arguments sample_arguments)) - - _ - false))) - -(implementation: (function_hash super) + (implementation + (def: (= reference sample) + (case [reference sample] + [{#Abstraction [reference_environment reference_arity reference_body]} + {#Abstraction [sample_environment sample_arity sample_body]}] + (and (at (list.equivalence #=) = reference_environment sample_environment) + (n.= reference_arity sample_arity) + (#= reference_body sample_body)) + + [{#Apply [reference_abstraction reference_arguments]} + {#Apply [sample_abstraction sample_arguments]}] + (and (#= reference_abstraction sample_abstraction) + (at (list.equivalence #=) = reference_arguments sample_arguments)) + + _ + false)))) + +(def: (function_hash super) (All (_ a) (-> (Hash a) (Hash (Function a)))) - - (def: equivalence - (..function_equivalence (at super equivalence))) - - (def: (hash value) - (case value - {#Abstraction [environment arity body]} - (all n.* 2 - (at (list.hash super) hash environment) - (at n.hash hash arity) - (at super hash body)) - - {#Apply [abstraction arguments]} - (all n.* 3 - (at super hash abstraction) - (at (list.hash super) hash arguments)) - ))) - -(implementation: (control_equivalence (open "#[0]")) + (implementation + (def: equivalence + (..function_equivalence (at super equivalence))) + + (def: (hash value) + (case value + {#Abstraction [environment arity body]} + (all n.* 2 + (at (list.hash super) hash environment) + (at n.hash hash arity) + (at super hash body)) + + {#Apply [abstraction arguments]} + (all n.* 3 + (at super hash abstraction) + (at (list.hash super) hash arguments)) + )))) + +(def: (control_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Control a)))) - - (def: (= reference sample) - (case [reference sample] - (^.with_template [<tag> <equivalence>] - [[{<tag> reference} {<tag> sample}] - (at (<equivalence> #=) = reference sample)]) - ([#Branch ..branch_equivalence] - [#Loop ..loop_equivalence] - [#Function ..function_equivalence]) - - _ - false))) - -(implementation: (control_hash super) + (implementation + (def: (= reference sample) + (case [reference sample] + (^.with_template [<tag> <equivalence>] + [[{<tag> reference} {<tag> sample}] + (at (<equivalence> #=) = reference sample)]) + ([#Branch ..branch_equivalence] + [#Loop ..loop_equivalence] + [#Function ..function_equivalence]) + + _ + false)))) + +(def: (control_hash super) (All (_ a) (-> (Hash a) (Hash (Control a)))) - - (def: equivalence - (..control_equivalence (at super equivalence))) - - (def: (hash value) - (case value - (^.with_template [<factor> <tag> <hash>] - [{<tag> value} - (n.* <factor> (at (<hash> super) hash value))]) - ([2 #Branch ..branch_hash] - [3 #Loop ..loop_hash] - [5 #Function ..function_hash]) - ))) - -(implementation: .public equivalence + (implementation + (def: equivalence + (..control_equivalence (at super equivalence))) + + (def: (hash value) + (case value + (^.with_template [<factor> <tag> <hash>] + [{<tag> value} + (n.* <factor> (at (<hash> super) hash value))]) + ([2 #Branch ..branch_hash] + [3 #Loop ..loop_hash] + [5 #Function ..function_hash]) + )))) + +(def: .public equivalence (Equivalence Synthesis) - - (def: (= reference sample) - (case [reference sample] - (^.with_template [<tag> <equivalence>] - [[{<tag> reference'} {<tag> sample'}] - (at <equivalence> = reference' sample')]) - ([#Simple /simple.equivalence] - [#Structure (analysis/complex.equivalence =)] - [#Reference reference.equivalence] - [#Control (control_equivalence =)] - [#Extension (extension.equivalence =)]) - - _ - false))) + (implementation + (def: (= reference sample) + (case [reference sample] + (^.with_template [<tag> <equivalence>] + [[{<tag> reference'} {<tag> sample'}] + (at <equivalence> = reference' sample')]) + ([#Simple /simple.equivalence] + [#Structure (analysis/complex.equivalence =)] + [#Reference reference.equivalence] + [#Control (control_equivalence =)] + [#Extension (extension.equivalence =)]) + + _ + false)))) (def: .public path_equivalence (Equivalence Path) (path'_equivalence equivalence)) -(implementation: .public hash +(def: .public hash (Hash Synthesis) - - (def: equivalence ..equivalence) - - (def: (hash value) - (let [again_hash [..equivalence hash]] - (case value - (^.with_template [<tag> <hash>] - [{<tag> value} - (at <hash> hash value)]) - ([#Simple /simple.hash] - [#Structure (analysis/complex.hash again_hash)] - [#Reference reference.hash] - [#Control (..control_hash again_hash)] - [#Extension (extension.hash again_hash)]))))) + (implementation + (def: equivalence ..equivalence) + + (def: (hash value) + (let [again_hash [..equivalence hash]] + (case value + (^.with_template [<tag> <hash>] + [{<tag> value} + (at <hash> hash value)]) + ([#Simple /simple.hash] + [#Structure (analysis/complex.hash again_hash)] + [#Reference reference.hash] + [#Control (..control_hash again_hash)] + [#Extension (extension.hash again_hash)])))))) (def: .public !bind_top (template (!bind_top register thenP) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux index 6a6e4b3b0..d9e04bdef 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux @@ -39,35 +39,35 @@ {#I64 value} (%.int (.int value)))) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Simple) - - (def: (= reference sample) - (case [reference sample] - (^.with_template [<tag> <eq> <format>] - [[{<tag> reference'} {<tag> sample'}] - (<eq> reference' sample')]) - ([#Bit bit#= %.bit] - [#F64 f.= %.frac] - [#Text text#= %.text]) + (implementation + (def: (= reference sample) + (case [reference sample] + (^.with_template [<tag> <eq> <format>] + [[{<tag> reference'} {<tag> sample'}] + (<eq> reference' sample')]) + ([#Bit bit#= %.bit] + [#F64 f.= %.frac] + [#Text text#= %.text]) - [{#I64 reference'} {#I64 sample'}] - (i64#= reference' sample') + [{#I64 reference'} {#I64 sample'}] + (i64#= reference' sample') - _ - false))) + _ + false)))) -(implementation: .public hash +(def: .public hash (Hash Simple) + (implementation + (def: equivalence ..equivalence) - (def: equivalence ..equivalence) - - (def: hash - (|>> (pipe.case - (^.with_template [<factor> <tag> <hash>] - [{<tag> value'} - (n.* <factor> (at <hash> hash value'))]) - ([2 #Bit bit.hash] - [3 #F64 f.hash] - [5 #Text text.hash] - [7 #I64 i64.hash]))))) + (def: hash + (|>> (pipe.case + (^.with_template [<factor> <tag> <hash>] + [{<tag> value'} + (n.* <factor> (at <hash> hash value'))]) + ([2 #Bit bit.hash] + [3 #F64 f.hash] + [5 #Text text.hash] + [7 #I64 i64.hash])))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux index a3780a1b8..9e00a5b51 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux @@ -40,25 +40,25 @@ {#Directive Text} {#Custom Text})) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Category) - - (def: (= left right) - (case [left right] - [{#Anonymous} {#Anonymous}] - true + (implementation + (def: (= left right) + (case [left right] + [{#Anonymous} {#Anonymous}] + true - [{#Definition left} {#Definition right}] - (at definition_equivalence = left right) - - (^.with_template [<tag>] - [[{<tag> left} {<tag> right}] - (text#= left right)]) - ([#Analyser] - [#Synthesizer] - [#Generator] - [#Directive] - [#Custom]) + [{#Definition left} {#Definition right}] + (at definition_equivalence = left right) + + (^.with_template [<tag>] + [[{<tag> left} {<tag> right}] + (text#= left right)]) + ([#Analyser] + [#Synthesizer] + [#Generator] + [#Directive] + [#Custom]) - _ - false))) + _ + false)))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux index bc35ee361..702be60b8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux @@ -36,20 +36,20 @@ #state Module_State #references (Set Module)])) -(implementation: module_state_equivalence +(def: module_state_equivalence (Equivalence Module_State) - - (def: (= left right) - (case [left right] - (^.with_template [<tag>] - [[{<tag>} {<tag>}] - true]) - ([.#Active] - [.#Compiled] - [.#Cached]) + (implementation + (def: (= left right) + (case [left right] + (^.with_template [<tag>] + [[{<tag>} {<tag>}] + true]) + ([.#Active] + [.#Compiled] + [.#Cached]) - _ - false))) + _ + false)))) (def: .public equivalence (Equivalence Descriptor) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 48b08b54b..26e6e7637 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -23,35 +23,35 @@ (type: .public (Operation s o) (state.+State Try s o)) -(implementation: .public functor +(def: .public functor (All (_ s) (Functor (Operation s))) - - (def: (each f it) - (function (_ state) - (case (it state) - {try.#Success [state' output]} - {try.#Success [state' (f output)]} - - {try.#Failure error} - {try.#Failure error})))) - -(implementation: .public monad + (implementation + (def: (each f it) + (function (_ state) + (case (it state) + {try.#Success [state' output]} + {try.#Success [state' (f output)]} + + {try.#Failure error} + {try.#Failure error}))))) + +(def: .public monad (All (_ s) (Monad (Operation s))) - - (def: functor ..functor) - - (def: (in it) - (function (_ state) - {try.#Success [state it]})) - - (def: (conjoint it) - (function (_ state) - (case (it state) - {try.#Success [state' it']} - (it' state') - - {try.#Failure error} - {try.#Failure error})))) + (implementation + (def: functor ..functor) + + (def: (in it) + (function (_ state) + {try.#Success [state it]})) + + (def: (conjoint it) + (function (_ state) + (case (it state) + {try.#Success [state' it']} + (it' state') + + {try.#Failure error} + {try.#Failure error}))))) (type: .public (Phase s i o) (-> Archive i (Operation s o))) diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index cd028073c..33940e6f7 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -27,36 +27,36 @@ {#Variable Variable} {#Constant Constant})) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Reference) + (implementation + (def: (= reference sample) + (case [reference sample] + (^.with_template [<tag> <equivalence>] + [[{<tag> reference} {<tag> sample}] + (at <equivalence> = reference sample)]) + ([#Variable /variable.equivalence] + [#Constant symbol.equivalence]) - (def: (= reference sample) - (case [reference sample] - (^.with_template [<tag> <equivalence>] - [[{<tag> reference} {<tag> sample}] - (at <equivalence> = reference sample)]) - ([#Variable /variable.equivalence] - [#Constant symbol.equivalence]) + _ + false)))) - _ - false))) - -(implementation: .public hash +(def: .public hash (Hash Reference) + (implementation + (def: equivalence + ..equivalence) - (def: equivalence - ..equivalence) - - (def: (hash value) - (case value - (^.with_template [<factor> <tag> <hash>] - [{<tag> value} - (|> value - (at <hash> hash) - (n.* <factor>))]) - ([2 #Variable /variable.hash] - [3 #Constant symbol.hash]) - ))) + (def: (hash value) + (case value + (^.with_template [<factor> <tag> <hash>] + [{<tag> value} + (|> value + (at <hash> hash) + (n.* <factor>))]) + ([2 #Variable /variable.hash] + [3 #Constant symbol.hash]) + )))) (with_template [<name> <family> <tag>] [(def: .public <name> diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index ad3be0e06..787f15e9f 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -24,34 +24,34 @@ {#Local Register} {#Foreign Register})) -(implementation: .public equivalence +(def: .public equivalence (Equivalence Variable) - - (def: (= reference sample) - (case [reference sample] - (^.with_template [<tag>] - [[{<tag> reference'} {<tag> sample'}] - (n.= reference' sample')]) - ([#Local] [#Foreign]) + (implementation + (def: (= reference sample) + (case [reference sample] + (^.with_template [<tag>] + [[{<tag> reference'} {<tag> sample'}] + (n.= reference' sample')]) + ([#Local] [#Foreign]) - _ - #0))) + _ + #0)))) -(implementation: .public hash +(def: .public hash (Hash Variable) - - (def: equivalence - ..equivalence) - - (def: hash - (|>> (pipe.case - (^.with_template [<factor> <tag>] - [{<tag> register} - (|> register - (at n.hash hash) - (n.* <factor>))]) - ([2 #Local] - [3 #Foreign]))))) + (implementation + (def: equivalence + ..equivalence) + + (def: hash + (|>> (pipe.case + (^.with_template [<factor> <tag>] + [{<tag> register} + (|> register + (at n.hash hash) + (n.* <factor>))]) + ([2 #Local] + [3 #Foreign])))))) (def: .public self (template (self) |