aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/sum.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/sum.lux')
-rw-r--r--stdlib/source/lux/data/sum.lux89
1 files changed, 0 insertions, 89 deletions
diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux
deleted file mode 100644
index bb0e6d0e7..000000000
--- a/stdlib/source/lux/data/sum.lux
+++ /dev/null
@@ -1,89 +0,0 @@
-(.module:
- {#.doc "Functionality for working with variants (particularly 2-variants)."}
- [lux #*
- [abstract
- [equivalence (#+ Equivalence)]
- [hash (#+ Hash)]]])
-
-(template [<name> <type> <right?>]
- [(def: #export (<name> value)
- (All [a b] (-> <type> (| a b)))
- (0 <right?> value))]
-
- [left a #0]
- [right b #1])
-
-(def: #export (either fl fr)
- (All [a b c]
- (-> (-> a c) (-> b c)
- (-> (| a b) c)))
- (function (_ input)
- (case input
- (0 #0 l) (fl l)
- (0 #1 r) (fr r))))
-
-(def: #export (apply fl fr)
- (All [l l' r r']
- (-> (-> l l') (-> r r')
- (-> (| l r) (| l' r'))))
- (function (_ input)
- (case input
- (0 #0 l) (0 #0 (fl l))
- (0 #1 r) (0 #1 (fr r)))))
-
-(template [<name> <side> <right?>]
- [(def: #export (<name> es)
- (All [a b] (-> (List (| a b)) (List <side>)))
- (case es
- #.Nil
- #.Nil
-
- (#.Cons (0 <right?> x) es')
- (#.Cons [x (<name> es')])
-
- (#.Cons _ es')
- (<name> es')))]
-
- [lefts a #0]
- [rights b #1]
- )
-
-(def: #export (partition xs)
- (All [a b] (-> (List (| a b)) [(List a) (List b)]))
- (case xs
- #.Nil
- [#.Nil #.Nil]
-
- (#.Cons x xs')
- (let [[lefts rights] (partition xs')]
- (case x
- (0 #0 x') [(#.Cons x' lefts) rights]
- (0 #1 x') [lefts (#.Cons x' rights)]))))
-
-(def: #export (equivalence left right)
- (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r))))
- (implementation
- (def: (= reference sample)
- (case [reference sample]
- [(#.Left reference) (#.Left sample)]
- (\ left = reference sample)
-
- [(#.Right reference) (#.Right sample)]
- (\ right = reference sample)
-
- _
- false))))
-
-(def: #export (hash left right)
- (All [l r] (-> (Hash l) (Hash r) (Hash (| l r))))
- (implementation
- (def: &equivalence
- (..equivalence (\ left &equivalence)
- (\ right &equivalence)))
- (def: (hash value)
- (case value
- (#.Left value)
- (\ left hash value)
-
- (#.Right value)
- (\ right hash value)))))