diff options
Diffstat (limited to 'stdlib/source/library/lux/data/collection/dictionary/ordered.lux')
-rw-r--r-- | stdlib/source/library/lux/data/collection/dictionary/ordered.lux | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 38521368c..8592aaeec 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -17,7 +17,7 @@ [number ["n" nat]]]]]) -(def: error_message +(def error_message "Invariant violation") (type: Color @@ -34,7 +34,7 @@ #right (Maybe (Node k v))])) (with_template [<create> <color>] - [(def: (<create> key value left right) + [(def (<create> key value left right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) [#color {<color>} #key key @@ -51,14 +51,14 @@ [#order (Order k) #root (Maybe (Node k v))])) -(def: .public (empty order) +(def .public (empty order) (All (_ k v) (-> (Order k) (Dictionary k v))) [#order order #root {.#None}]) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (value key dict) +(def .public (value key dict) (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [... (open "_#[0]") (the #order dict) ] @@ -83,7 +83,7 @@ ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (key? dict key) +(def .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (let [... (open "_#[0]") (the #order dict) ] @@ -102,7 +102,7 @@ (again (the #right node))))))))) (with_template [<name> <side>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (the #root dict) {.#None} @@ -121,7 +121,7 @@ [max #right] ) -(def: .public (size dict) +(def .public (size dict) (All (_ k v) (-> (Dictionary k v) Nat)) (loop (again [node (the #root dict)]) (case node @@ -132,12 +132,12 @@ (++ (n.+ (again (the #left node)) (again (the #right node))))))) -(def: .public empty? +(def .public empty? (All (_ k v) (-> (Dictionary k v) Bit)) (|>> ..size (n.= 0))) (with_template [<name> <other_color> <self_color> <no_change>] - [(def: (<name> self) + [(def (<name> self) (All (_ k v) (-> (Node k v) (Node k v))) (case (the #color self) {<other_color>} @@ -151,7 +151,7 @@ [reddened #Black #Red (panic! error_message)] ) -(def: (with_left addition center) +(def (with_left addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -200,7 +200,7 @@ {#Black} <default_behavior>)))) -(def: (with_right addition center) +(def (with_right addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -249,7 +249,7 @@ {#Black} <default_behavior>)))) -(def: .public (has key value dict) +(def .public (has key value dict) (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) root' (loop (again [?root (the #root dict)]) @@ -278,7 +278,7 @@ ))] (.has #root root' dict))) -(def: (left_balanced key value ?left ?right) +(def (left_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -307,7 +307,7 @@ _ (black key value ?left ?right))) -(def: (right_balanced key value ?left ?right) +(def (right_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -334,7 +334,7 @@ _ (black key value ?left ?right))) -(def: (without_left key value ?left ?right) +(def (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -363,7 +363,7 @@ (panic! error_message)) )) -(def: (without_right key value ?left ?right) +(def (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -392,7 +392,7 @@ (panic! error_message) ))) -(def: (prepended ?left ?right) +(def (prepended ?left ?right) (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] [{.#None} _] @@ -472,7 +472,7 @@ _ (undefined))) -(def: .public (lacks key dict) +(def .public (lacks key dict) (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) [?root found?] (loop (again [?root (the #root dict)]) @@ -527,7 +527,7 @@ (.has #root {.#Some (blackened root)} dict) ))) -(def: .public (revised key transform dict) +(def .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) {.#Some old} @@ -536,7 +536,7 @@ {.#None} dict)) -(def: .public (of_list order list) +(def .public (of_list order list) (All (_ k v) (-> (Order k) (List [k v]) (Dictionary k v))) (list#mix (function (_ [key value] dict) (..has key value dict)) @@ -544,7 +544,7 @@ list)) (with_template [<name> <type> <output>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (List <type>))) (loop (again [node (the #root dict)]) (case node @@ -562,10 +562,10 @@ [values v (the #value node')] ) -(def: .public (equivalence (open ",#[0]")) +(def .public (equivalence (open ",#[0]")) (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [(open "/#[0]") (the #order reference)] (loop (again [entriesR (entries reference) entriesS (entries sample)]) |