diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/data/collection/set/multi.lux | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 9d746ae52..05c02d4cf 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -19,20 +19,20 @@ [// ["." maybe]]]]) -(abstract: #export (Set a) - (Dictionary a Nat) - +(abstract: .public (Set a) {#.doc (doc "A set that keeps track of repetition in its entries.")} - (def: #export empty + (Dictionary a Nat) + + (def: .public empty (All [a] (-> (Hash a) (Set a))) (|>> dictionary.empty :abstraction)) - (def: #export size + (def: .public size (All [a] (-> (Set a) Nat)) (|>> :representation dictionary.values (list\fold n.+ 0))) - (def: #export (add multiplicity elem set) + (def: .public (add multiplicity elem set) (All [a] (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -41,7 +41,7 @@ (dictionary.upsert elem 0 (n.+ multiplicity)) :abstraction))) - (def: #export (remove multiplicity elem set) + (def: .public (remove multiplicity elem set) (All [a] (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -55,11 +55,11 @@ #.None set))) - (def: #export (multiplicity set elem) + (def: .public (multiplicity set elem) (All [a] (-> (Set a) a Nat)) (|> set :representation (dictionary.get elem) (maybe.else 0))) - (def: #export list + (def: .public list (All [a] (-> (Set a) (List a))) (|>> :representation dictionary.entries @@ -68,7 +68,7 @@ #.End))) (template [<name> <compose>] - [(def: #export (<name> parameter subject) + [(def: .public (<name> parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) (:abstraction (dictionary.merged_with <compose> (:representation parameter) (:representation subject))))] @@ -76,7 +76,7 @@ [sum n.+] ) - (def: #export (intersection parameter (^:representation subject)) + (def: .public (intersection parameter (^:representation subject)) (All [a] (-> (Set a) (Set a) (Set a))) (list\fold (function (_ [elem multiplicity] output) (..add (n.min (..multiplicity parameter elem) @@ -86,7 +86,7 @@ (..empty (dictionary.key_hash subject)) (dictionary.entries subject))) - (def: #export (difference parameter subject) + (def: .public (difference parameter subject) (All [a] (-> (Set a) (Set a) (Set a))) (|> parameter :representation @@ -95,7 +95,7 @@ (..remove multiplicity elem output)) subject))) - (def: #export (sub? reference subject) + (def: .public (sub? reference subject) {#.doc (doc "Is 'subject' a sub-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (|> subject @@ -106,7 +106,7 @@ (..multiplicity reference) (n.>= multiplicity)))))) - (def: #export (support set) + (def: .public (support set) {#.doc (doc "A set of the unique (non repeated) members.")} (All [a] (-> (Set a) (//.Set a))) (let [(^@ set [hash _]) (:representation set)] @@ -114,7 +114,7 @@ dictionary.keys (//.of_list hash)))) - (implementation: #export equivalence + (implementation: .public equivalence (All [a] (Equivalence (Set a))) (def: (= (^:representation reference) sample) @@ -127,7 +127,7 @@ (..multiplicity sample) (n.= multiplicity)))))))) - (implementation: #export hash + (implementation: .public hash (All [a] (Hash (Set a))) (def: &equivalence ..equivalence) @@ -140,24 +140,24 @@ (dictionary.entries set))))) ) -(def: #export (member? set elem) +(def: .public (member? set elem) (All [a] (-> (Set a) a Bit)) (|> elem (..multiplicity set) (n.> 0))) -(def: #export empty? +(def: .public empty? (All [a] (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: #export (of_list hash subject) +(def: .public (of_list hash subject) (All [a] (-> (Hash a) (List a) (Set a))) (list\fold (..add 1) (..empty hash) subject)) -(def: #export (of_set subject) +(def: .public (of_set subject) (All [a] (-> (//.Set a) (Set a))) (..of_list (//.member_hash subject) (//.list subject))) -(def: #export super? +(def: .public super? {#.doc (doc "Is 'subject' a super-set of 'reference'?")} (All [a] (-> (Set a) (Set a) Bit)) (function.flip sub?)) |