summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Data
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-07-01 08:51:59 +0000
committerkrasimir <krasimir@chalmers.se>2010-07-01 08:51:59 +0000
commit5ae7be358daf169a3852d93f36c30c4ce7d0363e (patch)
treedcbc25272686a5e04da654c657bd140c349aac2b /src/compiler/GF/Data
parent706b215fce733ab4e342bce4fc9cc37c16f9875c (diff)
redesign the open-literals API
Diffstat (limited to 'src/compiler/GF/Data')
-rw-r--r--src/compiler/GF/Data/TrieMap.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/GF/Data/TrieMap.hs b/src/compiler/GF/Data/TrieMap.hs
index a6749d641..a15c780ab 100644
--- a/src/compiler/GF/Data/TrieMap.hs
+++ b/src/compiler/GF/Data/TrieMap.hs
@@ -11,8 +11,8 @@ module GF.Data.TrieMap
, insertWith
- , unionWith
- , unionsWith
+ , union, unionWith
+ , unions, unionsWith
, elems
) where
@@ -47,6 +47,9 @@ insertWith f (k:ks) v0 (Tr mb_v m) = case Map.lookup k m of
Nothing -> Tr mb_v (Map.insert k (singleton ks v0) m)
Just tr -> Tr mb_v (Map.insert k (insertWith f ks v0 tr) m)
+union :: Ord k => TrieMap k v -> TrieMap k v -> TrieMap k v
+union = unionWith (\a b -> a)
+
unionWith :: Ord k => (v -> v -> v) -> TrieMap k v -> TrieMap k v -> TrieMap k v
unionWith f (Tr mb_v1 m1) (Tr mb_v2 m2) =
let mb_v = case (mb_v1,mb_v2) of
@@ -57,6 +60,9 @@ unionWith f (Tr mb_v1 m1) (Tr mb_v2 m2) =
m = Map.unionWith (unionWith f) m1 m2
in Tr mb_v m
+unions :: Ord k => [TrieMap k v] -> TrieMap k v
+unions = foldl union empty
+
unionsWith :: Ord k => (v -> v -> v) -> [TrieMap k v] -> TrieMap k v
unionsWith f = foldl (unionWith f) empty