File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ import Data.Monoid (Monoid(mempty, mappend))
95
95
import Data.Traversable (Traversable (.. ))
96
96
import Data.Word (Word )
97
97
#endif
98
+ #if __GLASGOW_HASKELL__ >= 711
99
+ import Data.Semigroup (Semigroup ((<>) ))
100
+ #endif
98
101
import Control.DeepSeq (NFData (rnf ))
99
102
import Control.Monad.ST (ST )
100
103
import Data.Bits ((.&.) , (.|.) , complement )
@@ -163,10 +166,20 @@ instance Functor (HashMap k) where
163
166
instance Foldable. Foldable (HashMap k ) where
164
167
foldr f = foldrWithKey (const f)
165
168
169
+ #if __GLASGOW_HASKELL__ >= 711
170
+ instance (Eq k , Hashable k ) => Semigroup (HashMap k v ) where
171
+ (<>) = union
172
+ {-# INLINE (<>) #-}
173
+ #endif
174
+
166
175
instance (Eq k , Hashable k ) => Monoid (HashMap k v ) where
167
176
mempty = empty
168
177
{-# INLINE mempty #-}
178
+ #if __GLASGOW_HASKELL__ >= 711
179
+ mappend = (<>)
180
+ #else
169
181
mappend = union
182
+ #endif
170
183
{-# INLINE mappend #-}
171
184
172
185
instance (Data k , Data v , Eq k , Hashable k ) => Data (HashMap k v ) where
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ import Control.DeepSeq (NFData(..))
76
76
import Data.Data hiding (Typeable )
77
77
import Data.HashMap.Base (HashMap , foldrWithKey )
78
78
import Data.Hashable (Hashable (hashWithSalt ))
79
- #if __GLASGOW_HASKELL__ < 709
79
+ #if __GLASGOW_HASKELL__ >= 711
80
+ import Data.Semigroup (Semigroup (.. ), Monoid (.. ))
81
+ #elif __GLASGOW_HASKELL__ < 709
80
82
import Data.Monoid (Monoid (.. ))
81
83
#endif
82
84
import GHC.Exts (build )
@@ -114,10 +116,20 @@ instance Foldable.Foldable HashSet where
114
116
foldr = Data.HashSet. foldr
115
117
{-# INLINE foldr #-}
116
118
119
+ #if __GLASGOW_HASKELL__ >= 711
120
+ instance (Hashable a , Eq a ) => Semigroup (HashSet a ) where
121
+ (<>) = union
122
+ {-# INLINE (<>) #-}
123
+ #endif
124
+
117
125
instance (Hashable a , Eq a ) => Monoid (HashSet a ) where
118
126
mempty = empty
119
127
{-# INLINE mempty #-}
128
+ #if __GLASGOW_HASKELL__ >= 711
129
+ mappend = (<>)
130
+ #else
120
131
mappend = union
132
+ #endif
121
133
{-# INLINE mappend #-}
122
134
123
135
instance (Eq a , Hashable a , Read a ) => Read (HashSet a ) where
You can’t perform that action at this time.
0 commit comments