diff --git a/src/Patch.hs b/src/Patch.hs index 9c212d11c..402783dbc 100644 --- a/src/Patch.hs +++ b/src/Patch.hs @@ -16,6 +16,7 @@ module Patch , patchType ) where +import Data.Align import Data.Functor.Listable import Data.These import Prologue @@ -90,3 +91,8 @@ instance Listable1 Patch where instance Listable a => Listable (Patch a) where tiers = tiers1 + +instance Crosswalk Patch where + crosswalk f (Replace a b) = alignWith (these Delete Insert Replace) (f a) (f b) + crosswalk f (Insert b) = Insert <$> f b + crosswalk f (Delete a) = Delete <$> f a