on master help sign in
Remove dependency on hashable/unordered-containers
commit1cd4379d01af32a2926d7fc7650a3bbbacf8ecf5 authorHarendra Kumar <harendra@composewell.com> dateSun 31 Jul 2022, 14:20 (4 years ago) parent1f412fe
6 files changed+39−16
benchmark/Streamly/Benchmark/Data/Fold.hs+1 benchmark/Streamly/Benchmark/Prelude/Serial/NestedFold.hs+1 core/src/Streamly/Internal/Data/IsMap.hs−13 core/streamly-core.cabal−2 src/Streamly/Internal/Data/IsMap/HashMap.hs+32 streamly.cabal+5−1
benchmark/Streamly/Benchmark/Data/Fold.hs+1
@@ -25,6 +25,7 @@ import System.Random (randomRIO)
2525
2626import Streamly.Prelude (SerialT)
2727import Streamly.Internal.Data.Fold (Fold(..))
28+import Streamly.Internal.Data.IsMap.HashMap ()
2829
2930import qualified Streamly.Internal.Data.Fold as FL
3031import qualified Streamly.Internal.Data.Unfold as Unfold
benchmark/Streamly/Benchmark/Prelude/Serial/NestedFold.hs+1
@@ -20,6 +20,7 @@ import Data.Monoid (Sum(..))
2020import Data.Proxy (Proxy(..))
2121import Data.HashMap.Strict (HashMap)
2222import GHC.Generics (Generic)
23+import Streamly.Internal.Data.IsMap.HashMap ()
2324
2425import qualified Streamly.Internal.Data.Refold.Type as Refold
2526import qualified Streamly.Internal.Data.Fold as FL
core/src/Streamly/Internal/Data/IsMap.hs−13
@@ -8,11 +8,9 @@
88
99module Streamly.Internal.Data.IsMap (IsMap(..)) where
1010
11−import Data.Hashable (Hashable)
1211import Data.Kind (Type)
1312import Data.Map.Strict (Map)
1413
15−import qualified Data.HashMap.Strict as HashMap
1614import qualified Data.IntMap.Strict as IntMap
1715import qualified Data.Map.Strict as Map
1816
@@ -52,14 +50,3 @@ instance IsMap IntMap.IntMap where
5250 mapDelete = IntMap.delete
5351 mapUnion = IntMap.union
5452 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
364364 , transformers-base >= 0.4 && < 0.5
365365 , primitive >= 0.5.4 && < 0.8
366366 , heaps >= 0.3 && < 0.5
367− , hashable >= 1.3 && < 1.5
368− , unordered-containers >= 0.2 && < 0.3
369367 if flag(use-unliftio)
370368 build-depends: unliftio-core >= 0.2 && < 0.3
371369 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
433433 -- XXX To be moved to streamly-core
434434 Streamly.Data.Unfold
435435
436+ , Streamly.Internal.Data.IsMap.HashMap
437+
436438 -- XXX To be removed or put under dev flag
437439 , Streamly.Internal.Data.SmallArray.Type
438440 , Streamly.Internal.Data.SmallArray
@@ -668,9 +670,11 @@ library
668670
669671 -- The core streamly package
670672 , streamly-core == 0.1.0
671−
672673 , fusion-plugin-types >= 0.1 && < 0.2
673674
675+ , hashable >= 1.3 && < 1.5
676+ , unordered-containers >= 0.2 && < 0.3
677+
674678 -- XXX to be removed
675679 , transformers-base >= 0.4 && < 0.5
676680 , primitive >= 0.5.4 && < 0.8