Skip to content

Commit

Permalink
Add instance Functor (PolyDiff a), required by class Bifunctor since …
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Oct 15, 2023
1 parent c835fae commit a37376e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Data/Algorithm/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a37376e

Please sign in to comment.