Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Data/IntMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ import Data.Functor.Classes
import Control.DeepSeq (NFData(rnf))
import Data.Bits
import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable())
import Data.Maybe (fromMaybe)
import Data.Typeable
import Prelude hiding (lookup, map, filter, foldr, foldl, null)

import Data.IntSet.Internal (Key)
import qualified Data.IntSet.Internal as IntSet
import Utils.Containers.Internal.BitUtil
import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair

#if __GLASGOW_HASKELL__
Expand Down Expand Up @@ -1003,18 +1003,18 @@ alterF f k m = (<$> f mv) $ \fres ->
-- > unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
-- > == fromList [(3, "B3"), (5, "A3"), (7, "C")]

unions :: [IntMap a] -> IntMap a
unions :: Foldable f => f (IntMap a) -> IntMap a
unions xs
= foldlStrict union empty xs
= Foldable.foldl' union empty xs

-- | The union of a list of maps, with a combining operation.
--
-- > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
-- > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]

unionsWith :: (a->a->a) -> [IntMap a] -> IntMap a
unionsWith :: Foldable f => (a->a->a) -> f (IntMap a) -> IntMap a
unionsWith f ts
= foldlStrict (unionWith f) empty ts
= Foldable.foldl' (unionWith f) empty ts

-- | /O(n+m)/. The (left-biased) union of two maps.
-- It prefers the first map when duplicate keys are encountered,
Expand Down Expand Up @@ -3031,7 +3031,7 @@ foldlFB = foldlWithKey

fromList :: [(Key,a)] -> IntMap a
fromList xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insert k x t

Expand All @@ -3052,7 +3052,7 @@ fromListWith f xs

fromListWithKey :: (Key -> a -> a -> a) -> [(Key,a)] -> IntMap a
fromListWithKey f xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insertWithKey f k x t

Expand Down
11 changes: 6 additions & 5 deletions Data/IntMap/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,13 @@ import Data.IntMap.Internal
import Data.IntMap.Internal.DeprecatedDebug (showTree, showTreeWith)
import qualified Data.IntSet.Internal as IntSet
import Utils.Containers.Internal.BitUtil
import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair
#if !MIN_VERSION_base(4,8,0)
import Data.Functor((<$>))
#endif
import Control.Applicative (Applicative (..), liftA2)
import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable())

{--------------------------------------------------------------------
Query
Expand Down Expand Up @@ -631,9 +632,9 @@ alterF f k m = (<$> f mv) $ \fres ->
-- > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
-- > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]

unionsWith :: (a->a->a) -> [IntMap a] -> IntMap a
unionsWith :: Foldable f => (a->a->a) -> f (IntMap a) -> IntMap a
unionsWith f ts
= foldlStrict (unionWith f) empty ts
= Foldable.foldl' (unionWith f) empty ts

-- | /O(n+m)/. The union with a combining function.
--
Expand Down Expand Up @@ -1042,7 +1043,7 @@ fromSet f (IntSet.Tip kx bm) = buildTree f kx bm (IntSet.suffixBitMask + 1)

fromList :: [(Key,a)] -> IntMap a
fromList xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insert k x t

Expand All @@ -1062,7 +1063,7 @@ fromListWith f xs

fromListWithKey :: (Key -> a -> a -> a) -> [(Key,a)] -> IntMap a
fromListWithKey f xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insertWithKey f k x t

Expand Down
9 changes: 5 additions & 4 deletions Data/IntSet/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ import Data.Typeable
import Prelude hiding (filter, foldr, foldl, null, map)

import Utils.Containers.Internal.BitUtil
import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair

#if __GLASGOW_HASKELL__
Expand All @@ -217,6 +216,8 @@ import qualified GHC.Exts as GHCExts
import GHC.Prim (indexInt8OffAddr#)
#endif

import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable())

infixl 9 \\{-This comment teaches CPP correct behaviour -}

Expand Down Expand Up @@ -499,9 +500,9 @@ deleteBM _ _ Nil = Nil
Union
--------------------------------------------------------------------}
-- | The union of a list of sets.
unions :: [IntSet] -> IntSet
unions :: Foldable f => f IntSet -> IntSet
unions xs
= foldlStrict union empty xs
= Foldable.foldl' union empty xs


