on master help sign in
Remove dependency on hashable/unordered-containers
1cd4379Harendra Kumar
benchmark/Streamly/Benchmark/Data/Fold.hs+1
@@ -25,6 +25,7 @@ import System.Random (randomRIO)
25
25
26import Streamly.Prelude (SerialT)
26import Streamly.Prelude (SerialT)
27import Streamly.Internal.Data.Fold (Fold(..))
27import Streamly.Internal.Data.Fold (Fold(..))
28+import Streamly.Internal.Data.IsMap.HashMap ()
28
29
29import qualified Streamly.Internal.Data.Fold as FL
30import qualified Streamly.Internal.Data.Fold as FL
30import qualified Streamly.Internal.Data.Unfold as Unfold
31import qualified Streamly.Internal.Data.Unfold as Unfold
benchmark/Streamly/Benchmark/Prelude/Serial/NestedFold.hs+1
@@ -20,6 +20,7 @@ import Data.Monoid (Sum(..))
20import Data.Proxy (Proxy(..))
20import Data.Proxy (Proxy(..))
21import Data.HashMap.Strict (HashMap)
21import Data.HashMap.Strict (HashMap)
22import GHC.Generics (Generic)
22import GHC.Generics (Generic)
23+import Streamly.Internal.Data.IsMap.HashMap ()
23
24
24import qualified Streamly.Internal.Data.Refold.Type as Refold
25import qualified Streamly.Internal.Data.Refold.Type as Refold
25import qualified Streamly.Internal.Data.Fold as FL
26import qualified Streamly.Internal.Data.Fold as FL
core/src/Streamly/Internal/Data/IsMap.hs−13
@@ -8,11 +8,9 @@
8
8
9module Streamly.Internal.Data.IsMap (IsMap(..)) where
9module Streamly.Internal.Data.IsMap (IsMap(..)) where
10
10
11−import Data.Hashable (Hashable)
12import Data.Kind (Type)
11import Data.Kind (Type)
13import Data.Map.Strict (Map)
12import Data.Map.Strict (Map)
14
13
15−import qualified Data.HashMap.Strict as HashMap
16import qualified Data.IntMap.Strict as IntMap
14import qualified Data.IntMap.Strict as IntMap
17import qualified Data.Map.Strict as Map
15import qualified Data.Map.Strict as Map
18
16
@@ -52,14 +50,3 @@ instance IsMap IntMap.IntMap where
52 mapDelete = IntMap.delete
50 mapDelete = IntMap.delete
53 mapUnion = IntMap.union
51 mapUnion = IntMap.union
54 mapNull = IntMap.null
52 mapNull = IntMap.null
55−
56−instance (Hashable k, Eq k) => IsMap (HashMap.HashMap k) where
57− type Key (HashMap.HashMap k) = k
58−
59− mapEmpty = HashMap.empty
60− mapAlterF = HashMap.alterF
61− mapLookup = HashMap.lookup
62− mapInsert = HashMap.insert
63− mapDelete = HashMap.delete
64− mapUnion = HashMap.union
65− mapNull = HashMap.null
core/streamly-core.cabal−2
@@ -364,8 +364,6 @@ library
364 , transformers-base >= 0.4 && < 0.5
364 , transformers-base >= 0.4 && < 0.5
365 , primitive >= 0.5.4 && < 0.8
365 , primitive >= 0.5.4 && < 0.8
366 , heaps >= 0.3 && < 0.5
366 , heaps >= 0.3 && < 0.5
367− , hashable >= 1.3 && < 1.5
368− , unordered-containers >= 0.2 && < 0.3
369 if flag(use-unliftio)
367 if flag(use-unliftio)
370 build-depends: unliftio-core >= 0.2 && < 0.3
368 build-depends: unliftio-core >= 0.2 && < 0.3
371 else
369 else
src/Streamly/Internal/Data/IsMap/HashMap.hsnew file+32
@@ -0,0 +1,32 @@
1+{-# OPTIONS_GHC -Wno-orphans #-}
2+
3+-- |
4+-- Module : Streamly.Internal.Data.IsMap.HashMap
5+-- Copyright : (c) 2022 Composewell Technologies
6+-- License : BSD-3-Clause
7+-- Maintainer : streamly@composewell.com
8+-- Stability : experimental
9+-- Portability : GHC
10+--
11+-- Adds an orphan HashMap instance for the IsMap type class from streamly-core
12+-- package. This is useful for various combinators that use a map type. We
13+-- cannot define this in streamly-core as it adds several non-boot library
14+-- dependencies on streamly-core.
15+
16+module Streamly.Internal.Data.IsMap.HashMap () where
17+
18+import Data.Hashable (Hashable)
19+import Streamly.Internal.Data.IsMap (IsMap(..))
20+
21+import qualified Data.HashMap.Strict as HashMap
22+
23+instance (Hashable k, Eq k) => IsMap (HashMap.HashMap k) where
24+ type Key (HashMap.HashMap k) = k
25+
26+ mapEmpty = HashMap.empty
27+ mapAlterF = HashMap.alterF
28+ mapLookup = HashMap.lookup
29+ mapInsert = HashMap.insert
30+ mapDelete = HashMap.delete
31+ mapUnion = HashMap.union
32+ mapNull = HashMap.null
streamly.cabal+5−1
@@ -433,6 +433,8 @@ library
433 -- XXX To be moved to streamly-core
433 -- XXX To be moved to streamly-core
434 Streamly.Data.Unfold
434 Streamly.Data.Unfold
435
435
436+ , Streamly.Internal.Data.IsMap.HashMap
437+
436 -- XXX To be removed or put under dev flag
438 -- XXX To be removed or put under dev flag
437 , Streamly.Internal.Data.SmallArray.Type
439 , Streamly.Internal.Data.SmallArray.Type
438 , Streamly.Internal.Data.SmallArray
440 , Streamly.Internal.Data.SmallArray
@@ -668,9 +670,11 @@ library
668
670
669 -- The core streamly package
671 -- The core streamly package
670 , streamly-core == 0.1.0
672 , streamly-core == 0.1.0
671−
672 , fusion-plugin-types >= 0.1 && < 0.2
673 , fusion-plugin-types >= 0.1 && < 0.2
673
674
675+ , hashable >= 1.3 && < 1.5
676+ , unordered-containers >= 0.2 && < 0.3
677+
674 -- XXX to be removed
678 -- XXX to be removed
675 , transformers-base >= 0.4 && < 0.5
679 , transformers-base >= 0.4 && < 0.5
676 , primitive >= 0.5.4 && < 0.8
680 , primitive >= 0.5.4 && < 0.8