From a37376e6010d557a82c750e3bbf0c7091f2fdadf Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sun, 15 Oct 2023 15:32:58 +0100 Subject: [PATCH] Add instance Functor (PolyDiff a), required by class Bifunctor since base-4.18 See https://hackage.haskell.org/package/base-4.19.0.0/docs/Data-Bifunctor.html#t:Bifunctor and https://github.com/haskell/core-libraries-committee/issues/91 --- src/Data/Algorithm/Diff.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Data/Algorithm/Diff.hs b/src/Data/Algorithm/Diff.hs index 25d7e7b..e025166 100644 --- a/src/Data/Algorithm/Diff.hs +++ b/src/Data/Algorithm/Diff.hs @@ -38,6 +38,11 @@ data DI = F | S deriving (Show, Eq) data PolyDiff a b = First a | Second b | Both a b deriving (Show, Eq) +instance Functor (PolyDiff a) where + fmap _ (First a) = First a + fmap g (Second b) = Second (g b) + fmap g (Both a b) = Both a (g b) + instance Bifunctor PolyDiff where bimap f _ (First a) = First (f a) bimap _ g (Second b) = Second (g b)