on 207f948 help sign in
42 lines 1.4 kB history raw
1{-# LANGUAGE TypeFamilies #-}
2-- Must come after TypeFamilies, otherwise it is re-enabled.
3-- MonoLocalBinds enabled by TypeFamilies causes perf regressions in general.
4{-# LANGUAGE NoMonoLocalBinds #-}
6{-# OPTIONS_GHC -Wno-orphans #-}
8-- |
9-- Module : Streamly.Internal.Data.IsMap.HashMap
10-- Copyright : (c) 2022 Composewell Technologies
11-- License : BSD-3-Clause
12-- Maintainer : streamly@composewell.com
13-- Stability : experimental
14-- Portability : GHC
15--
16-- Adds an orphan HashMap instance for the IsMap type class from streamly-core
17-- package. This is useful for various combinators that use a map type. We
18-- cannot define this in streamly-core as it adds several non-boot library
19-- dependencies on streamly-core.
21module Streamly.Internal.Data.IsMap.HashMap () where
23import Data.Hashable (Hashable)
24import Streamly.Internal.Data.IsMap (IsMap(..))
26import qualified Data.HashMap.Strict as HashMap
28#if MIN_VERSION_hashable(1,4,0)
29instance (Hashable k) => IsMap (HashMap.HashMap k) where
30#else
31instance (Hashable k, Eq k) => IsMap (HashMap.HashMap k) where
32#endif
33 type Key (HashMap.HashMap k) = k
35 mapEmpty = HashMap.empty
36 mapAlterF = HashMap.alterF
37 mapLookup = HashMap.lookup
38 mapInsert = HashMap.insert
39 mapDelete = HashMap.delete
40 mapUnion = HashMap.union
41 mapNull = HashMap.null
42 mapTraverseWithKey = HashMap.traverseWithKey