From 4ef3604a651e62e217da205129298d034e541f48 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 11 May 2017 14:19:34 -0400 Subject: [PATCH] Revert "Revert "Define a Crosswalk instance for Patch."" This reverts commit 20d96850fa7ee2b1ad3c949b128186eaa8f22f6b. --- src/Patch.hs | 6 ++++++ 1 file changed, 6 insertions(+) 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