aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/coll/dictionary/unordered.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/coll/dictionary/unordered.lux40
1 files changed, 20 insertions, 20 deletions
diff --git a/stdlib/source/lux/data/coll/dictionary/unordered.lux b/stdlib/source/lux/data/coll/dictionary/unordered.lux
index 61d21b425..e971228bb 100644
--- a/stdlib/source/lux/data/coll/dictionary/unordered.lux
+++ b/stdlib/source/lux/data/coll/dictionary/unordered.lux
@@ -42,7 +42,7 @@
(type: Level Nat)
## Nodes for the tree data-structure that organizes the data inside
-## Dicts.
+## Dictionaries.
(type: (Node k v)
(#Hierarchy Nat (Array (Node k v)))
(#Base BitMap
@@ -540,47 +540,47 @@
colls)))
## [Exports]
-(type: #export (Dict k v)
+(type: #export (Dictionary k v)
{#.doc "A dictionary implemented as a Hash-Array Mapped Trie (HAMT)."}
{#hash (Hash k)
#root (Node k v)})
(def: #export (new Hash<k>)
- (All [k v] (-> (Hash k) (Dict k v)))
+ (All [k v] (-> (Hash k) (Dictionary k v)))
{#hash Hash<k>
#root empty})
(def: #export (put key val dict)
- (All [k v] (-> k v (Dict k v) (Dict k v)))
+ (All [k v] (-> k v (Dictionary k v) (Dictionary k v)))
(let [[Hash<k> node] dict]
[Hash<k> (put' root-level (:: Hash<k> hash key) key val Hash<k> node)]))
(def: #export (remove key dict)
- (All [k v] (-> k (Dict k v) (Dict k v)))
+ (All [k v] (-> k (Dictionary k v) (Dictionary k v)))
(let [[Hash<k> node] dict]
[Hash<k> (remove' root-level (:: Hash<k> hash key) key Hash<k> node)]))
(def: #export (get key dict)
- (All [k v] (-> k (Dict k v) (Maybe v)))
+ (All [k v] (-> k (Dictionary k v) (Maybe v)))
(let [[Hash<k> node] dict]
(get' root-level (:: Hash<k> hash key) key Hash<k> node)))
(def: #export (contains? key dict)
- (All [k v] (-> k (Dict k v) Bool))
+ (All [k v] (-> k (Dictionary k v) Bool))
(case (get key dict)
#.None false
(#.Some _) true))
(def: #export (put~ key val dict)
{#.doc "Only puts the KV-pair if the key is not already present."}
- (All [k v] (-> k v (Dict k v) (Dict k v)))
+ (All [k v] (-> k v (Dictionary k v) (Dictionary k v)))
(if (contains? key dict)
dict
(put key val dict)))
(def: #export (update key f dict)
{#.doc "Transforms the value located at key (if available), using the given function."}
- (All [k v] (-> k (-> v v) (Dict k v) (Dict k v)))
+ (All [k v] (-> k (-> v v) (Dictionary k v) (Dictionary k v)))
(case (get key dict)
#.None
dict
@@ -590,26 +590,26 @@
(def: #export (update~ key default f dict)
{#.doc "Transforms the value located at key (if available), using the given function."}
- (All [k v] (-> k v (-> v v) (Dict k v) (Dict k v)))
+ (All [k v] (-> k v (-> v v) (Dictionary k v) (Dictionary k v)))
(put key
(f (maybe.default default
(get key dict)))
dict))
(def: #export size
- (All [k v] (-> (Dict k v) Nat))
+ (All [k v] (-> (Dictionary k v) Nat))
(|>> product.right size'))
(def: #export empty?
- (All [k v] (-> (Dict k v) Bool))
+ (All [k v] (-> (Dictionary k v) Bool))
(|>> size (n/= +0)))
(def: #export (entries dict)
- (All [k v] (-> (Dict k v) (List [k v])))
+ (All [k v] (-> (Dictionary k v) (List [k v])))
(entries' (product.right dict)))
(def: #export (from-list Hash<k> kvs)
- (All [k v] (-> (Hash k) (List [k v]) (Dict k v)))
+ (All [k v] (-> (Hash k) (List [k v]) (Dictionary k v)))
(list/fold (function (_ [k v] dict)
(put k v dict))
(new Hash<k>)
@@ -617,7 +617,7 @@
(do-template [<name> <elem-type> <side>]
[(def: #export (<name> dict)
- (All [k v] (-> (Dict k v) (List <elem-type>)))
+ (All [k v] (-> (Dictionary k v) (List <elem-type>)))
(|> dict entries (list/map <side>)))]
[keys k product.left]
@@ -628,7 +628,7 @@
{#.doc "Merges 2 dictionaries.
If any collisions with keys occur, the values of dict2 will overwrite those of dict1."}
- (All [k v] (-> (Dict k v) (Dict k v) (Dict k v)))
+ (All [k v] (-> (Dictionary k v) (Dictionary k v) (Dictionary k v)))
(list/fold (function (_ [key val] dict) (put key val dict))
dict1
(entries dict2)))
@@ -637,7 +637,7 @@
{#.doc "Merges 2 dictionaries.
If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1."}
- (All [k v] (-> (-> v v v) (Dict k v) (Dict k v) (Dict k v)))
+ (All [k v] (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v)))
(list/fold (function (_ [key val2] dict)
(case (get key dict)
#.None
@@ -649,7 +649,7 @@
(entries dict2)))
(def: #export (re-bind from-key to-key dict)
- (All [k v] (-> k k (Dict k v) (Dict k v)))
+ (All [k v] (-> k k (Dictionary k v) (Dictionary k v)))
(case (get from-key dict)
#.None
dict
@@ -661,7 +661,7 @@
(def: #export (select keys dict)
{#.doc "Creates a sub-set of the given dict, with only the specified keys."}
- (All [k v] (-> (List k) (Dict k v) (Dict k v)))
+ (All [k v] (-> (List k) (Dictionary k v) (Dictionary k v)))
(let [[Hash<k> _] dict]
(list/fold (function (_ key new-dict)
(case (get key dict)
@@ -671,7 +671,7 @@
keys)))
## [Structures]
-(structure: #export (Equivalence<Dict> Equivalence<v>) (All [k v] (-> (Equivalence v) (Equivalence (Dict k v))))
+(structure: #export (Equivalence<Dictionary> Equivalence<v>) (All [k v] (-> (Equivalence v) (Equivalence (Dictionary k v))))
(def: (= test subject)
(and (n/= (size test)
(size subject))