This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1515
1616 instance functorMap :: P.Functor (Map k)
1717
18+ instance monoidMap :: (P.Ord k) => Monoid (Map k v)
19+
20+ instance semigroupMap :: (P.Ord k) => P.Semigroup (Map k v)
21+
1822 instance showMap :: (P.Show k, P.Show v) => P.Show (Map k v)
1923
2024 instance traversableMap :: (P.Ord k) => Traversable (Map k)
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import qualified Prelude as P
3232import qualified Data.Array as A
3333import Data.Maybe
3434import Data.Tuple
35+ import Data.Monoid (Monoid )
3536import Data.Foldable (foldl , foldMap , foldr , Foldable )
3637import Data.Traversable (traverse , Traversable )
3738
@@ -47,6 +48,12 @@ instance eqMap :: (P.Eq k, P.Eq v) => P.Eq (Map k v) where
4748instance showMap :: (P.Show k , P.Show v ) => P.Show (Map k v ) where
4849 show m = " fromList " P .++ P .show (toList m)
4950
51+ instance semigroupMap :: (P.Ord k ) => P.Semigroup (Map k v ) where
52+ (<>) = union
53+
54+ instance monoidMap :: (P.Ord k ) => Monoid (Map k v ) where
55+ mempty = empty
56+
5057instance functorMap :: P.Functor (Map k ) where
5158 (<$>) _ Leaf = Leaf
5259 (<$>) f (Two left k v right) = Two (f P .<$> left) k (f v) (f P .<$> right)
You can’t perform that action at this time.
0 commit comments