1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define a Bifoldable instance for DiffF.

This commit is contained in:
Rob Rix 2017-09-09 13:35:59 +01:00
parent 2094dd059b
commit e42152dca8

View File

@ -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