From e42152dca82bc3b1d20ebdcf64777008babe3f4c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sat, 9 Sep 2017 13:35:59 +0100 Subject: [PATCH] Define a Bifoldable instance for DiffF. --- src/Diff.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Diff.hs b/src/Diff.hs index 1bc0e2395..40f9422e2 100644 --- a/src/Diff.hs +++ b/src/Diff.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DataKinds, TypeFamilies, TypeOperators #-} module Diff where +import Data.Bifoldable import Data.Bifunctor import Data.Functor.Both as Both import Data.Functor.Classes @@ -131,3 +132,8 @@ instance (Show1 f, Show a) => Show1 (DiffF f a) where instance (Show1 f, Show a, Show b) => Show (DiffF f a b) where showsPrec = showsPrec1 + + +instance Foldable f => Bifoldable (DiffF f) where + bifoldMap f g (Copy as r) = foldMap f as `mappend` foldMap g r + bifoldMap f _ (Patch p) = foldMap (foldMap f) p