patch icon indicating copy to clipboard operation
patch copied to clipboard

Should we have a class for diffing?

Open endgame opened this issue 2 years ago • 0 comments

From a discussion with a colleague, the following class emerged:

-- | Law: applyAlways (diff x y) x = y
class Patch p => Diff p where
  -- | @diff from to@ returns a patch which turns @from@ into @to@.
  diff :: PatchTarget p -> PatchTarget p -> p

It seems useful, even if we cannot guarantee that such a class exists for every patch type.

endgame avatar Jan 18 '23 05:01 endgame