git.iko.soy/monoidal-containers
on master help sign in
replace Monoid depends with Semigroup, and uses of mappend with (<>)
commitaf5f6cedd1acd8725b19fd6a0277f83906603491 authorhsloan <ishaqsloan@gmail.com> dateTue 24 Jul 2018, 14:22 (8 years ago) parentb0d505b
4 files changed+17−17
monoidal-containers.cabal+1−1 src/Data/HashMap/Monoidal.hs+8−8 src/Data/Map/Monoidal.hs+4−4 src/Data/Map/Monoidal/Strict.hs+4−4
monoidal-containers.cabal+1−1
@@ -12,7 +12,7 @@ description:
1212 the @Monoid@ @Map@ instance looks like,
1313 .
1414 @
15− instance (Ord k, Monoid a) => Monoid (MonoidalMap k a)
15+ instance (Ord k, Semigroup a) => Monoid (MonoidalMap k a)
1616 @
1717homepage: http://github.com/bgamari/monoidal-containers
1818license: BSD3
src/Data/HashMap/Monoidal.hs+8−8
@@ -98,11 +98,11 @@ instance (Eq k, Hashable k, Semigroup a) => Semigroup (MonoidalHashMap k a) wher
9898 MonoidalHashMap a <> MonoidalHashMap b = MonoidalHashMap $ M.unionWith (<>) a b
9999 {-# INLINE (<>) #-}
100100
101−instance (Eq k, Hashable k, Monoid a) => Monoid (MonoidalHashMap k a) where
101+instance (Eq k, Hashable k, Semigroup a) => Monoid (MonoidalHashMap k a) where
102102 mempty = MonoidalHashMap mempty
103103 {-# INLINE mempty #-}
104104#if !(MIN_VERSION_base(4,11,0))
105− mappend (MonoidalHashMap a) (MonoidalHashMap b) = MonoidalHashMap $ M.unionWith mappend a b
105+ mappend (MonoidalHashMap a) (MonoidalHashMap b) = MonoidalHashMap $ M.unionWith (<>) a b
106106 {-# INLINE mappend #-}
107107#endif
108108
@@ -113,9 +113,9 @@ instance Newtype (MonoidalHashMap k a) (M.HashMap k a) where
113113 {-# INLINE unpack #-}
114114
115115#if MIN_VERSION_base(4,7,0)
116−instance (Eq k, Hashable k, Monoid a) => Exts.IsList (MonoidalHashMap k a) where
116+instance (Eq k, Hashable k, Semigroup a) => Exts.IsList (MonoidalHashMap k a) where
117117 type Item (MonoidalHashMap k a) = (k, a)
118− fromList = MonoidalHashMap . M.fromListWith mappend
118+ fromList = MonoidalHashMap . M.fromListWith (<>)
119119 {-# INLINE fromList #-}
120120 toList = M.toList . unpack
121121 {-# INLINE toList #-}
@@ -173,8 +173,8 @@ keys = M.keys . unpack
173173
174174-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
175175-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
176−fromList :: (Eq k, Hashable k, Monoid a) => [(k,a)] -> MonoidalHashMap k a
177−fromList = pack . M.fromListWith mappend
176+fromList :: (Eq k, Hashable k, Semigroup a) => [(k,a)] -> MonoidalHashMap k a
177+fromList = pack . M.fromListWith (<>)
178178{-# INLINE fromList #-}
179179
180180-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
@@ -218,7 +218,7 @@ modify f k = pack
218218
219219-- | /O(log n)/. Modify a value on some key with a function, providing
220220-- a default value if that key doesn't exist.
221−modifyDef :: (Monoid a, Hashable k, Eq k)
221+modifyDef :: (Semigroup a, Hashable k, Eq k)
222222 => a -> (a -> a)
223223 -> k -> MonoidalHashMap k a
224224 -> MonoidalHashMap k a
@@ -229,7 +229,7 @@ modifyDef d f k = pack
229229
230230-- | /O(n)/. Map a function to each key of a map, if it will result
231231-- in duplicated mappings, their values will be merged in unspecified order
232−mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
232+mapKeys :: (Semigroup a, Hashable k, Eq k, Hashable k', Eq k')
233233 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
234234mapKeys f = fromList
235235 . fmap (\(k, v) -> (f k, v))
src/Data/Map/Monoidal.hs+4−4
@@ -93,11 +93,11 @@ instance (Ord k, Semigroup a) => Semigroup (MonoidalMap k a) where
9393 MonoidalMap a <> MonoidalMap b = MonoidalMap $ M.unionWith (<>) a b
9494 {-# INLINE (<>) #-}
9595
96−instance (Ord k, Monoid a) => Monoid (MonoidalMap k a) where
96+instance (Ord k, Semigroup a) => Monoid (MonoidalMap k a) where
9797 mempty = MonoidalMap mempty
9898 {-# INLINE mempty #-}
9999#if !(MIN_VERSION_base(4,11,0))
100− mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith mappend a b
100+ mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith (<>) a b
101101 {-# INLINE mappend #-}
102102#endif
103103
@@ -108,9 +108,9 @@ instance Newtype (MonoidalMap k a) (M.Map k a) where
108108 {-# INLINE unpack #-}
109109
110110#if MIN_VERSION_base(4,7,0)
111−instance (Ord k, Monoid a) => IsList (MonoidalMap k a) where
111+instance (Ord k, Semigroup a) => IsList (MonoidalMap k a) where
112112 type Item (MonoidalMap k a) = (k, a)
113− fromList = MonoidalMap . M.fromListWith mappend
113+ fromList = MonoidalMap . M.fromListWith (<>)
114114 {-# INLINE fromList #-}
115115 toList = M.toList . unpack
116116 {-# INLINE toList #-}
src/Data/Map/Monoidal/Strict.hs+4−4
@@ -93,11 +93,11 @@ instance (Ord k, Semigroup a) => Semigroup (MonoidalMap k a) where
9393 MonoidalMap a <> MonoidalMap b = MonoidalMap $ M.unionWith (<>) a b
9494 {-# INLINE (<>) #-}
9595
96−instance (Ord k, Semigroup a, Monoid a) => Monoid (MonoidalMap k a) where
96+instance (Ord k, Semigroup a) => Monoid (MonoidalMap k a) where
9797 mempty = MonoidalMap mempty
9898 {-# INLINE mempty #-}
9999#if !(MIN_VERSION_base(4,11,0))
100− mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith mappend a b
100+ mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith (<>) a b
101101 {-# INLINE mappend #-}
102102#endif
103103
@@ -108,9 +108,9 @@ instance Newtype (MonoidalMap k a) (M.Map k a) where
108108 {-# INLINE unpack #-}
109109
110110#if MIN_VERSION_base(4,7,0)
111−instance (Ord k, Monoid a) => IsList (MonoidalMap k a) where
111+instance (Ord k, Semigroup a) => IsList (MonoidalMap k a) where
112112 type Item (MonoidalMap k a) = (k, a)
113− fromList = MonoidalMap . M.fromListWith mappend
113+ fromList = MonoidalMap . M.fromListWith (<>)
114114 {-# INLINE fromList #-}
115115 toList = M.toList . unpack
116116 {-# INLINE toList #-}