From 4278177e3d5dbfcc9da9f952ab8cc4173c568cc4 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Mon, 28 Dec 2020 19:56:47 +0100 Subject: [PATCH] Implement Semigroup via unionWith --- src/Foreign/Object.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Foreign/Object.purs b/src/Foreign/Object.purs index f1d60b3..6f89c78 100644 --- a/src/Foreign/Object.purs +++ b/src/Foreign/Object.purs @@ -280,7 +280,7 @@ mapWithKey :: forall a b. (String -> a -> b) -> Object a -> Object b mapWithKey f m = runFn2 _mapWithKey m f instance semigroupObject :: (Semigroup a) => Semigroup (Object a) where - append m1 m2 = mutate (\s1 -> foldM (\s2 k v1 -> OST.poke k (runFn4 _lookup v1 (\v2 -> v1 <> v2) k m2) s2) s1 m1) m2 + append = unionWith (<>) instance monoidObject :: (Semigroup a) => Monoid (Object a) where mempty = empty