diff options
Diffstat (limited to 'stdlib/source/lux/data/sum.lux')
-rw-r--r-- | stdlib/source/lux/data/sum.lux | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux index 4d76b6039..2daefe6a4 100644 --- a/stdlib/source/lux/data/sum.lux +++ b/stdlib/source/lux/data/sum.lux @@ -60,34 +60,30 @@ (0 #0 x') [(#.Cons x' lefts) rights] (0 #1 x') [lefts (#.Cons x' rights)])))) -(structure: #export (equivalence l\= r\=) - (All [l r] - (-> (Equivalence l) (Equivalence r) - (Equivalence (| l r)))) - (def: (= reference sample) - (case [reference sample] - [(#.Left reference) (#.Left sample)] - (l\= reference sample) - - [(#.Right reference) (#.Right sample)] - (r\= reference sample) +(def: #export (equivalence left right) + (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r)))) + (structure + (def: (= reference sample) + (case [reference sample] + [(#.Left reference) (#.Left sample)] + (\ left = reference sample) - _ - false))) + [(#.Right reference) (#.Right sample)] + (\ right = reference sample) -(structure: #export (hash (^open "l\.") (^open "r\.")) - (All [l r] - (-> (Hash l) (Hash r) - (Hash (| l r)))) + _ + false)))) - (def: &equivalence (..equivalence l\= r\=)) +(def: #export (hash left right) + (All [l r] (-> (Hash l) (Hash r) (Hash (| l r)))) + (structure + (def: &equivalence + (..equivalence (\ left &equivalence) + (\ right &equivalence))) + (def: (hash value) + (case value + (#.Left value) + (\ left hash value) - (def: (hash value) - (case value - (#.Left value) - (l\hash value) - - (#.Right value) - (.nat ("lux i64 *" - (.int 2) - (.int (r\hash value))))))) + (#.Right value) + (\ right hash value))))) |