Commit 254d9995 authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'dataMapRemoveFoldlStrict' into 'master'

Data.Map: remove foldlStrict

See merge request !253
parents abb84e35 44d69fee
Pipeline #23462 passed with stage
in 3 minutes and 53 seconds
...@@ -438,8 +438,6 @@ union :: !(Map k a) !(Map k a) -> Map k a | < k ...@@ -438,8 +438,6 @@ union :: !(Map k a) !(Map k a) -> Map k a | < k
mergeWithKey :: !(k a b -> Maybe c) !((Map k a) -> Map k c) !((Map k b) -> Map k c) mergeWithKey :: !(k a b -> Maybe c) !((Map k a) -> Map k c) !((Map k b) -> Map k c)
!(Map k a) !(Map k b) -> Map k c | < k !(Map k a) !(Map k b) -> Map k c | < k
foldlStrict :: !(a b -> a) !a ![b] -> a
/** /**
* Removes the values at given key positions. The mapping itself can be spine unique. * Removes the values at given key positions. The mapping itself can be spine unique.
* *
......
...@@ -557,10 +557,10 @@ union t1 Tip = t1 ...@@ -557,10 +557,10 @@ union t1 Tip = t1
union t1 t2 = hedgeUnion Nothing Nothing t1 t2 union t1 t2 = hedgeUnion Nothing Nothing t1 t2
unions :: ![Map k a] -> Map k a | < k unions :: ![Map k a] -> Map k a | < k
unions ts = foldlStrict union newMap ts unions ts = foldl union newMap ts
unionsWith :: !(a a -> a) ![Map k a] -> Map k a | < k unionsWith :: !(a a -> a) ![Map k a] -> Map k a | < k
unionsWith f ts = foldlStrict (unionWith f) newMap ts unionsWith f ts = foldl (unionWith f) newMap ts
unionWith :: !(a a -> a) !(Map k a) !(Map k a) -> Map k a | < k unionWith :: !(a a -> a) !(Map k a) !(Map k a) -> Map k a | < k
unionWith f m1 m2 = unionWithKey (appUnion f) m1 m2 unionWith f m1 m2 = unionWithKey (appUnion f) m1 m2
...@@ -1088,9 +1088,9 @@ foldr` f z` (Bin _ _ x l r) = foldr` f (f x (foldr` f z` r)) l ...@@ -1088,9 +1088,9 @@ foldr` f z` (Bin _ _ x l r) = foldr` f (f x (foldr` f z` r)) l
// //
// > let f len a = len + (length a) // > let f len a = len + (length a)
// > foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4 // > foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
foldl :: !(a b -> a) !a !(Map k b) -> a /*foldl :: !(a b -> a) !a !(Map k b) -> a
foldl f z` Tip = z` foldl f z` Tip = z`
foldl f z` (Bin _ _ x l r) = foldl f (f (foldl f z` l) x) r foldl f z` (Bin _ _ x l r) = foldl f (f (foldl f z` l) x) r*/
// | /O(n)/. A strict version of 'foldl`. Each application of the operator is // | /O(n)/. A strict version of 'foldl`. Each application of the operator is
// evaluated before using the result in the next application. This // evaluated before using the result in the next application. This
...@@ -1200,7 +1200,7 @@ fromList [(kx0, x0) : xs0] ...@@ -1200,7 +1200,7 @@ fromList [(kx0, x0) : xs0]
not_ordered kx [(ky,_) : _] = kx >= ky not_ordered kx [(ky,_) : _] = kx >= ky
fromList` :: !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v] fromList` :: !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
fromList` t0 xs = foldlStrict ins t0 xs fromList` t0 xs = foldl ins t0 xs
where ins t (k,x) = put k x t where ins t (k,x) = put k x t
go :: !Int !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v] go :: !Int !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
...@@ -1244,7 +1244,7 @@ fromListWith f xs :== fromListWithKey (\_ x y -> f x y) xs ...@@ -1244,7 +1244,7 @@ fromListWith f xs :== fromListWithKey (\_ x y -> f x y) xs
// > fromListWithKey f [] == newMap // > fromListWithKey f [] == newMap
fromListWithKey :: !(k a a -> a) ![(!k, !a)] -> Map k a | < k fromListWithKey :: !(k a a -> a) ![(!k, !a)] -> Map k a | < k
fromListWithKey f xs = foldlStrict (ins f) newMap xs fromListWithKey f xs = foldl (ins f) newMap xs
where where
ins :: !(k a a -> a) !(Map k a) !(!k, !a) -> Map k a | < k ins :: !(k a a -> a) !(Map k a) !(!k, !a) -> Map k a | < k
ins f t (k, x) = putWithKey f k x t ins f t (k, x) = putWithKey f k x t
...@@ -1963,12 +1963,6 @@ validmapSize t ...@@ -1963,12 +1963,6 @@ validmapSize t
(Just n,Just m) | n+m+1 == sz -> Just sz (Just n,Just m) | n+m+1 == sz -> Just sz
_ -> Nothing _ -> Nothing
foldlStrict :: !(a b -> a) !a ![b] -> a
foldlStrict f acc [] = acc
foldlStrict f acc [x:xs]
#! z` = f acc x
= foldlStrict f z` xs
// | /O(1)/. Decompose a map into pieces based on the structure of the underlying // | /O(1)/. Decompose a map into pieces based on the structure of the underlying
// tree. This function is useful for consuming a map in parallel. // tree. This function is useful for consuming a map in parallel.
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment