1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Define a Monoid instance for Map.

This commit is contained in:
Rob Rix 2018-03-07 12:26:32 -05:00
parent 303e55b403
commit f199e7fa73

View File

@ -10,3 +10,7 @@ newtype Map key value = Map { unMap :: Map.Map key value }
instance (Ord key, Semigroup value) => Semigroup (Map key value) where instance (Ord key, Semigroup value) => Semigroup (Map key value) where
Map a <> Map b = Map (Map.unionWith (<>) a b) Map a <> Map b = Map (Map.unionWith (<>) a b)
instance (Ord key, Semigroup value) => Monoid (Map key value) where
mempty = Map Map.empty
mappend = (<>)