From b8e44ec6ee38d3f67b7e3c3989de51b03e7a1352 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Jul 2018 00:34:35 -0400 Subject: - Re-named "equality" to "equivalence". --- stdlib/source/lux.lux | 22 +-- stdlib/source/lux/cli.lux | 2 +- stdlib/source/lux/control/equality.lux | 30 ----- stdlib/source/lux/control/equivalence.lux | 30 +++++ stdlib/source/lux/control/hash.lux | 4 +- stdlib/source/lux/control/interval.lux | 6 +- stdlib/source/lux/control/order.lux | 6 +- stdlib/source/lux/data/bool.lux | 6 +- stdlib/source/lux/data/coll/array.lux | 8 +- stdlib/source/lux/data/coll/bits.lux | 4 +- stdlib/source/lux/data/coll/dictionary/ordered.lux | 10 +- stdlib/source/lux/data/coll/dictionary/plist.lux | 2 +- .../source/lux/data/coll/dictionary/unordered.lux | 6 +- stdlib/source/lux/data/coll/list.lux | 10 +- stdlib/source/lux/data/coll/queue.lux | 16 +-- stdlib/source/lux/data/coll/queue/priority.lux | 8 +- stdlib/source/lux/data/coll/row.lux | 18 +-- stdlib/source/lux/data/coll/set/ordered.lux | 6 +- stdlib/source/lux/data/coll/set/unordered.lux | 8 +- stdlib/source/lux/data/coll/tree/rose.lux | 8 +- stdlib/source/lux/data/color.lux | 4 +- stdlib/source/lux/data/format/json.lux | 18 +-- stdlib/source/lux/data/format/xml.lux | 10 +- stdlib/source/lux/data/ident.lux | 8 +- stdlib/source/lux/data/maybe.lux | 6 +- stdlib/source/lux/data/number.lux | 20 +-- stdlib/source/lux/data/number/complex.lux | 4 +- stdlib/source/lux/data/number/ratio.lux | 6 +- stdlib/source/lux/data/text.lux | 8 +- stdlib/source/lux/host.jvm.lux | 10 +- stdlib/source/lux/lang/compiler/analysis.lux | 2 +- .../lux/lang/compiler/analysis/case/coverage.lux | 12 +- .../lux/lang/compiler/analysis/reference.lux | 2 +- .../lang/compiler/extension/analysis/host.jvm.lux | 18 +-- stdlib/source/lux/lang/compiler/synthesis/case.lux | 10 +- stdlib/source/lux/lang/module.lux | 2 +- stdlib/source/lux/lang/reference.lux | 6 +- stdlib/source/lux/lang/scope.lux | 2 +- stdlib/source/lux/lang/type.lux | 8 +- stdlib/source/lux/lang/type/check.lux | 6 +- stdlib/source/lux/macro.lux | 4 +- stdlib/source/lux/macro/code.lux | 28 ++-- stdlib/source/lux/macro/poly.lux | 6 +- stdlib/source/lux/macro/poly/equality.lux | 150 --------------------- stdlib/source/lux/macro/poly/equivalence.lux | 150 +++++++++++++++++++++ stdlib/source/lux/macro/poly/json.lux | 2 +- stdlib/source/lux/macro/syntax.lux | 20 +-- stdlib/source/lux/macro/syntax/common/reader.lux | 2 +- stdlib/source/lux/time/date.lux | 20 +-- stdlib/source/lux/time/duration.lux | 8 +- stdlib/source/lux/time/instant.lux | 8 +- stdlib/source/lux/type/abstract.lux | 2 +- stdlib/source/lux/type/implicit.lux | 10 +- stdlib/source/lux/type/object/interface.lux | 2 +- stdlib/source/lux/type/refinement.lux | 2 +- stdlib/source/lux/type/unit.lux | 6 +- stdlib/source/lux/world/blob.jvm.lux | 4 +- stdlib/test/test/lux.lux | 2 +- stdlib/test/test/lux/cli.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 2 +- stdlib/test/test/lux/concurrency/semaphore.lux | 2 +- stdlib/test/test/lux/concurrency/stm.lux | 2 +- stdlib/test/test/lux/control/continuation.lux | 2 +- stdlib/test/test/lux/control/equality.lux | 19 --- stdlib/test/test/lux/control/equivalence.lux | 19 +++ stdlib/test/test/lux/control/interval.lux | 10 +- stdlib/test/test/lux/control/parser.lux | 2 +- stdlib/test/test/lux/control/pipe.lux | 2 +- stdlib/test/test/lux/control/writer.lux | 2 +- stdlib/test/test/lux/data/bool.lux | 10 +- stdlib/test/test/lux/data/coll/array.lux | 12 +- stdlib/test/test/lux/data/coll/bits.lux | 8 +- .../test/test/lux/data/coll/dictionary/ordered.lux | 12 +- .../test/lux/data/coll/dictionary/unordered.lux | 12 +- stdlib/test/test/lux/data/coll/list.lux | 12 +- stdlib/test/test/lux/data/coll/queue.lux | 12 +- stdlib/test/test/lux/data/coll/queue/priority.lux | 10 +- stdlib/test/test/lux/data/coll/row.lux | 8 +- stdlib/test/test/lux/data/coll/sequence.lux | 4 +- stdlib/test/test/lux/data/coll/set/ordered.lux | 4 +- stdlib/test/test/lux/data/coll/set/unordered.lux | 2 +- stdlib/test/test/lux/data/coll/tree/rose.lux | 6 +- .../test/test/lux/data/coll/tree/rose/zipper.lux | 4 +- stdlib/test/test/lux/data/color.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 40 +++--- stdlib/test/test/lux/data/format/xml.lux | 6 +- stdlib/test/test/lux/data/ident.lux | 8 +- stdlib/test/test/lux/data/identity.lux | 2 +- stdlib/test/test/lux/data/maybe.lux | 2 +- stdlib/test/test/lux/data/number.lux | 60 ++++----- stdlib/test/test/lux/data/sum.lux | 2 +- stdlib/test/test/lux/data/text.lux | 4 +- stdlib/test/test/lux/data/text/format.lux | 2 +- stdlib/test/test/lux/data/text/lexer.lux | 4 +- stdlib/test/test/lux/data/text/regex.lux | 2 +- stdlib/test/test/lux/host.jvm.lux | 2 +- stdlib/test/test/lux/io.lux | 2 +- .../test/test/lux/lang/compiler/analysis/case.lux | 6 +- .../test/lux/lang/compiler/analysis/function.lux | 4 +- .../test/lux/lang/compiler/analysis/primitive.lux | 2 +- .../lang/compiler/analysis/procedure/common.lux | 14 +- .../lang/compiler/analysis/procedure/host.jvm.lux | 8 +- .../test/lux/lang/compiler/analysis/reference.lux | 6 +- .../test/lux/lang/compiler/analysis/structure.lux | 4 +- .../test/lux/lang/compiler/synthesis/function.lux | 2 +- .../test/lux/lang/compiler/synthesis/structure.lux | 2 +- stdlib/test/test/lux/lang/syntax.lux | 10 +- stdlib/test/test/lux/lang/type.lux | 20 +-- stdlib/test/test/lux/lang/type/check.lux | 12 +- stdlib/test/test/lux/macro/code.lux | 4 +- stdlib/test/test/lux/macro/poly/equality.lux | 70 ---------- stdlib/test/test/lux/macro/poly/equivalence.lux | 70 ++++++++++ stdlib/test/test/lux/macro/poly/functor.lux | 17 +-- stdlib/test/test/lux/macro/syntax.lux | 28 ++-- stdlib/test/test/lux/math.lux | 2 +- stdlib/test/test/lux/math/logic/fuzzy.lux | 2 +- stdlib/test/test/lux/math/modular.lux | 4 +- stdlib/test/test/lux/math/random.lux | 2 +- stdlib/test/test/lux/time/date.lux | 14 +- stdlib/test/test/lux/time/duration.lux | 8 +- stdlib/test/test/lux/time/instant.lux | 10 +- stdlib/test/test/lux/type/implicit.lux | 10 +- stdlib/test/test/lux/world/blob.lux | 6 +- stdlib/test/test/lux/world/file.lux | 8 +- stdlib/test/test/lux/world/net/tcp.lux | 4 +- stdlib/test/test/lux/world/net/udp.lux | 4 +- 126 files changed, 731 insertions(+), 742 deletions(-) delete mode 100644 stdlib/source/lux/control/equality.lux create mode 100644 stdlib/source/lux/control/equivalence.lux delete mode 100644 stdlib/source/lux/macro/poly/equality.lux create mode 100644 stdlib/source/lux/macro/poly/equivalence.lux delete mode 100644 stdlib/test/test/lux/control/equality.lux create mode 100644 stdlib/test/test/lux/control/equivalence.lux delete mode 100644 stdlib/test/test/lux/macro/poly/equality.lux create mode 100644 stdlib/test/test/lux/macro/poly/equivalence.lux diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index d2d39783a..5a484598e 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2206,7 +2206,7 @@ (def:''' #export (n/= test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Nat(ural) equality.")]) + (text$ "Nat(ural) equivalence.")]) (-> Nat Nat Bool) ("lux i64 =" test subject)) @@ -2296,7 +2296,7 @@ (def:''' #export (r/= test subject) (list [(tag$ ["lux" "doc"]) - (text$ "Rev(olution) equality.")]) + (text$ "Rev(olution) equivalence.")]) (-> Rev Rev Bool) ("lux i64 =" test subject)) @@ -2368,10 +2368,10 @@ ( subject test)))] [ Int "lux i64 =" "lux int <" i/= i/< i/<= i/> i/>= - "Int(eger) equality." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."] + "Int(eger) equivalence." "Int(eger) less-than." "Int(eger) less-than-equal." "Int(eger) greater-than." "Int(eger) greater-than-equal."] [Frac "lux frac =" "lux frac <" f/= f/< f/<= f/> f/>= - "Frac(tion) equality." "Frac(tion) less-than." "Frac(tion) less-than-equal." "Frac(tion) greater-than." "Frac(tion) greater-than-equal."] + "Frac(tion) equivalence." "Frac(tion) less-than." "Frac(tion) less-than-equal." "Frac(tion) greater-than." "Frac(tion) greater-than-equal."] ) (def:''' #export (n// param subject) @@ -3492,7 +3492,7 @@ (macro: #export (sig: tokens) {#.doc "## Definition of signatures ala ML. (sig: #export (Ord a) - (: (Eq a) + (: (Equivalence a) eq) (: (-> a a Bool) <) @@ -3901,7 +3901,7 @@ (macro: #export (struct: tokens) {#.doc "## Definition of structures ala ML. (struct: #export Ord (Ord Int) - (def: eq Eq) + (def: eq Equivalence) (def: (< test subject) (lux.< test subject)) (def: (<= test subject) @@ -4971,7 +4971,7 @@ (ident #open (\"ident/\" Codec))) meta (macro code)) - (// (type #open (\"\" Eq)))) + (// (type #open (\"\" Equivalence)))) (.module: {#.doc \"Some documentation...\"} lux @@ -4982,7 +4982,7 @@ [ident \"ident/\" Codec]) meta (macro code)) - (// [type \"\" Eq]))"} + (// [type \"\" Equivalence]))"} (do Monad [#let [[_meta _imports] (: [(List [Code Code]) (List Code)] (case tokens @@ -5633,7 +5633,7 @@ [ (do-template [ ] [(compare ) (compare (:: Code/encode show )) - (compare true (:: Eq = ))] + (compare true (:: Equivalence = ))] [(bool true) "true" [_ (#.Bool true)]] [(bool false) "false" [_ (#.Bool false)]] @@ -5883,9 +5883,9 @@ {#.doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index." "In the example below, +0 corresponds to the 'a' variable." (def: #export (from-list list) - (All [a] (-> (List a) (Sequence a))) + (All [a] (-> (List a) (Row a))) (list/fold add - (: (Sequence ($ +0)) + (: (Row ($ +0)) empty) list)))} (case tokens diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index 281dfd9d5..c2e8e2c0f 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -3,7 +3,7 @@ (lux (control monad ["p" parser]) (data (coll [list "list/" Monoid Monad]) - [text "text/" Eq] + [text "text/" Equivalence] text/format ["E" error]) [io] diff --git a/stdlib/source/lux/control/equality.lux b/stdlib/source/lux/control/equality.lux deleted file mode 100644 index f75a78fdd..000000000 --- a/stdlib/source/lux/control/equality.lux +++ /dev/null @@ -1,30 +0,0 @@ -(.module: lux) - -(sig: #export (Eq a) - {#.doc "Equality for a type's instances."} - (: (-> a a Bool) - =)) - -(def: #export (product left right) - (All [l r] (-> (Eq l) (Eq r) (Eq [l r]))) - (struct (def: (= [a b] [x y]) - (and (:: left = a x) - (:: right = b y))))) - -(def: #export (sum left right) - (All [l r] (-> (Eq l) (Eq r) (Eq (| l r)))) - (struct (def: (= a|b x|y) - (case [a|b x|y] - [(+0 a) (+0 x)] - (:: left = a x) - - [(+1 b) (+1 y)] - (:: right = b y) - - _ - false)))) - -(def: #export (rec sub) - (All [a] (-> (-> (Eq a) (Eq a)) (Eq a))) - (struct (def: (= left right) - (sub (rec sub) left right)))) diff --git a/stdlib/source/lux/control/equivalence.lux b/stdlib/source/lux/control/equivalence.lux new file mode 100644 index 000000000..eabe1165e --- /dev/null +++ b/stdlib/source/lux/control/equivalence.lux @@ -0,0 +1,30 @@ +(.module: lux) + +(sig: #export (Equivalence a) + {#.doc "Equivalence for a type's instances."} + (: (-> a a Bool) + =)) + +(def: #export (product left right) + (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence [l r]))) + (struct (def: (= [a b] [x y]) + (and (:: left = a x) + (:: right = b y))))) + +(def: #export (sum left right) + (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r)))) + (struct (def: (= a|b x|y) + (case [a|b x|y] + [(+0 a) (+0 x)] + (:: left = a x) + + [(+1 b) (+1 y)] + (:: right = b y) + + _ + false)))) + +(def: #export (rec sub) + (All [a] (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) + (struct (def: (= left right) + (sub (rec sub) left right)))) diff --git a/stdlib/source/lux/control/hash.lux b/stdlib/source/lux/control/hash.lux index 6399307bf..76fcd2730 100644 --- a/stdlib/source/lux/control/hash.lux +++ b/stdlib/source/lux/control/hash.lux @@ -1,13 +1,13 @@ (.module: lux - (// [equality #+ Eq])) + (// [equivalence #+ Equivalence])) ## [Signatures] (sig: #export (Hash a) {#.doc "A way to produce hash-codes for a type's instances. A necessity when working with some data-structures, such as dictionaries or sets."} - (: (Eq a) + (: (Equivalence a) eq) (: (-> a Nat) hash)) diff --git a/stdlib/source/lux/control/interval.lux b/stdlib/source/lux/control/interval.lux index 70540622f..92cb9599f 100644 --- a/stdlib/source/lux/control/interval.lux +++ b/stdlib/source/lux/control/interval.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [order] [enum #+ Enum]))) @@ -133,7 +133,7 @@ [after? >] ) -(struct: #export Eq (All [a] (Eq (Interval a))) +(struct: #export Equivalence (All [a] (Equivalence (Interval a))) (def: (= reference sample) (let [(^open) reference] (and (= bottom (:: sample bottom)) @@ -163,7 +163,7 @@ (def: #export (overlaps? reference sample) (All [a] (-> (Interval a) (Interval a) Bool)) (let [(^open) reference] - (and (not (:: Eq = reference sample)) + (and (not (:: Equivalence = reference sample)) (cond (singleton? sample) false diff --git a/stdlib/source/lux/control/order.lux b/stdlib/source/lux/control/order.lux index fd595b1f3..04d0e6a82 100644 --- a/stdlib/source/lux/control/order.lux +++ b/stdlib/source/lux/control/order.lux @@ -1,13 +1,13 @@ (.module: lux (lux function) - (// [equality #+ Eq])) + (// [equivalence #+ Equivalence])) ## [Signatures] (sig: #export (Order a) {#.doc "A signature for types that possess some sense of ordering among their elements."} - (: (Eq a) + (: (Equivalence a) eq) (do-template [] @@ -20,7 +20,7 @@ ## [Values] (def: #export (order eq <) (All [a] - (-> (Eq a) (-> a a Bool) (Order a))) + (-> (Equivalence a) (-> a a Bool) (Order a))) (let [> (flip <)] (struct (def: eq eq) diff --git a/stdlib/source/lux/data/bool.lux b/stdlib/source/lux/data/bool.lux index 21ae0526f..88c1011e5 100644 --- a/stdlib/source/lux/data/bool.lux +++ b/stdlib/source/lux/data/bool.lux @@ -1,20 +1,20 @@ (.module: lux (lux (control [monoid #+ Monoid] - [equality #+ Eq] + [equivalence #+ Equivalence] hash [codec #+ Codec]) function)) ## [Structures] -(struct: #export _ (Eq Bool) +(struct: #export _ (Equivalence Bool) (def: (= x y) (if x y (not y)))) (struct: #export _ (Hash Bool) - (def: eq Eq) + (def: eq Equivalence) (def: (hash value) (case value true +1 diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux index 3e649fc7d..8f3bee0c3 100644 --- a/stdlib/source/lux/data/coll/array.lux +++ b/stdlib/source/lux/data/coll/array.lux @@ -2,7 +2,7 @@ lux (lux (control [monoid #+ Monoid] [functor #+ Functor] - [equality #+ Eq] + [equivalence #+ Equivalence] fold) (data (coll [list "list/" Fold]) [product]) @@ -149,8 +149,8 @@ #.None output))))) -(struct: #export (Eq Eq) - (All [a] (-> (Eq a) (Eq (Array a)))) +(struct: #export (Equivalence Equivalence) + (All [a] (-> (Equivalence a) (Equivalence (Array a)))) (def: (= xs ys) (let [sxs (size xs) sxy (size ys)] @@ -162,7 +162,7 @@ true [(#.Some x) (#.Some y)] - (:: Eq = x y) + (:: Equivalence = x y) _ false))) diff --git a/stdlib/source/lux/data/coll/bits.lux b/stdlib/source/lux/data/coll/bits.lux index 950aadd0f..94d3398a0 100644 --- a/stdlib/source/lux/data/coll/bits.lux +++ b/stdlib/source/lux/data/coll/bits.lux @@ -1,6 +1,6 @@ (.module: [lux #- not and or] - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] pipe) (data [maybe] [bit] @@ -151,7 +151,7 @@ [xor bit.xor] ) -(struct: #export _ (Eq Bits) +(struct: #export _ (Equivalence Bits) (def: (= reference sample) (let [size (n/max (array.size reference) (array.size sample))] diff --git a/stdlib/source/lux/data/coll/dictionary/ordered.lux b/stdlib/source/lux/data/coll/dictionary/ordered.lux index aec44d943..6fbcb5a42 100644 --- a/stdlib/source/lux/data/coll/dictionary/ordered.lux +++ b/stdlib/source/lux/data/coll/dictionary/ordered.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [monad #+ do Monad] - equality + equivalence [order #+ Order]) (data (coll [list "L/" Monad Monoid Fold]) ["p" product] @@ -551,9 +551,9 @@ [values v (get@ #value node')] ) -(struct: #export (Eq Eq) (All [k v] (-> (Eq v) (Eq (Dict k v)))) +(struct: #export (Equivalence Equivalence) (All [k v] (-> (Equivalence v) (Equivalence (Dict k v)))) (def: (= reference sample) - (let [Eq (:: sample eq)] + (let [Equivalence (:: sample eq)] (loop [entriesR (entries reference) entriesS (entries sample)] (case [entriesR entriesS] @@ -561,8 +561,8 @@ true [(#.Cons [keyR valueR] entriesR') (#.Cons [keyS valueS] entriesS')] - (and (:: Eq = keyR keyS) - (:: Eq = valueR valueS) + (and (:: Equivalence = keyR keyS) + (:: Equivalence = valueR valueS) (recur entriesR' entriesS')) _ diff --git a/stdlib/source/lux/data/coll/dictionary/plist.lux b/stdlib/source/lux/data/coll/dictionary/plist.lux index e9e08107a..c483a3287 100644 --- a/stdlib/source/lux/data/coll/dictionary/plist.lux +++ b/stdlib/source/lux/data/coll/dictionary/plist.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (data [text "text/" Eq]))) + (lux (data [text "text/" Equivalence]))) (type: #export (PList a) (List [Text a])) diff --git a/stdlib/source/lux/data/coll/dictionary/unordered.lux b/stdlib/source/lux/data/coll/dictionary/unordered.lux index 12c58a2fd..bb6d12b24 100644 --- a/stdlib/source/lux/data/coll/dictionary/unordered.lux +++ b/stdlib/source/lux/data/coll/dictionary/unordered.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control hash - [equality #+ Eq]) + [equivalence #+ Equivalence]) (data [maybe] (coll [list "list/" Fold Functor Monoid] [array "array/" Functor Fold]) @@ -671,14 +671,14 @@ keys))) ## [Structures] -(struct: #export (Eq Eq) (All [k v] (-> (Eq v) (Eq (Dict k v)))) +(struct: #export (Equivalence Equivalence) (All [k v] (-> (Equivalence v) (Equivalence (Dict k v)))) (def: (= test subject) (and (n/= (size test) (size subject)) (list.every? (function (_ k) (case [(get k test) (get k subject)] [(#.Some tk) (#.Some sk)] - (:: Eq = tk sk) + (:: Equivalence = tk sk) _ false)) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 7f5a71994..4049fce8e 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -4,7 +4,7 @@ [functor #+ Functor] [apply #+ Apply] [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] [fold]) (data [number "nat/" Codec] bool @@ -265,15 +265,15 @@ (nth (dec i) xs')))) ## [Structures] -(struct: #export (Eq Eq) - (All [a] (-> (Eq a) (Eq (List a)))) +(struct: #export (Equivalence Equivalence) + (All [a] (-> (Equivalence a) (Equivalence (List a)))) (def: (= xs ys) (case [xs ys] [#.Nil #.Nil] true [(#.Cons x xs') (#.Cons y ys')] - (and (:: Eq = x y) + (and (:: Equivalence = x y) (= xs' ys')) [_ _] @@ -357,7 +357,7 @@ _ false)) (def: #export (member? eq xs x) - (All [a] (-> (Eq a) (List a) a Bool)) + (All [a] (-> (Equivalence a) (List a) a Bool)) (case xs #.Nil false (#.Cons x' xs') (or (:: eq = x x') diff --git a/stdlib/source/lux/data/coll/queue.lux b/stdlib/source/lux/data/coll/queue.lux index 3a39a3e41..490351d29 100644 --- a/stdlib/source/lux/data/coll/queue.lux +++ b/stdlib/source/lux/data/coll/queue.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] ["F" functor]) (data (coll [list "L/" Monoid Functor])))) @@ -37,11 +37,11 @@ (All [a] (-> (Queue a) Bool)) (|>> (get@ #front) list.empty?)) -(def: #export (member? Eq queue member) - (All [a] (-> (Eq a) (Queue a) a Bool)) +(def: #export (member? Equivalence queue member) + (All [a] (-> (Equivalence a) (Queue a) a Bool)) (let [(^slots [#front #rear]) queue] - (or (list.member? Eq front member) - (list.member? Eq rear member)))) + (or (list.member? Equivalence front member) + (list.member? Equivalence rear member)))) (def: #export (pop queue) (All [a] (-> (Queue a) (Queue a))) @@ -67,10 +67,10 @@ _ (update@ #rear (|>> (#.Cons val)) queue))) -(struct: #export (Eq Eq) - (All [a] (-> (Eq a) (Eq (Queue a)))) +(struct: #export (Equivalence Equivalence) + (All [a] (-> (Equivalence a) (Equivalence (Queue a)))) (def: (= qx qy) - (:: (list.Eq Eq) = (to-list qx) (to-list qy)))) + (:: (list.Equivalence Equivalence) = (to-list qx) (to-list qy)))) (struct: #export _ (F.Functor Queue) (def: (map f fa) diff --git a/stdlib/source/lux/data/coll/queue/priority.lux b/stdlib/source/lux/data/coll/queue/priority.lux index a1e765fc3..443a54908 100644 --- a/stdlib/source/lux/data/coll/queue/priority.lux +++ b/stdlib/source/lux/data/coll/queue/priority.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [monad #+ do Monad]) (data (coll (tree [finger #+ Tree])) [number "nat/" Interval] @@ -39,8 +39,8 @@ (#finger.Branch _ left right) (n/+ (recur left) (recur right)))))) -(def: #export (member? Eq queue member) - (All [a] (-> (Eq a) (Queue a) a Bool)) +(def: #export (member? Equivalence queue member) + (All [a] (-> (Equivalence a) (Queue a) a Bool)) (case queue #.None false @@ -49,7 +49,7 @@ (loop [node (get@ #finger.node fingers)] (case node (#finger.Leaf _ reference) - (:: Eq = reference member) + (:: Equivalence = reference member) (#finger.Branch _ left right) (or (recur left) diff --git a/stdlib/source/lux/data/coll/row.lux b/stdlib/source/lux/data/coll/row.lux index 0b258a2ec..2c50120ec 100644 --- a/stdlib/source/lux/data/coll/row.lux +++ b/stdlib/source/lux/data/coll/row.lux @@ -3,7 +3,7 @@ (lux (control [functor #+ Functor] [apply #+ Apply] [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] monoid fold ["p" parser]) @@ -328,9 +328,9 @@ empty list)) -(def: #export (member? a/Eq vec val) - (All [a] (-> (Eq a) (Row a) a Bool)) - (list.member? a/Eq (to-list vec) val)) +(def: #export (member? a/Equivalence vec val) + (All [a] (-> (Equivalence a) (Row a) a Bool)) + (list.member? a/Equivalence (to-list vec) val)) (def: #export empty? (All [a] (-> (Row a) Bool)) @@ -343,22 +343,22 @@ (wrap (list (` (from-list (list (~+ elems))))))) ## [Structures] -(struct: #export (Eq Eq) (All [a] (-> (Eq a) (Eq (Node a)))) +(struct: #export (Equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (Node a)))) (def: (= v1 v2) (case [v1 v2] [(#Base b1) (#Base b2)] - (:: (array.Eq Eq) = b1 b2) + (:: (array.Equivalence Equivalence) = b1 b2) [(#Hierarchy h1) (#Hierarchy h2)] - (:: (array.Eq (Eq Eq)) = h1 h2) + (:: (array.Equivalence (Equivalence Equivalence)) = h1 h2) _ false))) -(struct: #export (Eq Eq) (All [a] (-> (Eq a) (Eq (Row a)))) +(struct: #export (Equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (Row a)))) (def: (= v1 v2) (and (n/= (get@ #size v1) (get@ #size v2)) - (let [(^open "Node/") (Eq Eq)] + (let [(^open "Node/") (Equivalence Equivalence)] (and (Node/= (#Base (get@ #tail v1)) (#Base (get@ #tail v2))) (Node/= (#Hierarchy (get@ #root v1)) diff --git a/stdlib/source/lux/data/coll/set/ordered.lux b/stdlib/source/lux/data/coll/set/ordered.lux index 5b7524a8a..0862d62c2 100644 --- a/stdlib/source/lux/data/coll/set/ordered.lux +++ b/stdlib/source/lux/data/coll/set/ordered.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [monad #+ do Monad] - equality + equivalence [order #+ Order]) (data (coll [list "L/" Monad Monoid Fold] (dictionary ["d" ordered])) @@ -80,7 +80,7 @@ (All [a] (-> (Set a) (Set a) Bool)) (sub? super sub)) -(struct: #export Eq (All [a] (Eq (Set a))) +(struct: #export Equivalence (All [a] (Equivalence (Set a))) (def: (= reference sample) - (:: (list.Eq (:: sample eq)) + (:: (list.Equivalence (:: sample eq)) = (to-list reference) (to-list sample)))) diff --git a/stdlib/source/lux/data/coll/set/unordered.lux b/stdlib/source/lux/data/coll/set/unordered.lux index e977f35e5..4fcc0c1cc 100644 --- a/stdlib/source/lux/data/coll/set/unordered.lux +++ b/stdlib/source/lux/data/coll/set/unordered.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [hash #*]) (data (coll (dictionary ["dict" unordered #+ Dict]) [list "list/" Fold Functor])))) @@ -63,12 +63,12 @@ (sub? super sub)) ## [Structures] -(struct: #export Eq (All [a] (Eq (Set a))) +(struct: #export Equivalence (All [a] (Equivalence (Set a))) (def: (= (^@ test [Hash _]) subject) - (:: (list.Eq (get@ #hash.eq Hash)) = (to-list test) (to-list subject)))) + (:: (list.Equivalence (get@ #hash.eq Hash)) = (to-list test) (to-list subject)))) (struct: #export Hash (All [a] (Hash (Set a))) - (def: eq Eq) + (def: eq Equivalence) (def: (hash (^@ set [Hash _])) (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) diff --git a/stdlib/source/lux/data/coll/tree/rose.lux b/stdlib/source/lux/data/coll/tree/rose.lux index 28ca96d41..8171dcdaa 100644 --- a/stdlib/source/lux/data/coll/tree/rose.lux +++ b/stdlib/source/lux/data/coll/tree/rose.lux @@ -2,7 +2,7 @@ lux (lux (control functor [monad #+ do Monad] - equality + equivalence ["p" parser] fold) (data (coll [list "L/" Monad Fold])) @@ -54,10 +54,10 @@ #children (list (~+ (L/map recur children)))}))))))) ## [Structs] -(struct: #export (Eq Eq) (All [a] (-> (Eq a) (Eq (Tree a)))) +(struct: #export (Equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (Tree a)))) (def: (= tx ty) - (and (:: Eq = (get@ #value tx) (get@ #value ty)) - (:: (list.Eq (Eq Eq)) = (get@ #children tx) (get@ #children ty))))) + (and (:: Equivalence = (get@ #value tx) (get@ #value ty)) + (:: (list.Equivalence (Equivalence Equivalence)) = (get@ #children tx) (get@ #children ty))))) (struct: #export _ (Functor Tree) (def: (map f fa) diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 241347859..67c9c3388 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control ["eq" equality]) + (lux (control ["eq" equivalence]) (data (coll [list "L/" Functor])) [math] (type abstract))) @@ -33,7 +33,7 @@ (-> Color [Nat Nat Nat]) (|>> :representation)) - (struct: #export _ (eq.Eq Color) + (struct: #export _ (eq.Equivalence Color) (def: (= reference sample) (let [[rr rg rb] (:representation reference) [sr sg sb] (:representation sample)] diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index a5c81ad6b..984fbb1aa 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -3,11 +3,11 @@ For more information, please see: http://www.json.org/"} [lux #- Array] (lux (control [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] codec ["p" parser "parser/" Monad]) (data [bool] - [text "text/" Eq Monoid] + [text "text/" Equivalence Monoid] (text ["l" lexer]) [number "frac/" Codec "nat/" Codec] [maybe] @@ -147,7 +147,7 @@ [get-object #Object Object "objects"] ) -(struct: #export _ (Eq JSON) +(struct: #export _ (Equivalence JSON) (def: (= x y) (case [x y] [#Null #Null] @@ -156,9 +156,9 @@ (^template [ ] [( x') ( y')] (:: = x' y')) - ([#Boolean bool.Eq] - [#Number number.Eq] - [#String text.Eq]) + ([#Boolean bool.Equivalence] + [#Number number.Equivalence] + [#String text.Equivalence]) [(#Array xs) (#Array ys)] (and (n/= (row.size xs) (row.size ys)) @@ -268,9 +268,9 @@ _ (fail ($_ text/compose "JSON value is not a " ".")))))] - [boolean? boolean! Bool bool.Eq (:: bool.Codec encode) #Boolean "boolean" id] - [number? number! Frac number.Eq (:: number.Codec encode) #Number "number" id] - [string? string! Text text.Eq text.encode #String "string" id] + [boolean? boolean! Bool bool.Equivalence (:: bool.Codec encode) #Boolean "boolean" id] + [number? number! Frac number.Equivalence (:: number.Codec encode) #Number "number" id] + [string? string! Text text.Equivalence text.encode #String "string" id] ) (def: #export (nullable parser) diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux index a725263af..7d1614fca 100644 --- a/stdlib/source/lux/data/format/xml.lux +++ b/stdlib/source/lux/data/format/xml.lux @@ -1,17 +1,17 @@ (.module: {#.doc "Functionality for reading, generating and processing values in the XML format."} lux (lux (control monad - [equality #+ Eq] + [equivalence #+ Equivalence] codec ["p" parser "p/" Monad] ["ex" exception #+ exception:]) - (data [text "text/" Eq Monoid] + (data [text "text/" Equivalence Monoid] (text ["l" lexer]) [number] ["E" error] [product] [maybe "m/" Monad] - [ident "ident/" Eq Codec] + [ident "ident/" Equivalence Codec] (coll [list "list/" Monad] (dictionary ["d" unordered]))))) @@ -224,7 +224,7 @@ (def: encode write) (def: decode read)) -(struct: #export _ (Eq XML) +(struct: #export _ (Equivalence XML) (def: (= reference sample) (case [reference sample] [(#Text reference/value) (#Text sample/value)] @@ -233,7 +233,7 @@ [(#Node reference/tag reference/attrs reference/children) (#Node sample/tag sample/attrs sample/children)] (and (ident/= reference/tag sample/tag) - (:: (d.Eq text.Eq) = reference/attrs sample/attrs) + (:: (d.Equivalence text.Equivalence) = reference/attrs sample/attrs) (n/= (list.size reference/children) (list.size sample/children)) (|> (list.zip2 reference/children sample/children) diff --git a/stdlib/source/lux/data/ident.lux b/stdlib/source/lux/data/ident.lux index 867f96d8b..cb0b35b1f 100644 --- a/stdlib/source/lux/data/ident.lux +++ b/stdlib/source/lux/data/ident.lux @@ -1,9 +1,9 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [codec #+ Codec] hash) - (data [text "text/" Monoid Eq]))) + (data [text "text/" Monoid Equivalence]))) ## [Types] ## (type: Ident @@ -20,7 +20,7 @@ ) ## [Structures] -(struct: #export _ (Eq Ident) +(struct: #export _ (Equivalence Ident) (def: (= [xmodule xname] [ymodule yname]) (and (text/= xmodule ymodule) (text/= xname yname)))) @@ -45,7 +45,7 @@ (#.Left (text/compose "Invalid format for Ident: " input)))))) (struct: #export _ (Hash Ident) - (def: eq Eq) + (def: eq Equivalence) (def: (hash [module name]) (let [(^open) text.Hash] diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux index 6c5a7d02e..bfdb0fbe5 100644 --- a/stdlib/source/lux/data/maybe.lux +++ b/stdlib/source/lux/data/maybe.lux @@ -4,7 +4,7 @@ ["F" functor] ["A" apply] [monad #+ do Monad] - [equality #+ Eq]))) + [equivalence #+ Equivalence]))) ## [Types] ## (type: (Maybe a) @@ -47,14 +47,14 @@ #.None #.None (#.Some xs) xs))) -(struct: #export (Eq Eq) (All [a] (-> (Eq a) (Eq (Maybe a)))) +(struct: #export (Equivalence Equivalence) (All [a] (-> (Equivalence a) (Equivalence (Maybe a)))) (def: (= mx my) (case [mx my] [#.None #.None] true [(#.Some x) (#.Some y)] - (:: Eq = x y) + (:: Equivalence = x y) _ false))) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 8c9e663cb..637d0d0ba 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -2,7 +2,7 @@ lux (lux (control number [monoid #+ Monoid] - [equality #+ Eq] + [equivalence #+ Equivalence] hash [order] enum @@ -14,7 +14,7 @@ ## [Structures] (do-template [ ] - [(struct: #export _ (Eq ) + [(struct: #export _ (Equivalence ) (def: = ))] [ Nat n/=] @@ -31,10 +31,10 @@ (def: > ) (def: >= ))] - [ Nat Eq n/< n/<= n/> n/>=] - [ Int Eq i/< i/<= i/> i/>=] - [Rev Eq r/< r/<= r/> r/>=] - [Frac Eq f/< f/<= f/> f/>=] + [ Nat Equivalence n/< n/<= n/> n/>=] + [ Int Equivalence i/< i/<= i/> i/>=] + [Rev Equivalence r/< r/<= r/> r/>=] + [Frac Equivalence f/< f/<= f/> f/>=] ) (struct: #export _ (Number Nat) @@ -995,18 +995,18 @@ ## [Hash] (struct: #export _ (Hash Nat) - (def: eq Eq) + (def: eq Equivalence) (def: hash id)) (struct: #export _ (Hash Int) - (def: eq Eq) + (def: eq Equivalence) (def: hash .nat)) (struct: #export _ (Hash Frac) - (def: eq Eq) + (def: eq Equivalence) (def: hash frac-to-bits)) (struct: #export _ (Hash Rev) - (def: eq Eq) + (def: eq Equivalence) (def: hash (|>> (:coerce Nat)))) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index 792d2ce53..a7e535f08 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Complex arithmetic."} lux (lux [math] - (control [equality #+ Eq] + (control [equivalence #+ Equivalence] number codec ["M" monad #+ do Monad] @@ -56,7 +56,7 @@ [- f/-] ) -(struct: #export _ (Eq Complex) +(struct: #export _ (Equivalence Complex) (def: = ..=)) (def: #export negate diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index 6d241064a..c96c66882 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Rational arithmetic."} lux (lux [math] - (control [equality #+ Eq] + (control [equivalence #+ Equivalence] [order] number codec @@ -100,11 +100,11 @@ [max >] ) -(struct: #export _ (Eq Ratio) +(struct: #export _ (Equivalence Ratio) (def: = ..=)) (struct: #export _ (order.Order Ratio) - (def: eq Eq) + (def: eq Equivalence) (def: < ..<) (def: <= ..<=) (def: > ..>) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 58826e2c9..04af675c4 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control [monoid #+ Monoid] - [equality #+ Eq] + [equivalence #+ Equivalence] [order] [monad #+ do Monad] [codec #+ Codec] @@ -123,12 +123,12 @@ (split-all-with "\n")) ## [Structures] -(struct: #export _ (Eq Text) +(struct: #export _ (Equivalence Text) (def: (= test subject) ("lux text =" subject test))) (struct: #export _ (order.Order Text) - (def: eq Eq) + (def: eq Equivalence) (def: (< test subject) ("lux text <" subject test)) @@ -167,7 +167,7 @@ ($_ text/compose "\"" escaped "\""))) (struct: #export _ (Hash Text) - (def: eq Eq) + (def: eq Equivalence) (def: (hash input) ("lux text hash" input))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index 78a190505..6628cb81d 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -9,13 +9,13 @@ number [maybe] [product] - [text "text/" Eq Monoid] + [text "text/" Equivalence Monoid] text/format [bool "bool/" Codec]) [macro #+ with-gensyms Functor Monad] (macro [code] ["s" syntax #+ syntax: Syntax]) - (lang [type "type/" Eq]) + (lang [type "type/" Equivalence]) )) (do-template [ ] @@ -462,7 +462,7 @@ (def: (qualify imports name) (-> Class-Imports Text Text) - (if (list.member? text.Eq java/lang/* name) + (if (list.member? text.Equivalence java/lang/* name) (format "java/lang/" name) (maybe.default name (get-import name imports)))) @@ -675,7 +675,7 @@ (do p.Monad [name (full-class-name^ imports) _ (assert-no-periods name)] - (if (list.member? text.Eq (list/map product.left type-vars) name) + (if (list.member? text.Equivalence (list/map product.left type-vars) name) (wrap (#GenericTypeVar name)) (wrap (#GenericClass name (list))))) (s.form (do p.Monad @@ -701,7 +701,7 @@ _ (assert-no-periods name) params (p.some (generic-type^ imports type-vars)) _ (p.assert (format name " cannot be a type-parameter!") - (not (list.member? text.Eq (list/map product.left type-vars) name)))] + (not (list.member? text.Equivalence (list/map product.left type-vars) name)))] (wrap (#GenericClass name params)))) )) diff --git a/stdlib/source/lux/lang/compiler/analysis.lux b/stdlib/source/lux/lang/compiler/analysis.lux index 9d35ff92c..c9e9b8be1 100644 --- a/stdlib/source/lux/lang/compiler/analysis.lux +++ b/stdlib/source/lux/lang/compiler/analysis.lux @@ -2,7 +2,7 @@ [lux #- nat int rev] (lux (data [product] [error] - [text "text/" Eq] + [text "text/" Equivalence] (coll [list "list/" Fold])) [function]) [///reference #+ Register Variable Reference] diff --git a/stdlib/source/lux/lang/compiler/analysis/case/coverage.lux b/stdlib/source/lux/lang/compiler/analysis/case/coverage.lux index 3a63a76fc..c6a36e022 100644 --- a/stdlib/source/lux/lang/compiler/analysis/case/coverage.lux +++ b/stdlib/source/lux/lang/compiler/analysis/case/coverage.lux @@ -2,8 +2,8 @@ lux (lux (control [monad #+ do] ["ex" exception #+ exception:] - equality) - (data [bool "bool/" Eq] + equivalence) + (data [bool "bool/" Equivalence] [number] ["e" error "error/" Monad] [maybe] @@ -142,7 +142,7 @@ _ (list coverage))) -(struct: _ (Eq Coverage) +(struct: _ (Equivalence Coverage) (def: (= reference sample) (case [reference sample] [#Exhaustive #Exhaustive] @@ -154,7 +154,7 @@ [(#Variant allR casesR) (#Variant allS casesS)] (and (n/= (cases allR) (cases allS)) - (:: (dict.Eq =) = casesR casesS)) + (:: (dict.Equivalence =) = casesR casesS)) [(#Seq leftR rightR) (#Seq leftS rightS)] (and (= leftR leftS) @@ -171,7 +171,7 @@ _ false))) -(open: "C/" Eq) +(open: "C/" Equivalence) ## After determining the coverage of each individual pattern, it is ## necessary to merge them all to figure out if the entire @@ -200,7 +200,7 @@ (cond (not (n/= (cases allSF) (cases allA))) (e.fail "Variants do not match.") - (:: (dict.Eq Eq) = casesSF casesA) + (:: (dict.Equivalence Equivalence) = casesSF casesA) redundant-pattern ## else diff --git a/stdlib/source/lux/lang/compiler/analysis/reference.lux b/stdlib/source/lux/lang/compiler/analysis/reference.lux index 5652e21fc..a3436d15b 100644 --- a/stdlib/source/lux/lang/compiler/analysis/reference.lux +++ b/stdlib/source/lux/lang/compiler/analysis/reference.lux @@ -5,7 +5,7 @@ [macro] (macro [code]) (lang (type ["tc" check])) - (data [text "text/" Eq] + (data [text "text/" Equivalence] text/format)) [///] [// #+ Analysis Operation] diff --git a/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux b/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux index 9b742b415..826650ccc 100644 --- a/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/lang/compiler/extension/analysis/host.jvm.lux @@ -6,8 +6,8 @@ (data ["e" error] [maybe] [product] - [bool "bool/" Eq] - [text "text/" Eq] + [bool "bool/" Equivalence] + [text "text/" Equivalence] (text format ["l" lexer]) (coll [list "list/" Fold Functor Monoid] @@ -200,13 +200,13 @@ (def: #export boxes (Dict Text Text) (|> (list ["boolean" "java.lang.Boolean"] - ["byte" "java.lang.Byte"] - ["short" "java.lang.Short"] - ["int" "java.lang.Integer"] - ["long" "java.lang.Long"] - ["float" "java.lang.Float"] - ["double" "java.lang.Double"] - ["char" "java.lang.Character"]) + ["byte" "java.lang.Byte"] + ["short" "java.lang.Short"] + ["int" "java.lang.Integer"] + ["long" "java.lang.Long"] + ["float" "java.lang.Float"] + ["double" "java.lang.Double"] + ["char" "java.lang.Character"]) (dict.from-list text.Hash))) (def: (array//length proc) diff --git a/stdlib/source/lux/lang/compiler/synthesis/case.lux b/stdlib/source/lux/lang/compiler/synthesis/case.lux index 88bfd36e9..bdf06f05f 100644 --- a/stdlib/source/lux/lang/compiler/synthesis/case.lux +++ b/stdlib/source/lux/lang/compiler/synthesis/case.lux @@ -1,13 +1,13 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] pipe [monad #+ do]) (data [product] - [bool "bool/" Eq] - [text "text/" Eq] + [bool "bool/" Equivalence] + [text "text/" Equivalence] text/format - [number "frac/" Eq] + [number "frac/" Equivalence] (coll [list "list/" Fold Monoid]))) [///reference] [///compiler #+ Operation "operation/" Monad] @@ -99,7 +99,7 @@ rightP )) ([#//.Bool bool/=] - [#//.I64 (:coerce (Eq I64) i/=)] + [#//.I64 (:coerce (Equivalence I64) i/=)] [#//.F64 frac/=] [#//.Text text/=]) diff --git a/stdlib/source/lux/lang/module.lux b/stdlib/source/lux/lang/module.lux index d6b66da74..b93b5e27b 100644 --- a/stdlib/source/lux/lang/module.lux +++ b/stdlib/source/lux/lang/module.lux @@ -3,7 +3,7 @@ (lux (control [monad #+ do] ["ex" exception #+ exception:] pipe) - (data [text "text/" Eq] + (data [text "text/" Equivalence] text/format ["e" error] (coll [list "list/" Fold Functor] diff --git a/stdlib/source/lux/lang/reference.lux b/stdlib/source/lux/lang/reference.lux index 0f7438345..c76f78d87 100644 --- a/stdlib/source/lux/lang/reference.lux +++ b/stdlib/source/lux/lang/reference.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [hash #+ Hash] pipe))) @@ -14,7 +14,7 @@ (#Variable Variable) (#Constant Ident)) -(struct: #export _ (Eq Variable) +(struct: #export _ (Equivalence Variable) (def: (= reference sample) (case [reference sample] (^template [] @@ -26,7 +26,7 @@ false))) (struct: #export _ (Hash Variable) - (def: eq Eq) + (def: eq Equivalence) (def: (hash var) (case var (#Local register) diff --git a/stdlib/source/lux/lang/scope.lux b/stdlib/source/lux/lang/scope.lux index 217b7fcb3..191eb5e5d 100644 --- a/stdlib/source/lux/lang/scope.lux +++ b/stdlib/source/lux/lang/scope.lux @@ -1,7 +1,7 @@ (.module: lux (lux (control monad) - (data [text "text/" Eq] + (data [text "text/" Equivalence] text/format [maybe "maybe/" Monad] [product] diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux index cd18e103d..96ea1a9b0 100644 --- a/stdlib/source/lux/lang/type.lux +++ b/stdlib/source/lux/lang/type.lux @@ -1,10 +1,10 @@ (.module: {#.doc "Basic functionality for working with types."} [lux #- function] - (lux (control [equality #+ Eq] + (lux (control [equivalence #+ Equivalence] [monad #+ do Monad] ["p" parser]) - (data [text "text/" Monoid Eq] - [ident "ident/" Eq Codec] + (data [text "text/" Monoid Equivalence] + [ident "ident/" Equivalence Codec] [number "nat/" Codec] [maybe] (coll [list #+ "list/" Functor Monoid Fold])) @@ -46,7 +46,7 @@ )) ## [Structures] -(struct: #export _ (Eq Type) +(struct: #export _ (Equivalence Type) (def: (= x y) (case [x y] [(#.Primitive xname xparams) (#.Primitive yname yparams)] diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux index 482ea66bf..5e6ab2714 100644 --- a/stdlib/source/lux/lang/type/check.lux +++ b/stdlib/source/lux/lang/type/check.lux @@ -4,14 +4,14 @@ [apply #+ Apply] [monad #+ do Monad] ["ex" exception #+ exception:]) - (data [text "text/" Monoid Eq] + (data [text "text/" Monoid Equivalence] [number "nat/" Codec] [maybe] [product] (coll [list] (set ["set" unordered #+ Set])) ["e" error]) - (lang [type "type/" Eq]) + (lang [type "type/" Equivalence]) )) (exception: #export (unknown-type-var {id Nat}) @@ -419,7 +419,7 @@ (do @ [ringE (ring idE) ringA (ring idA)] - (if (:: set.Eq = ringE ringA) + (if (:: set.Equivalence = ringE ringA) (wrap assumptions) ## Fuse 2 rings (do @ diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux index 470406482..a8494f047 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/macro.lux @@ -5,10 +5,10 @@ [monad #+ do Monad]) (data [number "nat/" Codec] [product] - [ident "ident/" Codec Eq] + [ident "ident/" Codec Equivalence] [maybe] ["e" error] - [text "text/" Monoid Eq] + [text "text/" Monoid Equivalence] (coll [list "list/" Monoid Monad]))) (/ [code])) diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index 67da53982..1094d7e0e 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -1,9 +1,9 @@ (.module: [lux #- nat int rev] - (lux (control [equality #+ Eq]) + (lux (control [equivalence #+ Equivalence]) (data bool number - [text #+ Eq "text/" Monoid] + [text #+ Equivalence "text/" Monoid] ident (coll [list #* "" Functor Fold]) ))) @@ -56,24 +56,24 @@ [local-tag #.Tag "Produces a local tag (a tag with no module prefix)."]) ## [Structures] -(struct: #export _ (Eq Code) +(struct: #export _ (Equivalence Code) (def: (= x y) (case [x y] (^template [ ] [[_ ( x')] [_ ( y')]] (:: = x' y')) - ([#.Bool Eq] - [#.Nat Eq] - [#.Int Eq] - [#.Rev Eq] - [#.Frac Eq] - [#.Text Eq] - [#.Symbol Eq] - [#.Tag Eq]) + ([#.Bool Equivalence] + [#.Nat Equivalence] + [#.Int Equivalence] + [#.Rev Equivalence] + [#.Frac Equivalence] + [#.Text Equivalence] + [#.Symbol Equivalence] + [#.Tag Equivalence]) (^template [] [[_ ( xs')] [_ ( ys')]] - (and (:: Eq = (size xs') (size ys')) + (and (:: Equivalence = (size xs') (size ys')) (fold (function (_ [x' y'] old) (and old (= x' y'))) true @@ -82,7 +82,7 @@ [#.Tuple]) [[_ (#.Record xs')] [_ (#.Record ys')]] - (and (:: Eq = (size xs') (size ys')) + (and (:: Equivalence = (size xs') (size ys')) (fold (function (_ [[xl' xr'] [yl' yr']] old) (and old (= xl' yl') (= xr' yr'))) true @@ -124,7 +124,7 @@ (def: #export (replace original substitute ast) {#.doc "Replaces all code that looks like the 'original' with the 'substitute'."} (-> Code Code Code Code) - (if (:: Eq = original ast) + (if (:: Equivalence = original ast) substitute (case ast (^template [] diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 2eb2e9ebc..4cf25eff7 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -1,7 +1,7 @@ (.module: [lux #- function] (lux (control [monad #+ do Monad] - [equality] + [equivalence] ["p" parser] ["ex" exception #+ exception:]) [function] @@ -12,7 +12,7 @@ [product] [bool] [maybe] - [ident "ident/" Eq Codec] + [ident "ident/" Equivalence Codec] ["e" error]) [macro #+ with-gensyms] (macro [code] @@ -20,7 +20,7 @@ (syntax ["cs" common] (common ["csr" reader] ["csw" writer]))) - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] (type [check])) )) diff --git a/stdlib/source/lux/macro/poly/equality.lux b/stdlib/source/lux/macro/poly/equality.lux deleted file mode 100644 index 6eb6ce4ce..000000000 --- a/stdlib/source/lux/macro/poly/equality.lux +++ /dev/null @@ -1,150 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do Monad] - ["eq" equality] - ["p" parser]) - (data [text "text/" Monoid] - text/format - (coll [list "list/" Monad] - [row] - [array] - [queue] - (set ["set" unordered]) - (dictionary ["dict" unordered #+ Dict]) - (tree [rose])) - [number "nat/" Codec] - [product] - [bool] - [maybe]) - (time ["du" duration] - ["da" date] - ["i" instant]) - [macro] - (macro [code] - [syntax #+ syntax: Syntax] - (syntax [common]) - [poly #+ poly:]) - (type [unit]) - (lang [type]) - )) - -## [Derivers] -(poly: #export Eq - (`` (do @ - [#let [g!_ (code.local-symbol "_____________")] - *env* poly.env - inputT poly.peek - #let [@Eq (: (-> Type Code) - (function (_ type) - (` (eq.Eq (~ (poly.to-code *env* type))))))]] - ($_ p.either - ## Basic types - (~~ (do-template [ ] - [(do @ - [_ ] - (wrap (` (: (~ (@Eq inputT)) - ))))] - - [(poly.this Any) (function ((~ g!_) (~ g!_) (~ g!_)) true)] - [(poly.like Bool) bool.Eq] - [(poly.like Nat) number.Eq] - [(poly.like Int) number.Eq] - [(poly.like Rev) number.Eq] - [(poly.like Frac) number.Eq] - [(poly.like Text) text.Eq])) - ## Composite types - (~~ (do-template [ ] - [(do @ - [[_ argC] (poly.apply (p.seq (poly.this ) - Eq))] - (wrap (` (: (~ (@Eq inputT)) - ( (~ argC))))))] - - [.Maybe maybe.Eq] - [.List list.Eq] - [row.Row row.Eq] - [.Array array.Eq] - [queue.Queue queue.Eq] - [set.Set set.Eq] - [rose.Tree rose.Eq] - )) - (do @ - [[_ _ valC] (poly.apply ($_ p.seq - (poly.this dict.Dict) - poly.any - Eq))] - (wrap (` (: (~ (@Eq inputT)) - (dict.Eq (~ valC)))))) - ## Models - (~~ (do-template [ ] - [(do @ - [_ (poly.this )] - (wrap (` (: (~ (@Eq inputT)) - ))))] - - [du.Duration du.Eq] - [i.Instant i.Eq] - [da.Date da.Eq] - [da.Day da.Eq] - [da.Month da.Eq])) - (do @ - [_ (poly.apply (p.seq (poly.this unit.Qty) - poly.any))] - (wrap (` (: (~ (@Eq inputT)) - unit.Eq)))) - ## Variants - (do @ - [members (poly.variant (p.many Eq)) - #let [g!_ (code.local-symbol "_____________") - g!left (code.local-symbol "_____________left") - g!right (code.local-symbol "_____________right")]] - (wrap (` (: (~ (@Eq inputT)) - (function ((~ g!_) (~ g!left) (~ g!right)) - (case [(~ g!left) (~ g!right)] - (~+ (list/join (list/map (function (_ [tag g!eq]) - (list (` [((~ (code.nat tag)) (~ g!left)) - ((~ (code.nat tag)) (~ g!right))]) - (` ((~ g!eq) (~ g!left) (~ g!right))))) - (list.enumerate members)))) - (~ g!_) - false)))))) - ## Tuples - (do @ - [g!eqs (poly.tuple (p.many Eq)) - #let [g!_ (code.local-symbol "_____________") - indices (|> (list.size g!eqs) dec (list.n/range +0)) - g!lefts (list/map (|>> nat/encode (text/compose "left") code.local-symbol) indices) - g!rights (list/map (|>> nat/encode (text/compose "right") code.local-symbol) indices)]] - (wrap (` (: (~ (@Eq inputT)) - (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) - (and (~+ (|> (list.zip3 g!eqs g!lefts g!rights) - (list/map (function (_ [g!eq g!left g!right]) - (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) - ## Type recursion - (do @ - [[g!self bodyC] (poly.recursive Eq) - #let [g!_ (code.local-symbol "_____________")]] - (wrap (` (: (~ (@Eq inputT)) - (eq.rec (.function ((~ g!_) (~ g!self)) - (~ bodyC))))))) - poly.recursive-self - ## Type applications - (do @ - [[funcC argsC] (poly.apply (p.seq Eq (p.many Eq)))] - (wrap (` ((~ funcC) (~+ argsC))))) - ## Parameters - poly.parameter - ## Polymorphism - (do @ - [[funcC varsC bodyC] (poly.polymorphic Eq)] - (wrap (` (: (All [(~+ varsC)] - (-> (~+ (list/map (|>> (~) eq.Eq (`)) varsC)) - (eq.Eq ((~ (poly.to-code *env* inputT)) (~+ varsC))))) - (function ((~ funcC) (~+ varsC)) - (~ bodyC)))))) - poly.recursive-call - ## If all else fails... - (|> poly.any - (:: @ map (|>> %type (format "Cannot create Eq for: ") p.fail)) - (:: @ join)) - )))) diff --git a/stdlib/source/lux/macro/poly/equivalence.lux b/stdlib/source/lux/macro/poly/equivalence.lux new file mode 100644 index 000000000..89e403104 --- /dev/null +++ b/stdlib/source/lux/macro/poly/equivalence.lux @@ -0,0 +1,150 @@ +(.module: + lux + (lux (control [monad #+ do Monad] + ["eq" equivalence] + ["p" parser]) + (data [text "text/" Monoid] + text/format + (coll [list "list/" Monad] + [row] + [array] + [queue] + (set ["set" unordered]) + (dictionary ["dict" unordered #+ Dict]) + (tree [rose])) + [number "nat/" Codec] + [product] + [bool] + [maybe]) + (time ["du" duration] + ["da" date] + ["i" instant]) + [macro] + (macro [code] + [syntax #+ syntax: Syntax] + (syntax [common]) + [poly #+ poly:]) + (type [unit]) + (lang [type]) + )) + +## [Derivers] +(poly: #export Equivalence + (`` (do @ + [#let [g!_ (code.local-symbol "_____________")] + *env* poly.env + inputT poly.peek + #let [@Equivalence (: (-> Type Code) + (function (_ type) + (` (eq.Equivalence (~ (poly.to-code *env* type))))))]] + ($_ p.either + ## Basic types + (~~ (do-template [ ] + [(do @ + [_ ] + (wrap (` (: (~ (@Equivalence inputT)) + ))))] + + [(poly.this Any) (function ((~ g!_) (~ g!_) (~ g!_)) true)] + [(poly.like Bool) bool.Equivalence] + [(poly.like Nat) number.Equivalence] + [(poly.like Int) number.Equivalence] + [(poly.like Rev) number.Equivalence] + [(poly.like Frac) number.Equivalence] + [(poly.like Text) text.Equivalence])) + ## Composite types + (~~ (do-template [ ] + [(do @ + [[_ argC] (poly.apply (p.seq (poly.this ) + Equivalence))] + (wrap (` (: (~ (@Equivalence inputT)) + ( (~ argC))))))] + + [.Maybe maybe.Equivalence] + [.List list.Equivalence] + [row.Row row.Equivalence] + [.Array array.Equivalence] + [queue.Queue queue.Equivalence] + [set.Set set.Equivalence] + [rose.Tree rose.Equivalence] + )) + (do @ + [[_ _ valC] (poly.apply ($_ p.seq + (poly.this dict.Dict) + poly.any + Equivalence))] + (wrap (` (: (~ (@Equivalence inputT)) + (dict.Equivalence (~ valC)))))) + ## Models + (~~ (do-template [ ] + [(do @ + [_ (poly.this )] + (wrap (` (: (~ (@Equivalence inputT)) + ))))] + + [du.Duration du.Equivalence] + [i.Instant i.Equivalence] + [da.Date da.Equivalence] + [da.Day da.Equivalence] + [da.Month da.Equivalence])) + (do @ + [_ (poly.apply (p.seq (poly.this unit.Qty) + poly.any))] + (wrap (` (: (~ (@Equivalence inputT)) + unit.Equivalence)))) + ## Variants + (do @ + [members (poly.variant (p.many Equivalence)) + #let [g!_ (code.local-symbol "_____________") + g!left (code.local-symbol "_____________left") + g!right (code.local-symbol "_____________right")]] + (wrap (` (: (~ (@Equivalence inputT)) + (function ((~ g!_) (~ g!left) (~ g!right)) + (case [(~ g!left) (~ g!right)] + (~+ (list/join (list/map (function (_ [tag g!eq]) + (list (` [((~ (code.nat tag)) (~ g!left)) + ((~ (code.nat tag)) (~ g!right))]) + (` ((~ g!eq) (~ g!left) (~ g!right))))) + (list.enumerate members)))) + (~ g!_) + false)))))) + ## Tuples + (do @ + [g!eqs (poly.tuple (p.many Equivalence)) + #let [g!_ (code.local-symbol "_____________") + indices (|> (list.size g!eqs) dec (list.n/range +0)) + g!lefts (list/map (|>> nat/encode (text/compose "left") code.local-symbol) indices) + g!rights (list/map (|>> nat/encode (text/compose "right") code.local-symbol) indices)]] + (wrap (` (: (~ (@Equivalence inputT)) + (function ((~ g!_) [(~+ g!lefts)] [(~+ g!rights)]) + (and (~+ (|> (list.zip3 g!eqs g!lefts g!rights) + (list/map (function (_ [g!eq g!left g!right]) + (` ((~ g!eq) (~ g!left) (~ g!right))))))))))))) + ## Type recursion + (do @ + [[g!self bodyC] (poly.recursive Equivalence) + #let [g!_ (code.local-symbol "_____________")]] + (wrap (` (: (~ (@Equivalence inputT)) + (eq.rec (.function ((~ g!_) (~ g!self)) + (~ bodyC))))))) + poly.recursive-self + ## Type applications + (do @ + [[funcC argsC] (poly.apply (p.seq Equivalence (p.many Equivalence)))] + (wrap (` ((~ funcC) (~+ argsC))))) + ## Parameters + poly.parameter + ## Polymorphism + (do @ + [[funcC varsC bodyC] (poly.polymorphic Equivalence)] + (wrap (` (: (All [(~+ varsC)] + (-> (~+ (list/map (|>> (~) eq.Equivalence (`)) varsC)) + (eq.Equivalence ((~ (poly.to-code *env* inputT)) (~+ varsC))))) + (function ((~ funcC) (~+ varsC)) + (~ bodyC)))))) + poly.recursive-call + ## If all else fails... + (|> poly.any + (:: @ map (|>> %type (format "Cannot create Equivalence for: ") p.fail)) + (:: @ join)) + )))) diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index dac1874e9..775b86b69 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Codecs for values in the JSON format."} lux (lux (control [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Eq] codec ["p" parser "p/" Monad]) (data [bool] diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 7e787ec95..3b0efaa8a 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -2,7 +2,7 @@ [lux #- nat int rev] (lux [macro #+ with-gensyms] (control [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] ["p" parser]) (data [bool] [number] @@ -11,7 +11,7 @@ (coll [list "list/" Functor]) [maybe] [error #+ Error])) - (// [code "code/" Eq])) + (// [code "code/" Equivalence])) ## [Utils] (def: (join-pairs pairs) @@ -52,14 +52,14 @@ _ (#error.Error ($_ text/compose "Cannot parse " (remaining-inputs tokens))))))] - [ bool Bool #.Bool bool.Eq "bool"] - [ nat Nat #.Nat number.Eq "nat"] - [ int Int #.Int number.Eq "int"] - [ rev Rev #.Rev number.Eq "rev"] - [ frac Frac #.Frac number.Eq "frac"] - [ text Text #.Text text.Eq "text"] - [symbol Ident #.Symbol ident.Eq "symbol"] - [ tag Ident #.Tag ident.Eq "tag"] + [ bool Bool #.Bool bool.Equivalence "bool"] + [ nat Nat #.Nat number.Equivalence "nat"] + [ int Int #.Int number.Equivalence "int"] + [ rev Rev #.Rev number.Equivalence "rev"] + [ frac Frac #.Frac number.Equivalence "frac"] + [ text Text #.Text text.Equivalence "text"] + [symbol Ident #.Symbol ident.Equivalence "symbol"] + [ tag Ident #.Tag ident.Equivalence "tag"] ) (def: #export (this? ast) diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux index c84cc5624..0237d579a 100644 --- a/stdlib/source/lux/macro/syntax/common/reader.lux +++ b/stdlib/source/lux/macro/syntax/common/reader.lux @@ -3,7 +3,7 @@ (lux (control monad ["p" parser "p/" Monad]) (data (coll [list]) - [ident "ident/" Eq] + [ident "ident/" Equivalence] [product] [maybe]) [macro] diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index 2a937c84d..f4680a6ca 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control equality + (lux (control equivalence order enum codec @@ -29,7 +29,7 @@ #November #December) -(struct: #export _ (Eq Month) +(struct: #export _ (Equivalence Month) (def: (= reference sample) (case [reference sample] (^template [] @@ -68,7 +68,7 @@ #December +11)) (struct: #export _ (Order Month) - (def: eq Eq) + (def: eq Equivalence) (do-template [ ] [(def: ( reference sample) ( (month-to-nat reference) (month-to-nat sample)))] @@ -119,7 +119,7 @@ #Friday #Saturday) -(struct: #export _ (Eq Day) +(struct: #export _ (Equivalence Day) (def: (= reference sample) (case [reference sample] (^template [] @@ -148,7 +148,7 @@ #Saturday +6)) (struct: #export _ (Order Day) - (def: eq Eq) + (def: eq Equivalence) (do-template [ ] [(def: ( reference sample) ( (day-to-nat reference) (day-to-nat sample)))] @@ -185,11 +185,11 @@ #month Month #day Nat}) -(struct: #export _ (Eq Date) +(struct: #export _ (Equivalence Date) (def: (= reference sample) (and (i/= (get@ #year reference) (get@ #year sample)) - (:: Eq = + (:: Equivalence = (get@ #month reference) (get@ #month sample)) (n/= (get@ #day reference) @@ -206,16 +206,16 @@ (get@ #day sample)))) (struct: #export _ (Order Date) - (def: eq Eq) + (def: eq Equivalence) (def: < date/<) (def: (> reference sample) (date/< sample reference)) (def: (<= reference sample) (or (date/< reference sample) - (:: Eq = reference sample))) + (:: Equivalence = reference sample))) (def: (>= reference sample) (or (date/< sample reference) - (:: Eq = sample reference)))) + (:: Equivalence = sample reference)))) ## Based on this: https://stackoverflow.com/a/42936293/6823464 (def: (pad value) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index a29eda6da..5df655018 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -1,6 +1,6 @@ (.module: lux - (lux (control equality + (lux (control equivalence order codec [monoid #+ Monoid] @@ -41,12 +41,12 @@ (-> Duration Duration Int) (i// (:representation param) (:representation subject))) - (struct: #export _ (Eq Duration) + (struct: #export _ (Equivalence Duration) (def: (= param subject) (i/= (:representation param) (:representation subject)))) (struct: #export _ (Order Duration) - (def: eq Eq) + (def: eq Equivalence) (do-template [ ] [(def: ( param subject) ( (:representation param) (:representation subject)))] @@ -83,7 +83,7 @@ (def: (encode duration) (-> Duration Text) - (if (:: Eq = empty duration) + (if (:: Equivalence = empty duration) "0ms" (let [signed? (negative? duration) [days time-left] [(query day duration) (frame day duration)] diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index 68a86bf9d..4f14555f9 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -1,7 +1,7 @@ (.module: lux (lux [io #- run] - (control equality + (control equivalence order enum codec @@ -46,12 +46,12 @@ (-> duration.Duration Instant) (|> offset duration.to-millis :abstraction)) - (struct: #export _ (Eq Instant) + (struct: #export _ (Equivalence Instant) (def: (= param subject) - (:: number.Eq = (:representation param) (:representation subject)))) + (:: number.Equivalence = (:representation param) (:representation subject)))) (struct: #export _ (Order Instant) - (def: eq Eq) + (def: eq Equivalence) (do-template [] [(def: ( param subject) (:: number.Order (:representation param) (:representation subject)))] diff --git a/stdlib/source/lux/type/abstract.lux b/stdlib/source/lux/type/abstract.lux index f7594852d..d9aa8a8bb 100644 --- a/stdlib/source/lux/type/abstract.lux +++ b/stdlib/source/lux/type/abstract.lux @@ -2,7 +2,7 @@ lux (lux (control [monad #+ do Monad] ["p" parser]) - (data [text "text/" Eq Monoid] + (data [text "text/" Equivalence Monoid] [error] (coll [list "list/" Functor Monoid])) [macro #+ "meta/" Monad] diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux index 84bff5ec9..b7e970685 100644 --- a/stdlib/source/lux/type/implicit.lux +++ b/stdlib/source/lux/type/implicit.lux @@ -1,9 +1,9 @@ (.module: lux (lux (control [monad #+ do Monad] - ["eq" equality] + ["eq" equivalence] ["p" parser]) - (data [text "text/" Eq] + (data [text "text/" Equivalence] text/format [number] (coll [list "list/" Monad Fold] @@ -318,12 +318,12 @@ "If no alternative is found, or if more than one alternative is found (ambiguity)" "a compile-time error will be raised, to alert the user." "Examples:" - "Nat equality" - (:: number.Eq = x y) + "Nat equivalence" + (:: number.Equivalence = x y) (::: = x y) "Can optionally add the prefix of the module where the signature was defined." (::: eq.= x y) - "(List Nat) equality" + "(List Nat) equivalence" (::: = (list.n/range +1 +10) (list.n/range +1 +10)) diff --git a/stdlib/source/lux/type/object/interface.lux b/stdlib/source/lux/type/object/interface.lux index e4b08c9ac..80bf6cd3f 100644 --- a/stdlib/source/lux/type/object/interface.lux +++ b/stdlib/source/lux/type/object/interface.lux @@ -6,7 +6,7 @@ text/format [product] [maybe] - [ident #+ "ident/" Eq] + [ident #+ "ident/" Equivalence] (coll [list "list/" Functor Fold Monoid] (set ["set" unordered #+ Set]))) [macro #+ Monad "meta/" Monad] diff --git a/stdlib/source/lux/type/refinement.lux b/stdlib/source/lux/type/refinement.lux index afc190c4f..39b6393ce 100644 --- a/stdlib/source/lux/type/refinement.lux +++ b/stdlib/source/lux/type/refinement.lux @@ -4,7 +4,7 @@ [monad #+ do] ["p" parser]) (data ["e" error #+ Error]) - (lang [type "type/" Eq]) + (lang [type "type/" Equivalence]) (type abstract) [macro] (macro ["s" syntax #+ syntax:] diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux index 0b5e2dcec..5072a677f 100644 --- a/stdlib/source/lux/type/unit.lux +++ b/stdlib/source/lux/type/unit.lux @@ -2,7 +2,7 @@ lux (lux (control [monad #+ do Monad] ["p" parser "p/" Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] [order #+ Order] [enum #+ Enum]) (data text/format @@ -156,12 +156,12 @@ (unit: #export Litre) (unit: #export Second) -(struct: #export Eq (All [unit] (Eq (Qty unit))) +(struct: #export Equivalence (All [unit] (Equivalence (Qty unit))) (def: (= reference sample) (i/= (out reference) (out sample)))) (struct: #export Order (All [unit] (Order (Qty unit))) - (def: eq Eq) + (def: eq Equivalence) (do-template [ ] [(def: ( reference sample) diff --git a/stdlib/source/lux/world/blob.jvm.lux b/stdlib/source/lux/world/blob.jvm.lux index 3d30d2b93..162574ba9 100644 --- a/stdlib/source/lux/world/blob.jvm.lux +++ b/stdlib/source/lux/world/blob.jvm.lux @@ -2,7 +2,7 @@ [lux #- i64] (lux (control [monad #+ do] ["ex" exception #+ exception:] - ["eq" equality]) + ["eq" equivalence]) (data [bit] [maybe] ["e" error] @@ -140,6 +140,6 @@ (-> Nat Blob (e.Error Blob)) (slice from (dec (host.array-length blob)) blob)) -(struct: #export _ (eq.Eq Blob) +(struct: #export _ (eq.Equivalence Blob) (def: (= reference sample) (Arrays::equals [reference sample]))) diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index fc649eec3..211cf6d6b 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -6,7 +6,7 @@ ["r" math/random] (data [maybe] [bit] - [text "text/" Eq] + [text "text/" Equivalence] text/format) [macro] (macro ["s" syntax #+ syntax:]))) diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux index 4aed244b2..b8bc50e9e 100644 --- a/stdlib/test/test/lux/cli.lux +++ b/stdlib/test/test/lux/cli.lux @@ -8,7 +8,7 @@ [sum] ["E" error] [number] - [text "text/" Eq] + [text "text/" Equivalence] text/format (coll [list])) ["r" math/random] diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index 6de1634ec..8a1e04849 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -29,7 +29,7 @@ (wrap output))) (context: "FRP" - (let [(^open "list/") (list.Eq number.Eq)] + (let [(^open "list/") (list.Equivalence number.Equivalence)] ($_ seq (wrap (do promise.Monad [#let [values (list 0 1 2 3 4 5)] diff --git a/stdlib/test/test/lux/concurrency/semaphore.lux b/stdlib/test/test/lux/concurrency/semaphore.lux index b360426c5..0100ee2ac 100644 --- a/stdlib/test/test/lux/concurrency/semaphore.lux +++ b/stdlib/test/test/lux/concurrency/semaphore.lux @@ -2,7 +2,7 @@ lux (lux (control [monad #+ do]) (data [maybe] - [text "text/" Eq Monoid] + [text "text/" Equivalence Monoid] text/format (coll [list "list/" Functor])) (concurrency ["/" semaphore] diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux index 9f3c5bd7e..4bebfa3e7 100644 --- a/stdlib/test/test/lux/concurrency/stm.lux +++ b/stdlib/test/test/lux/concurrency/stm.lux @@ -54,7 +54,7 @@ _ (&.commit (&.update (n/* +3) _var)) changes (promise.future (atom.read changes))] (assert "Can follow all the changes to STM vars." - (:: (list.Eq number.Eq) = + (:: (list.Equivalence number.Equivalence) = (list +5 +15) (list.reverse changes))))) (wrap (let [_concurrency-var (&.var +0)] diff --git a/stdlib/test/test/lux/control/continuation.lux b/stdlib/test/test/lux/control/continuation.lux index ea43b511d..bda63e3e1 100644 --- a/stdlib/test/test/lux/control/continuation.lux +++ b/stdlib/test/test/lux/control/continuation.lux @@ -57,7 +57,7 @@ (test "Can use delimited continuations with shifting." (let [(^open "&/") &.Monad - (^open "L/") (list.Eq number.Eq) + (^open "L/") (list.Equivalence number.Equivalence) visit (: (-> (List Nat) (&.Cont (List Nat) (List Nat))) (function (visit xs) diff --git a/stdlib/test/test/lux/control/equality.lux b/stdlib/test/test/lux/control/equality.lux deleted file mode 100644 index 5139b41ea..000000000 --- a/stdlib/test/test/lux/control/equality.lux +++ /dev/null @@ -1,19 +0,0 @@ -(.module: - lux - (lux (control ["/" equality] - [monad #+ do]) - (math ["r" random]) - test)) - -(def: #export (spec Eq generator) - (All [a] (-> (/.Eq a) (r.Random a) Test)) - (do r.Monad - [sample generator - another generator] - ($_ seq - (test "Equality is reflexive." - (:: Eq = sample sample)) - (test "Equality is symmetric." - (if (:: Eq = sample another) - (:: Eq = another sample) - true))))) diff --git a/stdlib/test/test/lux/control/equivalence.lux b/stdlib/test/test/lux/control/equivalence.lux new file mode 100644 index 000000000..18265af6c --- /dev/null +++ b/stdlib/test/test/lux/control/equivalence.lux @@ -0,0 +1,19 @@ +(.module: + lux + (lux (control ["/" equivalence] + [monad #+ do]) + (math ["r" random]) + test)) + +(def: #export (spec Equivalence generator) + (All [a] (-> (/.Equivalence a) (r.Random a) Test)) + (do r.Monad + [sample generator + another generator] + ($_ seq + (test "Equivalence is reflexive." + (:: Equivalence = sample sample)) + (test "Equivalence is symmetric." + (if (:: Equivalence = sample another) + (:: Equivalence = another sample) + true))))) diff --git a/stdlib/test/test/lux/control/interval.lux b/stdlib/test/test/lux/control/interval.lux index 3187c0b7b..06fe5cbde 100644 --- a/stdlib/test/test/lux/control/interval.lux +++ b/stdlib/test/test/lux/control/interval.lux @@ -11,12 +11,12 @@ (coll ["S" set/unordered] ["L" list])))) -(context: "Equality." +(context: "Equivalence." (<| (times +100) (do @ [bottom r.int top r.int - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] ($_ seq (test "Every interval is equal to itself." (and (let [self (&.between number.Enum bottom top)] @@ -92,7 +92,7 @@ right-singleton gen-singleton left-outer gen-outer right-outer gen-outer - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] ($_ seq (test "The union of an interval to itself yields the same interval." (&/= some-interval (&.union some-interval some-interval))) @@ -114,7 +114,7 @@ right-singleton gen-singleton left-outer gen-outer right-outer gen-outer - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] ($_ seq (test "The intersection of an interval to itself yields the same interval." (&/= some-interval (&.intersection some-interval some-interval))) @@ -130,7 +130,7 @@ (<| (times +100) (do @ [some-interval gen-interval - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] ($_ seq (test "The complement of a complement is the same as the original." (&/= some-interval (|> some-interval &.complement &.complement))) diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index fd1f67724..c7293c2ee 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -2,7 +2,7 @@ lux (lux [io] (control ["M" monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] ["&" parser] pipe) (data [text "Text/" Monoid] diff --git a/stdlib/test/test/lux/control/pipe.lux b/stdlib/test/test/lux/control/pipe.lux index d159cfeb9..1288b5302 100644 --- a/stdlib/test/test/lux/control/pipe.lux +++ b/stdlib/test/test/lux/control/pipe.lux @@ -7,7 +7,7 @@ [number] [product] identity - [text "text/" Eq]) + [text "text/" Equivalence]) ["r" math/random]) lux/test) diff --git a/stdlib/test/test/lux/control/writer.lux b/stdlib/test/test/lux/control/writer.lux index 49335de0d..35df0ae06 100644 --- a/stdlib/test/test/lux/control/writer.lux +++ b/stdlib/test/test/lux/control/writer.lux @@ -4,7 +4,7 @@ (control ["M" monad #+ do Monad] pipe ["&" writer]) - (data [text "Text/" Monoid Eq] + (data [text "Text/" Monoid Equivalence] [number] [product])) lux/test) diff --git a/stdlib/test/test/lux/data/bool.lux b/stdlib/test/test/lux/data/bool.lux index d7bc88e87..ead88f0db 100644 --- a/stdlib/test/test/lux/data/bool.lux +++ b/stdlib/test/test/lux/data/bool.lux @@ -18,17 +18,17 @@ (:: And@Monoid identity) (not (:: And@Monoid compose value (not value))) - (:: Eq = value (not (not value))) - (not (:: Eq = value (not value))) + (:: Equivalence = value (not (not value))) + (not (:: Equivalence = value (not value))) - (not (:: Eq = value ((complement id) value))) - (:: Eq = value ((complement not) value)) + (not (:: Equivalence = value ((complement id) value))) + (:: Equivalence = value ((complement not) value)) (case (|> value (:: Codec encode) (:: Codec decode)) (#.Right dec-value) - (:: Eq = value dec-value) + (:: Equivalence = value dec-value) (#.Left _) false) diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux index 125694cc7..c29baefc3 100644 --- a/stdlib/test/test/lux/data/coll/array.lux +++ b/stdlib/test/test/lux/data/coll/array.lux @@ -29,11 +29,11 @@ (test "Size function must correctly return size of array." (n/= size (@.size original))) (test "Cloning an array should yield and identical array, but not the same one." - (and (:: (@.Eq number.Eq) = original clone) + (and (:: (@.Equivalence number.Equivalence) = original clone) (not (is? original clone)))) (test "Full-range manual copies should give the same result as cloning." (exec (@.copy size +0 original +0 copy) - (and (:: (@.Eq number.Eq) = original copy) + (and (:: (@.Equivalence number.Equivalence) = original copy) (not (is? original copy))))) (test "Array folding should go over all values." (exec (:: @.Fold fold @@ -42,11 +42,11 @@ (inc idx))) +0 original) - (:: (@.Eq number.Eq) = original manual-copy))) + (:: (@.Equivalence number.Equivalence) = original manual-copy))) (test "Transformations between (full) arrays and lists shouldn't cause lose or change any values." (|> original @.to-list @.from-list - (:: (@.Eq number.Eq) = original))) + (:: (@.Equivalence number.Equivalence) = original))) )))) (context: "Array mutation" @@ -102,7 +102,7 @@ [size bounded-size array (r.array size r.nat)] (let [(^open) @.Functor - (^open) (@.Eq number.Eq)] + (^open) (@.Equivalence number.Equivalence)] ($_ seq (test "Functor shouldn't alter original array." (let [copy (map id array)] @@ -122,7 +122,7 @@ left (r.array sizeL r.nat) right (r.array sizeR r.nat) #let [(^open) @.Monoid - (^open) (@.Eq number.Eq) + (^open) (@.Equivalence number.Equivalence) fusion (compose left right)]] ($_ seq (test "Appending two arrays should produce a new one twice as large." diff --git a/stdlib/test/test/lux/data/coll/bits.lux b/stdlib/test/test/lux/data/coll/bits.lux index a5141034c..0fbe2edb2 100644 --- a/stdlib/test/test/lux/data/coll/bits.lux +++ b/stdlib/test/test/lux/data/coll/bits.lux @@ -5,7 +5,7 @@ (data (coll ["/" bits])) ["r" math/random]) lux/test - (test (lux (control ["_eq" equality])))) + (test (lux (control ["_eq" equivalence])))) (def: (size min max) (-> Nat Nat (r.Random Nat)) @@ -57,7 +57,7 @@ (not (/.intersects? sample (/.not sample)))) (test "'and' with oneself changes nothing" - (:: /.Eq = sample (/.and sample sample))) + (:: /.Equivalence = sample (/.and sample sample))) (test "'and' with one's opposite yields the empty bit-set." (is? /.empty (/.and sample (/.not sample)))) @@ -72,9 +72,9 @@ (/.capacity sample))) (test "Double negation results in original bit-set." - (:: /.Eq = sample (/.not (/.not sample)))) + (:: /.Equivalence = sample (/.not (/.not sample)))) (test "Negation does not affect the empty bit-set." (is? /.empty (/.not /.empty))) - (_eq.spec /.Eq ..bits) + (_eq.spec /.Equivalence ..bits) )))) diff --git a/stdlib/test/test/lux/data/coll/dictionary/ordered.lux b/stdlib/test/test/lux/data/coll/dictionary/ordered.lux index a373f6107..bb13ac532 100644 --- a/stdlib/test/test/lux/data/coll/dictionary/ordered.lux +++ b/stdlib/test/test/lux/data/coll/dictionary/ordered.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [monad #+ do Monad] - [equality #+ Eq]) + [equivalence #+ Equivalence]) (data [product] [number] (coll (set ["s" unordered]) @@ -27,7 +27,7 @@ (n/< left right)) pairs) sorted-values (L/map product.right sorted-pairs) - (^open "&/") (&.Eq number.Eq)]] + (^open "&/") (&.Equivalence number.Equivalence)]] ($_ seq (test "Can query the size of a dictionary." (n/= size (&.size sample))) @@ -60,10 +60,10 @@ (&/= sample))) (test "Order is preserved." - (let [(^open "L/") (list.Eq (: (Eq [Nat Nat]) - (function (_ [kr vr] [ks vs]) - (and (n/= kr ks) - (n/= vr vs)))))] + (let [(^open "L/") (list.Equivalence (: (Equivalence [Nat Nat]) + (function (_ [kr vr] [ks vs]) + (and (n/= kr ks) + (n/= vr vs)))))] (L/= (&.entries sample) sorted-pairs))) diff --git a/stdlib/test/test/lux/data/coll/dictionary/unordered.lux b/stdlib/test/test/lux/data/coll/dictionary/unordered.lux index 93b83dc7b..bde4810a5 100644 --- a/stdlib/test/test/lux/data/coll/dictionary/unordered.lux +++ b/stdlib/test/test/lux/data/coll/dictionary/unordered.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [monad #+ do Monad] - ["eq" equality]) + ["eq" equivalence]) (data [text] text/format [number] @@ -19,7 +19,7 @@ size capped-nat dict (r.dict number.Hash size r.nat capped-nat) non-key (|> r.nat (r.filter (function (_ key) (not (&.contains? key dict))))) - test-val (|> r.nat (r.filter (function (_ val) (not (list.member? number.Eq (&.values dict) val)))))] + test-val (|> r.nat (r.filter (function (_ val) (not (list.member? number.Equivalence (&.values dict) val)))))] ($_ seq (test "Size function should correctly represent Dict size." (n/= size (&.size dict))) @@ -30,7 +30,7 @@ (not (&.empty? dict)))) (test "The functions 'entries', 'keys' and 'values' should be synchronized." - (:: (list.Eq (eq.product number.Eq number.Eq)) = + (:: (list.Equivalence (eq.product number.Equivalence number.Equivalence)) = (&.entries dict) (list.zip2 (&.keys dict) (&.values dict)))) @@ -89,19 +89,19 @@ (n/= (dec (&.size plus)) (&.size base))))) (test "A Dict should equal itself & going to<->from lists shouldn't change that." - (let [(^open) (&.Eq number.Eq)] + (let [(^open) (&.Equivalence number.Equivalence)] (and (= dict dict) (|> dict &.entries (&.from-list number.Hash) (= dict))))) (test "Merging a Dict to itself changes nothing." - (let [(^open) (&.Eq number.Eq)] + (let [(^open) (&.Equivalence number.Equivalence)] (= dict (&.merge dict dict)))) (test "If you merge, and the second dict has overlapping keys, it should overwrite yours." (let [dict' (|> dict &.entries (list/map (function (_ [k v]) [k (inc v)])) (&.from-list number.Hash)) - (^open) (&.Eq number.Eq)] + (^open) (&.Equivalence number.Equivalence)] (= dict' (&.merge dict' dict)))) (test "Can merge values in such a way that they become combined." diff --git a/stdlib/test/test/lux/data/coll/list.lux b/stdlib/test/test/lux/data/coll/list.lux index 73eb25d85..d57b19b9c 100644 --- a/stdlib/test/test/lux/data/coll/list.lux +++ b/stdlib/test/test/lux/data/coll/list.lux @@ -25,7 +25,7 @@ other-size bounded-size other-sample (r.list other-size r.nat) separator r.nat - #let [(^open) (&.Eq number.Eq) + #let [(^open) (&.Equivalence number.Equivalence) (^open "&/") &.Functor]] ($_ seq (test "The size function should correctly portray the size of the list." @@ -59,7 +59,7 @@ (test "Any element of the list can be considered its member." (let [elem (maybe.assume (&.nth idx sample))] - (&.member? number.Eq sample elem))) + (&.member? number.Equivalence sample elem))) )))) (context: "Lists: Part 2" @@ -71,7 +71,7 @@ other-size bounded-size other-sample (r.list other-size r.nat) separator r.nat - #let [(^open) (&.Eq number.Eq) + #let [(^open) (&.Equivalence number.Equivalence) (^open "&/") &.Functor]] ($_ seq (test "Appending the head and the tail should yield the original list." @@ -134,7 +134,7 @@ separator r.nat from (|> r.nat (:: @ map (n/% +10))) to (|> r.nat (:: @ map (n/% +10))) - #let [(^open) (&.Eq number.Eq) + #let [(^open) (&.Equivalence number.Equivalence) (^open "&/") &.Functor]] ($_ seq (test "If you zip 2 lists, the result's size will be that of the smaller list." @@ -212,10 +212,10 @@ (&/map product.right enum-sample))))) (test "Ranges can be constructed forward and backwards." - (and (let [(^open "list/") (&.Eq number.Eq)] + (and (let [(^open "list/") (&.Equivalence number.Equivalence)] (list/= (&.n/range from to) (&.reverse (&.n/range to from)))) - (let [(^open "list/") (&.Eq number.Eq) + (let [(^open "list/") (&.Equivalence number.Equivalence) from (.int from) to (.int to)] (list/= (&.i/range from to) diff --git a/stdlib/test/test/lux/data/coll/queue.lux b/stdlib/test/test/lux/data/coll/queue.lux index 7edcbf9b4..12d924963 100644 --- a/stdlib/test/test/lux/data/coll/queue.lux +++ b/stdlib/test/test/lux/data/coll/queue.lux @@ -13,7 +13,7 @@ [size (:: @ map (n/% +100) r.nat) sample (r.queue size r.nat) non-member (|> r.nat - (r.filter (|>> (&.member? number.Eq sample) not)))] + (r.filter (|>> (&.member? number.Equivalence sample) not)))] ($_ seq (test "I can query the size of a queue (and empty queues have size 0)." (if (n/= +0 size) @@ -27,7 +27,7 @@ (n/= size (&.size (&.pop (&.push non-member sample)))))) (test "Transforming to/from list can't change the queue." - (let [(^open "&/") (&.Eq number.Eq)] + (let [(^open "&/") (&.Equivalence number.Equivalence)] (|> sample &.to-list &.from-list (&/= sample)))) @@ -38,14 +38,14 @@ (#.Some _) true)) (test "I can query whether an element belongs to a queue." - (and (not (&.member? number.Eq sample non-member)) - (&.member? number.Eq (&.push non-member sample) + (and (not (&.member? number.Equivalence sample non-member)) + (&.member? number.Equivalence (&.push non-member sample) non-member) (case (&.peek sample) #.None (&.empty? sample) (#.Some first) - (and (&.member? number.Eq sample first) - (not (&.member? number.Eq (&.pop sample) first)))))) + (and (&.member? number.Equivalence sample first) + (not (&.member? number.Equivalence (&.pop sample) first)))))) )))) diff --git a/stdlib/test/test/lux/data/coll/queue/priority.lux b/stdlib/test/test/lux/data/coll/queue/priority.lux index 38527523a..17664056c 100644 --- a/stdlib/test/test/lux/data/coll/queue/priority.lux +++ b/stdlib/test/test/lux/data/coll/queue/priority.lux @@ -25,7 +25,7 @@ [size (|> r.nat (:: @ map (n/% +100))) sample (gen-queue size) non-member-priority r.nat - non-member (|> r.nat (r.filter (|>> (&.member? number.Eq sample) not)))] + non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not)))] ($_ seq (test "I can query the size of a queue (and empty queues have size 0)." (n/= size (&.size sample))) @@ -38,15 +38,15 @@ (&.size (&.pop sample)))))) (test "I can query whether an element belongs to a queue." - (and (and (not (&.member? number.Eq sample non-member)) - (&.member? number.Eq + (and (and (not (&.member? number.Equivalence sample non-member)) + (&.member? number.Equivalence (&.push non-member-priority non-member sample) non-member)) (or (n/= +0 (&.size sample)) - (and (&.member? number.Eq + (and (&.member? number.Equivalence sample (maybe.assume (&.peek sample))) - (not (&.member? number.Eq + (not (&.member? number.Equivalence (&.pop sample) (maybe.assume (&.peek sample)))))))) )))) diff --git a/stdlib/test/test/lux/data/coll/row.lux b/stdlib/test/test/lux/data/coll/row.lux index 3a4da0f42..643dcbe24 100644 --- a/stdlib/test/test/lux/data/coll/row.lux +++ b/stdlib/test/test/lux/data/coll/row.lux @@ -16,8 +16,8 @@ idx (|> r.nat (:: @ map (n/% size))) sample (r.row size r.nat) other-sample (r.row size r.nat) - non-member (|> r.nat (r.filter (|>> (&.member? number.Eq sample) not))) - #let [(^open "&/") (&.Eq number.Eq) + non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not))) + #let [(^open "&/") (&.Equivalence number.Equivalence) (^open "&/") &.Apply (^open "&/") &.Monad (^open "&/") &.Fold @@ -50,8 +50,8 @@ (|> sample &.to-list &.from-list (&/= sample))) (test "Can identify members of a row." - (and (not (&.member? number.Eq sample non-member)) - (&.member? number.Eq (&.add non-member sample) non-member))) + (and (not (&.member? number.Equivalence sample non-member)) + (&.member? number.Equivalence (&.add non-member sample) non-member))) (test "Can fold over elements of row." (n/= (list/fold n/+ +0 (&.to-list sample)) diff --git a/stdlib/test/test/lux/data/coll/sequence.lux b/stdlib/test/test/lux/data/coll/sequence.lux index 44eea350b..d1e91bcd1 100644 --- a/stdlib/test/test/lux/data/coll/sequence.lux +++ b/stdlib/test/test/lux/data/coll/sequence.lux @@ -21,7 +21,7 @@ elem r.nat cycle-seed (r.list size r.nat) cycle-sample-idx (|> r.nat (:: @ map (n/% +1000))) - #let [(^open "List/") (list.Eq number.Eq) + #let [(^open "List/") (list.Equivalence number.Equivalence) sample0 (&.iterate inc +0) sample1 (&.iterate inc offset)]] ($_ seq @@ -84,7 +84,7 @@ (test "'unfold' generalizes 'iterate'." (let [(^open "&/") &.Functor - (^open "List/") (list.Eq text.Eq)] + (^open "List/") (list.Equivalence text.Equivalence)] (List/= (&.take size (&/map Nat/encode (&.iterate inc offset))) (&.take size diff --git a/stdlib/test/test/lux/data/coll/set/ordered.lux b/stdlib/test/test/lux/data/coll/set/ordered.lux index cb78ad963..fd4fb5579 100644 --- a/stdlib/test/test/lux/data/coll/set/ordered.lux +++ b/stdlib/test/test/lux/data/coll/set/ordered.lux @@ -22,7 +22,7 @@ sizeR gen-nat listL (|> (r.set number.Hash sizeL gen-nat) (:: @ map s.to-list)) listR (|> (r.set number.Hash sizeR gen-nat) (:: @ map s.to-list)) - #let [(^open "&/") &.Eq + #let [(^open "&/") &.Equivalence setL (&.from-list number.Order listL) setR (&.from-list number.Order listR) sortedL (list.sort n/< listL) @@ -61,7 +61,7 @@ (test "Order is preserved." (let [listL (&.to-list setL) - (^open "L/") (list.Eq number.Eq)] + (^open "L/") (list.Equivalence number.Equivalence)] (L/= listL (list.sort n/< listL)))) diff --git a/stdlib/test/test/lux/data/coll/set/unordered.lux b/stdlib/test/test/lux/data/coll/set/unordered.lux index bdb896e8b..f17867665 100644 --- a/stdlib/test/test/lux/data/coll/set/unordered.lux +++ b/stdlib/test/test/lux/data/coll/set/unordered.lux @@ -22,7 +22,7 @@ setR (r.set number.Hash sizeR gen-nat) non-member (|> gen-nat (r.filter (|>> (&.member? setL) not))) - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] ($_ seq (test "I can query the size of a set." (and (n/= sizeL (&.size setL)) diff --git a/stdlib/test/test/lux/data/coll/tree/rose.lux b/stdlib/test/test/lux/data/coll/tree/rose.lux index fdc385515..133f2ef20 100644 --- a/stdlib/test/test/lux/data/coll/tree/rose.lux +++ b/stdlib/test/test/lux/data/coll/tree/rose.lux @@ -4,7 +4,7 @@ (control [monad #+ do Monad]) (data [product] [number] - [text "T/" Eq] + [text "T/" Equivalence] text/format (coll (tree ["&" rose]) [list "L/" Monad Fold])) @@ -30,11 +30,11 @@ (<| (times +100) (do @ [[size sample] gen-tree - #let [(^open "&/") (&.Eq number.Eq) + #let [(^open "&/") (&.Equivalence number.Equivalence) (^open "&/") &.Fold concat (function (_ addition partial) (format partial (%n addition)))]] ($_ seq - (test "Can compare trees for equality." + (test "Can compare trees for equivalence." (&/= sample sample)) (test "Can flatten a tree to get all the nodes as a flat tree." diff --git a/stdlib/test/test/lux/data/coll/tree/rose/zipper.lux b/stdlib/test/test/lux/data/coll/tree/rose/zipper.lux index ff52e706d..0f5eff838 100644 --- a/stdlib/test/test/lux/data/coll/tree/rose/zipper.lux +++ b/stdlib/test/test/lux/data/coll/tree/rose/zipper.lux @@ -36,8 +36,8 @@ new-val r.nat pre-val r.nat post-val r.nat - #let [(^open "tree/") (rose.Eq number.Eq) - (^open "list/") (list.Eq number.Eq)]] + #let [(^open "tree/") (rose.Equivalence number.Equivalence) + (^open "list/") (list.Equivalence number.Equivalence)]] ($_ seq (test "Trees can be converted to/from zippers." (|> sample diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux index 58bba6749..776862749 100644 --- a/stdlib/test/test/lux/data/color.lux +++ b/stdlib/test/test/lux/data/color.lux @@ -57,8 +57,8 @@ (f/<= 0.75 saturation))))))) ratio (|> r.frac (r.filter (f/>= 0.5)))] ($_ seq - (test "Has equality." - (:: @.Eq = any any)) + (test "Has equivalence." + (:: @.Equivalence = any any)) (test "Can convert to/from HSL." (|> any @.to-hsl @.from-hsl (distance any) @@ -78,7 +78,7 @@ (distance (@.brighter ratio colorful) white)))) (test "Can calculate complement." (let [~any (@.complement any) - (^open "@/") @.Eq] + (^open "@/") @.Equivalence] (and (not (@/= any ~any)) (@/= any (@.complement ~any))))) (test "Can saturate color." diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index b3196e1e6..e630b7a49 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -3,7 +3,7 @@ (lux [io] (control [monad #+ do Monad] codec - [equality #+ Eq] + [equivalence #+ Equivalence] pipe ["p" parser]) (data [text] @@ -20,7 +20,7 @@ (macro [code] [syntax #+ syntax:] [poly #+ derived:] - [poly/equality] + [poly/equivalence] [poly/json]) (type [unit]) ["r" math/random] @@ -51,7 +51,7 @@ (<| (times +100) (do @ [sample gen-json - #let [(^open "@/") @.Eq + #let [(^open "@/") @.Equivalence (^open "@/") @.Codec]] ($_ seq (test "Every JSON is equal to itself." @@ -97,7 +97,7 @@ (r.alt r.frac (r.seq r.frac gen-recursive))))) -(derived: (poly/equality.Eq Recursive)) +(derived: (poly/equivalence.Equivalence Recursive)) (def: qty (All [unit] (r.Random (unit.Qty unit))) @@ -125,38 +125,38 @@ (derived: (poly/json.Codec Record)) -(struct: _ (Eq Record) +(struct: _ (Equivalence Record) (def: (= recL recR) (let [variant/= (function (_ left right) (case [left right] [(#Case0 left') (#Case0 right')] - (:: bool.Eq = left' right') + (:: bool.Equivalence = left' right') [(#Case1 left') (#Case1 right')] - (:: text.Eq = left' right') + (:: text.Equivalence = left' right') [(#Case2 left') (#Case2 right')] (f/= left' right') _ false))] - (and (:: bool.Eq = (get@ #bool recL) (get@ #bool recR)) + (and (:: bool.Equivalence = (get@ #bool recL) (get@ #bool recR)) (f/= (get@ #frac recL) (get@ #frac recR)) - (:: text.Eq = (get@ #text recL) (get@ #text recR)) - (:: (maybe.Eq number.Eq) = (get@ #maybe recL) (get@ #maybe recR)) - (:: (list.Eq number.Eq) = (get@ #list recL) (get@ #list recR)) - (:: (d.Eq number.Eq) = (get@ #dict recL) (get@ #dict recR)) + (:: text.Equivalence = (get@ #text recL) (get@ #text recR)) + (:: (maybe.Equivalence number.Equivalence) = (get@ #maybe recL) (get@ #maybe recR)) + (:: (list.Equivalence number.Equivalence) = (get@ #list recL) (get@ #list recR)) + (:: (d.Equivalence number.Equivalence) = (get@ #dict recL) (get@ #dict recR)) ## (variant/= (get@ #variant recL) (get@ #variant recR)) ## (let [[tL0 tL1 tL2] (get@ #tuple recL) ## [tR0 tR1 tR2] (get@ #tuple recR)] - ## (and (:: bool.Eq = tL0 tR0) + ## (and (:: bool.Equivalence = tL0 tR0) ## (f/= tL1 tR1) - ## (:: text.Eq = tL2 tR2))) - (:: Eq = (get@ #recursive recL) (get@ #recursive recR)) - ## (:: ti.Eq = (get@ #instant recL) (get@ #instant recR)) - (:: tdu.Eq = (get@ #duration recL) (get@ #duration recR)) - (:: tda.Eq = (get@ #date recL) (get@ #date recR)) - (:: unit.Eq = (get@ #grams recL) (get@ #grams recR)) + ## (:: text.Equivalence = tL2 tR2))) + (:: Equivalence = (get@ #recursive recL) (get@ #recursive recR)) + ## (:: ti.Equivalence = (get@ #instant recL) (get@ #instant recR)) + (:: tdu.Equivalence = (get@ #duration recL) (get@ #duration recR)) + (:: tda.Equivalence = (get@ #date recL) (get@ #date recR)) + (:: unit.Equivalence = (get@ #grams recL) (get@ #grams recR)) )))) (context: "Polytypism" @@ -164,7 +164,7 @@ ## (times +100) (do @ [sample gen-record - #let [(^open "@/") Eq + #let [(^open "@/") Equivalence (^open "@/") Codec]] (test "Can encode/decode arbitrary types." (|> sample @/encode @/decode diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux index b7377ab64..27d904a98 100644 --- a/stdlib/test/test/lux/data/format/xml.lux +++ b/stdlib/test/test/lux/data/format/xml.lux @@ -4,7 +4,7 @@ (control [monad #+ do Monad] ["p" parser] pipe) - (data [text "text/" Eq] + (data [text "text/" Equivalence] text/format [ident] ["E" error] @@ -59,7 +59,7 @@ (<| (times +100) (do @ [sample gen-xml - #let [(^open "&/") &.Eq + #let [(^open "&/") &.Equivalence (^open "&/") &.Codec]] ($_ seq (test "Every XML is equal to itself." @@ -112,7 +112,7 @@ (do E.Monad [outputs (|> (&.children (p.some &.text)) (&.run node))] - (wrap (:: (list.Eq text.Eq) = + (wrap (:: (list.Equivalence text.Equivalence) = children outputs))))) )))) diff --git a/stdlib/test/test/lux/data/ident.lux b/stdlib/test/test/lux/data/ident.lux index 5e39bad7f..b1e4c8490 100644 --- a/stdlib/test/test/lux/data/ident.lux +++ b/stdlib/test/test/lux/data/ident.lux @@ -4,7 +4,7 @@ (control [monad #+ do Monad] pipe) (data ["&" ident] - [text "text/" Eq] + [text "text/" Equivalence] text/format) ["r" math/random]) lux/test) @@ -28,14 +28,14 @@ module2 (gen-part sizeM2) name2 (gen-part sizeN2) #let [ident2 [module2 name2]] - #let [(^open "&/") &.Eq + #let [(^open "&/") &.Equivalence (^open "&/") &.Codec]] ($_ seq (test "Can get the module & name parts of an ident." (and (is? module1 (&.module ident1)) (is? name1 (&.name ident1)))) - (test "Can compare idents for equality." + (test "Can compare idents for equivalence." (and (&/= ident1 ident1) (if (&/= ident1 ident2) (and (text/= module1 module2) @@ -56,7 +56,7 @@ )))) (context: "Ident-related macros." - (let [(^open "&/") &.Eq] + (let [(^open "&/") &.Equivalence] ($_ seq (test "Can obtain Ident from symbol." (and (&/= ["lux" "yolo"] (ident-for .yolo)) diff --git a/stdlib/test/test/lux/data/identity.lux b/stdlib/test/test/lux/data/identity.lux index f5ac9c6ba..479ec5670 100644 --- a/stdlib/test/test/lux/data/identity.lux +++ b/stdlib/test/test/lux/data/identity.lux @@ -4,7 +4,7 @@ (control ["M" monad #+ do Monad] comonad) (data ["&" identity] - [text "Text/" Monoid Eq])) + [text "Text/" Monoid Equivalence])) lux/test) (context: "Identity" diff --git a/stdlib/test/test/lux/data/maybe.lux b/stdlib/test/test/lux/data/maybe.lux index 9723500f5..8353461b7 100644 --- a/stdlib/test/test/lux/data/maybe.lux +++ b/stdlib/test/test/lux/data/maybe.lux @@ -12,7 +12,7 @@ (let [(^open "&/") &.Monoid (^open "&/") &.Apply (^open "&/") &.Monad - (^open "Maybe/") (&.Eq text.Eq)] + (^open "Maybe/") (&.Equivalence text.Equivalence)] ($_ seq (test "Can compare Maybe values." (and (Maybe/= #.None #.None) diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 9f3d94a2e..4afba422a 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -4,26 +4,26 @@ (control ["M" monad #+ do Monad] pipe) (data number - [text "Text/" Monoid Eq] + [text "Text/" Monoid Equivalence] text/format) ["r" math/random]) lux/test) -(do-template [category rand-gen ] - [(context: (format "[" category "] " "Eq & Order") +(do-template [category rand-gen ] + [(context: (format "[" category "] " "Equivalence & Order") (<| (times +100) (do @ [x rand-gen y rand-gen] - (test "" (and (:: = x x) - (or (:: = x y) + (test "" (and (:: = x x) + (or (:: = x y) (:: < y x) (:: > y x)))))))] - ["Nat" r.nat Eq Order] - ["Int" r.int Eq Order] - ["Rev" r.rev Eq Order] - ["Frac" r.frac Eq Order] + ["Nat" r.nat Equivalence Order] + ["Int" r.int Equivalence Order] + ["Rev" r.rev Equivalence Order] + ["Frac" r.frac Equivalence Order] ) (do-template [category rand-gen ] @@ -119,7 +119,7 @@ ["Frac/Max" r.frac Number Order Max@Monoid (f/% 1000.0) (f/> 0.0)] ) -(do-template [ ] +(do-template [ ] [(context: (format "[" "] " "Alternative formats") (<| (times +100) (do @ @@ -129,30 +129,30 @@ (:: encode) (:: decode) (case> (#.Right x') - (:: = x x') + (:: = x x') (#.Left _) false))))))] - ["Nat/Binary" r.nat Eq Binary@Codec] - ["Nat/Octal" r.nat Eq Octal@Codec] - ["Nat/Decimal" r.nat Eq Codec] - ["Nat/Hex" r.nat Eq Hex@Codec] - - ["Int/Binary" r.int Eq Binary@Codec] - ["Int/Octal" r.int Eq Octal@Codec] - ["Int/Decimal" r.int Eq Codec] - ["Int/Hex" r.int Eq Hex@Codec] - - ["Rev/Binary" r.rev Eq Binary@Codec] - ["Rev/Octal" r.rev Eq Octal@Codec] - ["Rev/Decimal" r.rev Eq Codec] - ["Rev/Hex" r.rev Eq Hex@Codec] - - ["Frac/Binary" r.frac Eq Binary@Codec] - ["Frac/Octal" r.frac Eq Octal@Codec] - ["Frac/Decimal" r.frac Eq Codec] - ["Frac/Hex" r.frac Eq Hex@Codec] + ["Nat/Binary" r.nat Equivalence Binary@Codec] + ["Nat/Octal" r.nat Equivalence Octal@Codec] + ["Nat/Decimal" r.nat Equivalence Codec] + ["Nat/Hex" r.nat Equivalence Hex@Codec] + + ["Int/Binary" r.int Equivalence Binary@Codec] + ["Int/Octal" r.int Equivalence Octal@Codec] + ["Int/Decimal" r.int Equivalence Codec] + ["Int/Hex" r.int Equivalence Hex@Codec] + + ["Rev/Binary" r.rev Equivalence Binary@Codec] + ["Rev/Octal" r.rev Equivalence Octal@Codec] + ["Rev/Decimal" r.rev Equivalence Codec] + ["Rev/Hex" r.rev Equivalence Hex@Codec] + + ["Frac/Binary" r.frac Equivalence Binary@Codec] + ["Frac/Octal" r.frac Equivalence Octal@Codec] + ["Frac/Decimal" r.frac Equivalence Codec] + ["Frac/Hex" r.frac Equivalence Hex@Codec] ) (context: "Can convert frac values to/from their bit patterns." diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index de33a9f64..47e68e220 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -10,7 +10,7 @@ lux/test) (context: "Sum operations" - (let [(^open "List/") (list.Eq text.Eq)] + (let [(^open "List/") (list.Equivalence text.Equivalence)] ($_ seq (test "Can inject values into Either." (and (|> (left "Hello") (case> (+0 "Hello") true _ false)) diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux index 99c750f74..23d6f8d9b 100644 --- a/stdlib/test/test/lux/data/text.lux +++ b/stdlib/test/test/lux/data/text.lux @@ -64,7 +64,7 @@ fake-sample (&.join-with " " (list sampleL sampleR)) dup-sample (&.join-with "" (list sampleL sampleR)) enclosed-sample (&.enclose [sampleR sampleR] sampleL) - (^open) &.Eq]] + (^open) &.Equivalence]] (test "" (and (not (= sample fake-sample)) (= sample dup-sample) (&.starts-with? sampleL sample) @@ -112,7 +112,7 @@ parts (r.list sizeL part-gen) #let [sample1 (&.concat (list.interpose sep1 parts)) sample2 (&.concat (list.interpose sep2 parts)) - (^open "&/") &.Eq]] + (^open "&/") &.Equivalence]] ($_ seq (test "Can split text through a separator." (n/= (list.size parts) diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux index ccffe2fcf..2ce811b33 100644 --- a/stdlib/test/test/lux/data/text/format.lux +++ b/stdlib/test/test/lux/data/text/format.lux @@ -8,7 +8,7 @@ lux/test) (context: "Formatters" - (let [(^open "&/") text.Eq] + (let [(^open "&/") text.Equivalence] ($_ seq (test "Can format common values simply." (and (&/= "true" (%b true)) diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index 58e142a98..d1d05074f 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -5,7 +5,7 @@ ["p" parser]) [io] (data ["E" error] - [text "text/" Eq] + [text "text/" Equivalence] text/format ["&" text/lexer] (coll [list])) @@ -30,7 +30,7 @@ (def: (should-passL test input) (-> (List Text) (E.Error (List Text)) Bool) - (let [(^open "list/") (list.Eq text.Eq)] + (let [(^open "list/") (list.Equivalence text.Equivalence)] (case input (#.Right output) (list/= test output) diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 7bc3082a1..cab2b168b 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -5,7 +5,7 @@ pipe ["p" parser]) (data [product] - [text "T/" Eq] + [text "T/" Equivalence] text/format (text [lexer] ["&" regex])) diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index cfd6bad5e..c9c59e8d2 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -6,7 +6,7 @@ (data text/format [number] [product] - [text "text/" Eq]) + [text "text/" Equivalence]) ["&" host #+ class: interface: object] ["r" math/random]) lux/test) diff --git a/stdlib/test/test/lux/io.lux b/stdlib/test/test/lux/io.lux index faddcf42d..768bc3166 100644 --- a/stdlib/test/test/lux/io.lux +++ b/stdlib/test/test/lux/io.lux @@ -2,7 +2,7 @@ lux (lux ["&" io] (control ["M" monad #+ do Monad]) - (data [text "Text/" Monoid Eq] + (data [text "Text/" Monoid Equivalence] text/format [number])) lux/test) diff --git a/stdlib/test/test/lux/lang/compiler/analysis/case.lux b/stdlib/test/test/lux/lang/compiler/analysis/case.lux index cbf11b164..21fa2b9f9 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/case.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/case.lux @@ -3,18 +3,18 @@ (lux [io] (control [monad #+ do] pipe) - (data [bool "B/" Eq] + (data [bool "B/" Equivalence] ["R" error] [product] [maybe] - [text "T/" Eq] + [text "T/" Equivalence] text/format (coll [list "list/" Monad] (set ["set" unordered]))) ["r" math/random "r/" Monad] [macro #+ Monad] (macro [code]) - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] (type ["tc" check]) [".L" module] (compiler [analysis] diff --git a/stdlib/test/test/lux/lang/compiler/analysis/function.lux b/stdlib/test/test/lux/lang/compiler/analysis/function.lux index 3fab96a92..b8c5d23b6 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/function.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/function.lux @@ -6,14 +6,14 @@ (data ["e" error] [maybe] [product] - [text "text/" Eq] + [text "text/" Equivalence] text/format (coll [list "list/" Functor])) ["r" math/random "r/" Monad] [macro] (macro [code]) [lang] - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] [".L" reference] (compiler [".L" init] [".L" analysis #+ Analysis] diff --git a/stdlib/test/test/lux/lang/compiler/analysis/primitive.lux b/stdlib/test/test/lux/lang/compiler/analysis/primitive.lux index 6f4cd1afc..cf98a71ff 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/primitive.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/primitive.lux @@ -10,7 +10,7 @@ [macro] (macro [code]) [lang] - (lang [".L" type "type/" Eq] + (lang [".L" type "type/" Equivalence] (compiler [".L" init] [analysis #+ Analysis] (analysis [".A" type] diff --git a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux index 581ce90b8..fc1a209d9 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux @@ -12,17 +12,17 @@ [macro #+ Monad] (macro [code]) [lang] - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] [".L" scope] - [".L" init] - (analysis [".A" type])) + (compiler [".L" init] + (analysis [".A" type]))) test) (/// ["_." primitive])) (do-template [ ] [(def: ( procedure params output-type) (-> Text (List Code) Type Bool) - (|> (lang.with-scope + (|> (scopeL.with-scope "" (typeA.with-type output-type (_primitive.analyse (` ((~ (code.text procedure)) (~+ params)))))) (macro.run (initL.compiler [])) @@ -90,7 +90,7 @@ (check-success+ "lux int /" (list subjectC paramC) Int)) (test "Can calculate remainder of integers." (check-success+ "lux int %" (list subjectC paramC) Int)) - (test "Can test equality of integers." + (test "Can test equivalence of integers." (check-success+ "lux int =" (list subjectC paramC) Bool)) (test "Can compare integers." (check-success+ "lux int <" (list subjectC paramC) Bool)) @@ -123,7 +123,7 @@ (check-success+ "lux frac /" (list subjectC paramC) Frac)) (test "Can calculate remainder of frac numbers." (check-success+ "lux frac %" (list subjectC paramC) Frac)) - (test "Can test equality of frac numbers." + (test "Can test equivalence of frac numbers." (check-success+ "lux frac =" (list subjectC paramC) Bool)) (test "Can compare frac numbers." (check-success+ "lux frac <" (list subjectC paramC) Bool)) @@ -150,7 +150,7 @@ fromC (|> r.nat (:: @ map code.nat)) toC (|> r.nat (:: @ map code.nat))] ($_ seq - (test "Can test text equality." + (test "Can test text equivalence." (check-success+ "lux text =" (list subjectC paramC) Bool)) (test "Compare texts in lexicographical order." (check-success+ "lux text <" (list subjectC paramC) Bool)) diff --git a/stdlib/test/test/lux/lang/compiler/analysis/procedure/host.jvm.lux b/stdlib/test/test/lux/lang/compiler/analysis/procedure/host.jvm.lux index 0a60149d5..af4741918 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/procedure/host.jvm.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/procedure/host.jvm.lux @@ -7,7 +7,7 @@ (data ["e" error] [product] [maybe] - [text "text/" Eq] + [text "text/" Equivalence] text/format (coll [array] [list "list/" Fold] @@ -17,9 +17,9 @@ (macro [code]) [lang] (lang [type] - [".L" init] - (analysis [".A" type]) - (extension (analysis [".AE" host]))) + (compiler [".L" init] + (analysis [".A" type]) + (extension (analysis [".AE" host])))) test) (/// ["_." primitive])) diff --git a/stdlib/test/test/lux/lang/compiler/analysis/reference.lux b/stdlib/test/test/lux/lang/compiler/analysis/reference.lux index c6fbf5da0..d1874bfee 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/reference.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/reference.lux @@ -4,13 +4,13 @@ (control [monad #+ do] pipe) (data ["e" error] - [ident "ident/" Eq] - [text "text/" Eq]) + [ident "ident/" Equivalence] + [text "text/" Equivalence]) ["r" math/random] [macro #+ Monad] (macro [code]) [lang] - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] [".L" scope] [".L" module] [".L" reference] diff --git a/stdlib/test/test/lux/lang/compiler/analysis/structure.lux b/stdlib/test/test/lux/lang/compiler/analysis/structure.lux index 2342e0e5a..d9d029d31 100644 --- a/stdlib/test/test/lux/lang/compiler/analysis/structure.lux +++ b/stdlib/test/test/lux/lang/compiler/analysis/structure.lux @@ -3,7 +3,7 @@ (lux [io] (control [monad #+ do] pipe) - (data [bool "bool/" Eq] + (data [bool "bool/" Equivalence] ["e" error] [product] [maybe] @@ -15,7 +15,7 @@ [macro] (macro [code]) [lang] - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] (type ["tc" check]) [".L" module] (compiler [".L" init] diff --git a/stdlib/test/test/lux/lang/compiler/synthesis/function.lux b/stdlib/test/test/lux/lang/compiler/synthesis/function.lux index c7b16de27..92e5dcc72 100644 --- a/stdlib/test/test/lux/lang/compiler/synthesis/function.lux +++ b/stdlib/test/test/lux/lang/compiler/synthesis/function.lux @@ -11,7 +11,7 @@ (coll [list "list/" Functor Fold] (dictionary ["dict" unordered #+ Dict]) (set ["set" unordered]))) - (lang ["///." reference #+ Variable "variable/" Equality] + (lang ["///." reference #+ Variable "variable/" Equivalence] ["///." compiler] [".L" analysis #+ Arity Analysis] ["//" synthesis #+ Synthesis] diff --git a/stdlib/test/test/lux/lang/compiler/synthesis/structure.lux b/stdlib/test/test/lux/lang/compiler/synthesis/structure.lux index e61386044..eb970d3a3 100644 --- a/stdlib/test/test/lux/lang/compiler/synthesis/structure.lux +++ b/stdlib/test/test/lux/lang/compiler/synthesis/structure.lux @@ -3,7 +3,7 @@ (lux [io] (control [monad #+ do] pipe) - (data [bool "bool/" Eq] + (data [bool "bool/" Equivalence] [product] [error] (coll [list])) diff --git a/stdlib/test/test/lux/lang/syntax.lux b/stdlib/test/test/lux/lang/syntax.lux index 0ea9c5b9c..929ecaca0 100644 --- a/stdlib/test/test/lux/lang/syntax.lux +++ b/stdlib/test/test/lux/lang/syntax.lux @@ -88,7 +88,7 @@ false (#e.Success [_ parsed]) - (:: code.Eq = parsed sample))) + (:: code.Equivalence = parsed sample))) (test "Can parse Lux multiple code nodes." (case (&.read "" (dict.new text.Hash) [default-cursor +0 (format (code.to-text sample) " " @@ -103,8 +103,8 @@ false (#e.Success [_ =other]) - (and (:: code.Eq = sample =sample) - (:: code.Eq = other =other))))) + (and (:: code.Equivalence = sample =sample) + (:: code.Equivalence = other =other))))) )))) (context: "Frac special syntax." @@ -208,7 +208,7 @@ false (#e.Success [_ parsed]) - (:: code.Eq = + (:: code.Equivalence = parsed (code.text good-output))))) (test "Can handle comments." @@ -219,7 +219,7 @@ false (#e.Success [_ parsed]) - (:: code.Eq = parsed sample))) + (:: code.Equivalence = parsed sample))) (test "Will reject unbalanced multi-line comments." (and (case (&.read "" (dict.new text.Hash) [default-cursor +0 diff --git a/stdlib/test/test/lux/lang/type.lux b/stdlib/test/test/lux/lang/type.lux index 22cd568ee..26f59f7b1 100644 --- a/stdlib/test/test/lux/lang/type.lux +++ b/stdlib/test/test/lux/lang/type.lux @@ -47,7 +47,7 @@ (do @ [sample gen-type] (test "Every type is equal to itself." - (:: &.Eq = sample sample))))) + (:: &.Equivalence = sample sample))))) (context: "Type application" (test "Can apply quantified types (universal and existential quantification)." @@ -55,7 +55,7 @@ (do maybe.Monad [partial (&.apply (list Bool) Ann) full (&.apply (list Int) partial)] - (wrap (:: &.Eq = full (#.Product Bool Int))))) + (wrap (:: &.Equivalence = full (#.Product Bool Int))))) (|> (&.apply (list Bool) Text) (case> #.None true _ false))))) @@ -66,15 +66,15 @@ base))] ($_ seq (test "Can remove aliases from an already-named type." - (:: &.Eq = + (:: &.Equivalence = base (&.un-alias aliased))) (test "Can remove all names from a type." - (and (not (:: &.Eq = + (and (not (:: &.Equivalence = base (&.un-name aliased))) - (:: &.Eq = + (:: &.Equivalence = (&.un-name base) (&.un-name aliased))))))) @@ -92,8 +92,8 @@ true))) (list.repeat size) (M.seq @)) - #let [(^open "&/") &.Eq - (^open "L/") (list.Eq &.Eq)]] + #let [(^open "&/") &.Equivalence + (^open "L/") (list.Equivalence &.Equivalence)]] (with-expansions [ (do-template [ ] [(test (format "Can build and tear-down " " types.") @@ -122,8 +122,8 @@ _ true)))) - #let [(^open "&/") &.Eq - (^open "L/") (list.Eq &.Eq)]] + #let [(^open "&/") &.Equivalence + (^open "L/") (list.Equivalence &.Equivalence)]] ($_ seq (test "Can build and tear-down function types." (let [[inputs output] (|> (&.function members extra) &.flatten-function)] @@ -147,7 +147,7 @@ _ true)))) - #let [(^open "&/") &.Eq]] + #let [(^open "&/") &.Equivalence]] (with-expansions [ (do-template [ ] [(test (format "Can build and tear-down " " types.") diff --git a/stdlib/test/test/lux/lang/type/check.lux b/stdlib/test/test/lux/lang/type/check.lux index 57285c91c..2ffee1318 100644 --- a/stdlib/test/test/lux/lang/type/check.lux +++ b/stdlib/test/test/lux/lang/type/check.lux @@ -6,12 +6,12 @@ (data [product] [maybe] [number] - [text "text/" Monoid Eq] + [text "text/" Monoid Equivalence] text/format (coll [list "list/" Functor] (set ["set" unordered]))) ["r" math/random] - (lang [type "type/" Eq] + (lang [type "type/" Equivalence] ["@" type/check])) lux/test) @@ -215,11 +215,11 @@ headR (@.ring head-id) tailR (@.ring tail-id)] (@.assert "" - (let [same-rings? (:: set.Eq = headR tailR) + (let [same-rings? (:: set.Equivalence = headR tailR) expected-size? (n/= (inc num-connections) (set.size headR)) same-vars? (|> (set.to-list headR) (list.sort n/<) - (:: (list.Eq number.Eq) = (list.sort n/< (#.Cons head-id ids))))] + (:: (list.Equivalence number.Equivalence) = (list.sort n/< (#.Cons head-id ids))))] (and same-rings? expected-size? same-vars?)))))) @@ -251,10 +251,10 @@ headRL-post (@.ring head-idL) headRR-post (@.ring head-idR)] (@.assert "" - (let [same-rings? (:: set.Eq = headRL-post headRR-post) + (let [same-rings? (:: set.Equivalence = headRL-post headRR-post) expected-size? (n/= (n/* +2 (inc num-connections)) (set.size headRL-post)) - union? (:: set.Eq = headRL-post (set.union headRL-pre headRR-pre))] + union? (:: set.Equivalence = headRL-post (set.union headRL-pre headRR-pre))] (and same-rings? expected-size? union?)))))) diff --git a/stdlib/test/test/lux/macro/code.lux b/stdlib/test/test/lux/macro/code.lux index 08160c7e2..300adc53c 100644 --- a/stdlib/test/test/lux/macro/code.lux +++ b/stdlib/test/test/lux/macro/code.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [monad #+ do Monad]) - (data [text "T/" Eq] + (data [text "T/" Equivalence] text/format [number]) ["r" math/random] @@ -14,7 +14,7 @@ [ (do-template [ ] [(test (format "Can produce Code node: " ) (and (T/= (&.to-text )) - (:: &.Eq = )))] + (:: &.Equivalence = )))] [(&.bool true) "true"] [(&.bool false) "false"] diff --git a/stdlib/test/test/lux/macro/poly/equality.lux b/stdlib/test/test/lux/macro/poly/equality.lux deleted file mode 100644 index 832c72355..000000000 --- a/stdlib/test/test/lux/macro/poly/equality.lux +++ /dev/null @@ -1,70 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do Monad] - [equality #+ Eq]) - (data text/format - [bool] - [number "int/" Number] - [text] - [maybe] - (coll [list])) - ["r" math/random] - [macro] - (macro [poly #+ derived:] - ["&" poly/equality])) - lux/test) - -## [Utils] -(type: Variant - (#Case0 Bool) - (#Case1 Int) - (#Case2 Frac)) - -(type: #rec Recursive - (#Number Frac) - (#Addition Frac Recursive)) - -(type: Record - {#bool Bool - #int Int - #frac Frac - #text Text - #maybe (Maybe Int) - #list (List Int) - #variant Variant - #tuple [Int Frac Text] - #recursive Recursive}) - -(def: gen-recursive - (r.Random Recursive) - (r.rec (function (_ gen-recursive) - (r.alt r.frac - (r.seq r.frac gen-recursive))))) - -(def: gen-record - (r.Random Record) - (do r.Monad - [size (:: @ map (n/% +2) r.nat) - #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]] - ($_ r.seq - r.bool - gen-int - r.frac - (r.unicode size) - (r.maybe gen-int) - (r.list size gen-int) - ($_ r.alt r.bool gen-int r.frac) - ($_ r.seq gen-int r.frac (r.unicode size)) - gen-recursive))) - -(derived: (&.Eq Record)) - -## [Tests] -(context: "Eq polytypism" - (<| (times +100) - (do @ - [sample gen-record - #let [(^open "&/") Eq]] - (test "Every instance equals itself." - (&/= sample sample))))) diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux new file mode 100644 index 000000000..f37ad04b5 --- /dev/null +++ b/stdlib/test/test/lux/macro/poly/equivalence.lux @@ -0,0 +1,70 @@ +(.module: + lux + (lux [io] + (control [monad #+ do Monad] + [equivalence #+ Equivalence]) + (data text/format + [bool] + [number "int/" Number] + [text] + [maybe] + (coll [list])) + ["r" math/random] + [macro] + (macro [poly #+ derived:] + ["&" poly/equivalence])) + lux/test) + +## [Utils] +(type: Variant + (#Case0 Bool) + (#Case1 Int) + (#Case2 Frac)) + +(type: #rec Recursive + (#Number Frac) + (#Addition Frac Recursive)) + +(type: Record + {#bool Bool + #int Int + #frac Frac + #text Text + #maybe (Maybe Int) + #list (List Int) + #variant Variant + #tuple [Int Frac Text] + #recursive Recursive}) + +(def: gen-recursive + (r.Random Recursive) + (r.rec (function (_ gen-recursive) + (r.alt r.frac + (r.seq r.frac gen-recursive))))) + +(def: gen-record + (r.Random Record) + (do r.Monad + [size (:: @ map (n/% +2) r.nat) + #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]] + ($_ r.seq + r.bool + gen-int + r.frac + (r.unicode size) + (r.maybe gen-int) + (r.list size gen-int) + ($_ r.alt r.bool gen-int r.frac) + ($_ r.seq gen-int r.frac (r.unicode size)) + gen-recursive))) + +(derived: (&.Equivalence Record)) + +## [Tests] +(context: "Equivalence polytypism" + (<| (times +100) + (do @ + [sample gen-record + #let [(^open "&/") Equivalence]] + (test "Every instance equals itself." + (&/= sample sample))))) diff --git a/stdlib/test/test/lux/macro/poly/functor.lux b/stdlib/test/test/lux/macro/poly/functor.lux index 86c3eca7f..9db2ea282 100644 --- a/stdlib/test/test/lux/macro/poly/functor.lux +++ b/stdlib/test/test/lux/macro/poly/functor.lux @@ -1,17 +1,7 @@ (.module: lux - (lux [io] - (control [monad #+ do Monad] - [functor] - [equality #+ Eq] - [state]) - (data text/format - [bool] - [number] - [text] - [identity]) - ["r" math/random] - [macro] + (lux (control [state]) + (data [identity]) (macro [poly #+ derived:] ["&" poly/functor])) lux/test) @@ -27,4 +17,5 @@ ## [Tests] (context: "Functor polytypism." - (test "" true)) + (test "Can derive functors automatically." + true)) diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 342845337..3b9815064 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [monad #+ do Monad] - [equality #+ Eq] + [equivalence #+ Equivalence] ["p" parser]) (data [text "Text/" Monoid] text/format @@ -35,11 +35,11 @@ _ false)) -(def: (equals? Eq reference parser input) - (All [a] (-> (Eq a) a (Syntax a) (List Code) Bool)) +(def: (equals? Equivalence reference parser input) + (All [a] (-> (Equivalence a) a (Syntax a) (List Code) Bool)) (case (p.run input parser) (#.Right [_ output]) - (:: Eq = reference output) + (:: Equivalence = reference output) _ false)) @@ -64,20 +64,20 @@ ## [Tests] (context: "Simple value syntax." (with-expansions - [ (do-template [ ] + [ (do-template [ ] [(test - (and (equals? (list ( ))) + (and (equals? (list ( ))) (found? (s.this? ( )) (list ( ))) (enforced? (s.this ( )) (list ( )))))] - ["Can parse Bool syntax." true code.bool bool.Eq s.bool] - ["Can parse Nat syntax." +123 code.nat number.Eq s.nat] - ["Can parse Int syntax." 123 code.int number.Eq s.int] - ["Can parse Rev syntax." .123 code.rev number.Eq s.rev] - ["Can parse Frac syntax." 123.0 code.frac number.Eq s.frac] - ["Can parse Text syntax." "\n" code.text text.Eq s.text] - ["Can parse Symbol syntax." ["yolo" "lol"] code.symbol ident.Eq s.symbol] - ["Can parse Tag syntax." ["yolo" "lol"] code.tag ident.Eq s.tag] + ["Can parse Bool syntax." true code.bool bool.Equivalence s.bool] + ["Can parse Nat syntax." +123 code.nat number.Equivalence s.nat] + ["Can parse Int syntax." 123 code.int number.Equivalence s.int] + ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] + ["Can parse Frac syntax." 123.0 code.frac number.Equivalence s.frac] + ["Can parse Text syntax." "\n" code.text text.Equivalence s.text] + ["Can parse Symbol syntax." ["yolo" "lol"] code.symbol ident.Equivalence s.symbol] + ["Can parse Tag syntax." ["yolo" "lol"] code.tag ident.Equivalence s.tag] )] ($_ seq diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux index 80ca6995c..4e7e29a1e 100644 --- a/stdlib/test/test/lux/math.lux +++ b/stdlib/test/test/lux/math.lux @@ -2,7 +2,7 @@ lux (lux [io] (control [monad #+ do Monad]) - (data [bool "bool/" Eq] + (data [bool "bool/" Equivalence] [number "frac/" Number]) ["r" math/random] ["&" math]) diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index c5c70c5a0..3fa7c66cc 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -4,7 +4,7 @@ (control [monad #+ do Monad]) (data (coll [list] (set ["set" unordered])) - [bool "B/" Eq] + [bool "B/" Equivalence] [number] text/format) ["r" math/random] diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index 7bb684695..7102e684d 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -2,12 +2,12 @@ lux (lux (control [monad #+ do]) (data [product] - [bool "bool/" Eq] + [bool "bool/" Equivalence] ["e" error] text/format) (math ["r" random] ["/" modular]) - (lang [type "type/" Eq])) + (lang [type "type/" Equivalence])) lux/test) (def: %3 (/.modulus 3)) diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux index b2f4fe6ca..2096edcfe 100644 --- a/stdlib/test/test/lux/math/random.lux +++ b/stdlib/test/test/lux/math/random.lux @@ -49,7 +49,7 @@ (test "Can filter values." (n/<= top filtered)) (test "Can shuffle rows." - (let [(^open "v/") (row.Eq number.Eq) + (let [(^open "v/") (row.Equivalence number.Equivalence) sorted (row.from-list sorted)] (and (not (v/= sorted shuffled)) (v/= sorted (row.from-list re-sorted))))) diff --git a/stdlib/test/test/lux/time/date.lux b/stdlib/test/test/lux/time/date.lux index 8dba5517a..dbd925fda 100644 --- a/stdlib/test/test/lux/time/date.lux +++ b/stdlib/test/test/lux/time/date.lux @@ -25,11 +25,11 @@ (r.either (r/wrap #@.November) (r/wrap #@.December)))))) -(context: "(Month) Eq." +(context: "(Month) Equivalence." (<| (times +100) (do @ [sample month - #let [(^open "@/") @.Eq]] + #let [(^open "@/") @.Equivalence]] (test "Every value equals itself." (@/= sample sample))))) @@ -68,11 +68,11 @@ (r/wrap #@.Friday)) (r/wrap #@.Saturday)))) -(context: "(Day) Eq." +(context: "(Day) Equivalence." (<| (times +100) (do @ [sample day - #let [(^open "@/") @.Eq]] + #let [(^open "@/") @.Equivalence]] (test "Every value equals itself." (@/= sample sample))))) @@ -105,11 +105,11 @@ (r.Random @.Date) (|> _instant.instant (:: r.Monad map @instant.date))) -(context: "(Date) Eq." +(context: "(Date) Equivalence." (<| (times +100) (do @ [sample date - #let [(^open "@/") @.Eq]] + #let [(^open "@/") @.Equivalence]] (test "Every value equals itself." (@/= sample sample))))) @@ -130,7 +130,7 @@ ## (times +100) (do @ [sample date - #let [(^open "@/") @.Eq + #let [(^open "@/") @.Equivalence (^open "@/") @.Codec]] (test "Can encode/decode dates." (|> sample diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 3529852a0..6437a45a3 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -18,15 +18,15 @@ (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) -(context: "Equality" +(context: "Equivalence." (<| (times +100) (do @ [sample duration - #let [(^open "@/") @.Eq]] + #let [(^open "@/") @.Equivalence]] (test "Every duration equals itself." (@/= sample sample))))) -(context: "Order" +(context: "Order." (<| (times +100) (do @ [reference duration @@ -73,7 +73,7 @@ (<| (times +100) (do @ [sample duration - #let [(^open "@/") @.Eq + #let [(^open "@/") @.Equivalence (^open "@/") @.Codec]] (test "Can encode/decode durations." (E.default false diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux index ee328ea3d..cff332527 100644 --- a/stdlib/test/test/lux/time/instant.lux +++ b/stdlib/test/test/lux/time/instant.lux @@ -27,11 +27,11 @@ (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) -(context: "Equality" +(context: "Equivalence." (<| (times +100) (do @ [sample instant - #let [(^open "@/") @.Eq]] + #let [(^open "@/") @.Equivalence]] (test "Every instant equals itself." (@/= sample sample))))) @@ -65,8 +65,8 @@ (do @ [sample instant span _duration.duration - #let [(^open "@/") @.Eq - (^open "@d/") @d.Eq]] + #let [(^open "@/") @.Equivalence + (^open "@d/") @d.Equivalence]] ($_ seq (test "The span of a instant and itself has an empty duration." (|> sample (@.span sample) (@d/= @d.empty))) @@ -82,7 +82,7 @@ ## ## (times +100) ## (do @ ## [sample instant -## #let [(^open "@/") @.Eq +## #let [(^open "@/") @.Equivalence ## (^open "@/") @.Codec]] ## (test "Can encode/decode instants." ## (|> sample diff --git a/stdlib/test/test/lux/type/implicit.lux b/stdlib/test/test/lux/type/implicit.lux index a5af06c5d..33c0bd6c5 100644 --- a/stdlib/test/test/lux/type/implicit.lux +++ b/stdlib/test/test/lux/type/implicit.lux @@ -1,11 +1,9 @@ (.module: lux (lux [io] - (control [monad #+ do Monad] - functor - [equality]) + (control [monad #+ do Monad]) (data [number] - [bool "bool/" Eq] + [bool "bool/" Equivalence] (coll [list])) ["r" math/random] (type implicit)) @@ -18,8 +16,8 @@ y r.nat] ($_ seq (test "Can automatically select first-order structures." - (let [(^open "list/") (list.Eq number.Eq)] - (and (bool/= (:: number.Eq = x y) + (let [(^open "list/") (list.Equivalence number.Equivalence)] + (and (bool/= (:: number.Equivalence = x y) (::: = x y)) (list/= (list.n/range +1 +10) (::: map inc (list.n/range +0 +9))) diff --git a/stdlib/test/test/lux/world/blob.lux b/stdlib/test/test/lux/world/blob.lux index a74fb20e0..8e69e4176 100644 --- a/stdlib/test/test/lux/world/blob.lux +++ b/stdlib/test/test/lux/world/blob.lux @@ -10,7 +10,7 @@ (world ["/" blob]) ["r" math/random]) lux/test - (test (lux (control ["_eq" equality])))) + (test (lux (control ["_eq" equivalence])))) (def: (succeed result) (-> (e.Error Bool) Bool) @@ -55,7 +55,7 @@ #let [[from to] [(n/min from to) (n/max from to)]]] ($_ seq ## TODO: De-comment... - ## (_eq.spec /.Eq (:: @ map blob gen-size)) + ## (_eq.spec /.Equivalence (:: @ map blob gen-size)) (test "Can get size of blob." (|> random-blob /.size (n/= blob-size))) (test "Can read/write 8-bit values." @@ -75,7 +75,7 @@ (case [(monad.map e.Monad (reader random-slice) idxs) (monad.map e.Monad (|>> (n/+ from) (reader random-blob)) idxs)] [(#e.Success slice-vals) (#e.Success blob-vals)] - (:: (list.Eq number.Eq) = slice-vals blob-vals) + (:: (list.Equivalence number.Equivalence) = slice-vals blob-vals) _ false)))) diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux index 6d32a994b..75f08e97c 100644 --- a/stdlib/test/test/lux/world/file.lux +++ b/stdlib/test/test/lux/world/file.lux @@ -50,7 +50,7 @@ [_ (@.write dataL file) output (@.read file) _ (@.delete file)] - (wrap (:: blob.Eq = dataL output))))] + (wrap (:: blob.Equivalence = dataL output))))] (assert "Can write/read files." (e.default false result)))) (wrap (do P.Monad @@ -73,8 +73,8 @@ read-size (@.size file) _ (@.delete file)] (wrap (and (n/= (n/* +2 file-size) read-size) - (:: blob.Eq = dataL (e.assume (blob.slice +0 (dec file-size) output))) - (:: blob.Eq = dataR (e.assume (blob.slice file-size (dec read-size) output)))))))] + (:: blob.Equivalence = dataL (e.assume (blob.slice +0 (dec file-size) output))) + (:: blob.Equivalence = dataR (e.assume (blob.slice file-size (dec read-size) output)))))))] (assert "Can append to files." (e.default false result)))) (wrap (do P.Monad @@ -151,7 +151,7 @@ time-read (@.last-modified file) _ (@.delete file)] (wrap (and was-modified? - (:: i.Eq = last-modified time-read)))))] + (:: i.Equivalence = last-modified time-read)))))] (assert "Can change the time of last modification." (e.default false result)))) (wrap (do P.Monad diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux index 892f6ddc4..e49a06a1e 100644 --- a/stdlib/test/test/lux/world/net/tcp.lux +++ b/stdlib/test/test/lux/world/net/tcp.lux @@ -42,7 +42,7 @@ (do @ [bytes-from (@.read temp-from +0 size socket) #let [_ (io.run (P.resolve (#E.Success (and (n/= size bytes-from) - (:: blob.Eq = from temp-from))) + (:: blob.Equivalence = from temp-from))) from-worked?))]] (@.write to +0 size socket))) server)] @@ -53,7 +53,7 @@ #################### bytes-to (@.read temp-to +0 size client) #let [to-worked? (and (n/= size bytes-to) - (:: blob.Eq = to temp-to))] + (:: blob.Equivalence = to temp-to))] #################### _ (@.close client) _ (T.from-promise (P.future (P.resolve [] server-close)))] diff --git a/stdlib/test/test/lux/world/net/udp.lux b/stdlib/test/test/lux/world/net/udp.lux index 4cb268a4f..6a51e0bf4 100644 --- a/stdlib/test/test/lux/world/net/udp.lux +++ b/stdlib/test/test/lux/world/net/udp.lux @@ -40,12 +40,12 @@ _ (@.write localhost port from +0 size client) [bytes-from from-address from-port] (@.read temp +0 size server) #let [from-worked? (and (n/= size bytes-from) - (:: blob.Eq = from temp))] + (:: blob.Equivalence = from temp))] #################### _ (@.write from-address from-port to +0 size server) [bytes-to to-address to-port] (@.read temp +0 size client) #let [to-worked? (and (n/= size bytes-to) - (:: blob.Eq = to temp) + (:: blob.Equivalence = to temp) (n/= port to-port))] #################### _ (@.close client) -- cgit v1.2.3