@@ -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