-- | /O(n+m)/. The union of two sets.
Expand Down Expand Up @@ -1044,7 +1045,7 @@ foldlFB = foldl
-- | /O(n*min(n,W))/. Create a set from a list of integers.
fromList :: [Key] -> IntSet
fromList xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t x = insert x t

Expand Down
14 changes: 7 additions & 7 deletions Data/Map/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ import Control.Applicative (Const (..))
import Control.DeepSeq (NFData(rnf))
import Data.Bits (shiftL, shiftR)
import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable())
import Data.Typeable
import Prelude hiding (lookup, map, filter, foldr, foldl, null, splitAt, take, drop)

import qualified Data.Set.Internal as Set
import Data.Set.Internal (Set)
import Utils.Containers.Internal.PtrEquality (ptrEq)
import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair
import Utils.Containers.Internal.StrictMaybe
import Utils.Containers.Internal.BitQueue
Expand Down Expand Up @@ -1782,9 +1782,9 @@ maxView t = case maxViewWithKey t of
-- > unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
-- > == fromList [(3, "B3"), (5, "A3"), (7, "C")]

unions :: Ord k => [Map k a] -> Map k a
unions :: (Foldable f, Ord k) => f (Map k a) -> Map k a
unions ts
= foldlStrict union empty ts
= Foldable.foldl' union empty ts
#if __GLASGOW_HASKELL__
{-# INLINABLE unions #-}
#endif
Expand All @@ -1795,9 +1795,9 @@ unions ts
-- > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
-- > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]

unionsWith :: Ord k => (a->a->a) -> [Map k a] -> Map k a
unionsWith :: (Foldable f, Ord k) => (a->a->a) -> f (Map k a) -> Map k a
unionsWith f ts
= foldlStrict (unionWith f) empty ts
= Foldable.foldl' (unionWith f) empty ts
#if __GLASGOW_HASKELL__
{-# INLINABLE unionsWith #-}
#endif
Expand Down Expand Up @@ -3348,7 +3348,7 @@ fromList ((kx0, x0) : xs0) | not_ordered kx0 xs0 = fromList' (Bin 1 kx0 x0 Tip T
not_ordered kx ((ky,_) : _) = kx >= ky
{-# INLINE not_ordered #-}

fromList' t0 xs = foldlStrict ins t0 xs
fromList' t0 xs = Foldable.foldl' ins t0 xs
where ins t (k,x) = insert k x t

go !_ t [] = t
Expand Down Expand Up @@ -3397,7 +3397,7 @@ fromListWith f xs

fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k,a)] -> Map k a
fromListWithKey f xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insertWithKey f k x t
#if __GLASGOW_HASKELL__
Expand Down
11 changes: 6 additions & 5 deletions Data/Map/Strict/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ import Control.Applicative (Applicative (..), (<$>))
#endif
import qualified Data.Set.Internal as Set
import qualified Data.Map.Internal as L
import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair

import Data.Bits (shiftL, shiftR)
Expand All @@ -418,6 +417,8 @@ import Data.Coerce
import Data.Functor.Identity (Identity (..))
#endif

import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable())

-- $strictness
--
Expand Down Expand Up @@ -951,9 +952,9 @@ updateMaxWithKey f (Bin _ kx x l r) = balanceL kx x l (updateMaxWithKey f r)
-- > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
-- > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]

unionsWith :: Ord k => (a->a->a) -> [Map k a] -> Map k a
unionsWith :: (Foldable f, Ord k) => (a->a->a) -> f (Map k a) -> Map k a
unionsWith f ts
= foldlStrict (unionWith f) empty ts
= Foldable.foldl' (unionWith f) empty ts
#if __GLASGOW_HASKELL__
{-# INLINABLE unionsWith #-}
#endif
Expand Down Expand Up @@ -1487,7 +1488,7 @@ fromList ((kx0, x0) : xs0) | not_ordered kx0 xs0 = x0 `seq` fromList' (Bin 1 kx0
not_ordered kx ((ky,_) : _) = kx >= ky
{-# INLINE not_ordered #-}

fromList' t0 xs = foldlStrict ins t0 xs
fromList' t0 xs = Foldable.foldl' ins t0 xs
where ins t (k,x) = insert k x t

go !_ t [] = t
Expand Down Expand Up @@ -1536,7 +1537,7 @@ fromListWith f xs

fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k,a)] -> Map k a
fromListWithKey f xs
= foldlStrict ins empty xs
= Foldable.foldl' ins empty xs
where
ins t (k,x) = insertWithKey f k x t
#if __GLASGOW_HASKELL__
Expand Down
7 changes: 3 additions & 4 deletions Data/Set/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ import Data.Foldable (Foldable (foldMap))
import Data.Typeable
import Control.DeepSeq (NFData(rnf))

import Utils.Containers.Internal.StrictFold
import Utils.Containers.Internal.StrictPair
import Utils.Containers.Internal.PtrEquality

Expand Down Expand Up @@ -705,8 +704,8 @@ deleteMax Tip = Tip
Union.
--------------------------------------------------------------------}
-- | The union of a list of sets: (@'unions' == 'foldl' 'union' 'empty'@).
unions :: Ord a => [Set a] -> Set a
unions = foldlStrict union empty
unions :: (Foldable f, Ord a) => f (Set a) -> Set a
unions = Foldable.foldl' union empty
#if __GLASGOW_HASKELL__
{-# INLINABLE unions #-}
#endif
Expand Down Expand Up @@ -973,7 +972,7 @@ fromList (x0 : xs0) | not_ordered x0 xs0 = fromList' (Bin 1 x0 Tip Tip) xs0
not_ordered x (y : _) = x >= y
{-# INLINE not_ordered #-}

fromList' t0 xs = foldlStrict ins t0 xs
fromList' t0 xs = Foldable.foldl' ins t0 xs
where ins t x = insert x t

go !_ t [] = t
Expand Down
20 changes: 0 additions & 20 deletions Utils/Containers/Internal/StrictFold.hs

This file was deleted.

13 changes: 0 additions & 13 deletions containers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Library

other-modules:
Utils.Containers.Internal.State
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.Coercions
Expand Down Expand Up @@ -209,7 +208,6 @@ benchmark lookupge-intmap
Data.IntSet.Internal
LookupGE_IntMap
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
ghc-options: -O2
cpp-options: -DTESTING
Expand Down Expand Up @@ -238,7 +236,6 @@ benchmark lookupge-map
Utils.Containers.Internal.BitQueue
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.StrictPair
ghc-options: -O2
Expand Down Expand Up @@ -273,7 +270,6 @@ Test-suite map-lazy-properties
Utils.Containers.Internal.BitQueue
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -307,7 +303,6 @@ Test-suite map-strict-properties
Utils.Containers.Internal.BitQueue
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -355,7 +350,6 @@ Test-suite set-properties
Data.Set.Internal
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
cpp-options: -DTESTING
Expand Down Expand Up @@ -385,7 +379,6 @@ Test-suite intmap-lazy-properties
Data.IntSet.Internal
IntMapValidity
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
cpp-options: -DTESTING
Expand Down Expand Up @@ -414,7 +407,6 @@ Test-suite intmap-strict-properties
Data.IntSet.Internal
IntMapValidity
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
cpp-options: -DTESTING -DSTRICT
Expand Down Expand Up @@ -442,7 +434,6 @@ Test-suite intset-properties
IntSetValidity
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
cpp-options: -DTESTING
Expand Down Expand Up @@ -480,7 +471,6 @@ Test-suite deprecated-properties
Utils.Containers.Internal.BitQueue
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -549,7 +539,6 @@ test-suite map-strictness-properties
Utils.Containers.Internal.BitQueue
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.PtrEquality
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictMaybe
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -577,7 +566,6 @@ test-suite intmap-strictness-properties
Data.IntMap.Strict
Data.IntSet.Internal
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
other-extensions: CPP, BangPatterns
Expand All @@ -602,7 +590,6 @@ test-suite intset-strictness-properties
Data.IntSet
Data.IntSet.Internal
Utils.Containers.Internal.BitUtil
Utils.Containers.Internal.StrictFold
Utils.Containers.Internal.StrictPair
type: exitcode-stdio-1.0
other-extensions: CPP, BangPatterns
Expand Down