1
1
mirror of https://github.com/github/semantic.git synced 2025-01-09 00:56:32 +03:00

Define a Show1 instance for Diff.

This commit is contained in:
Rob Rix 2017-09-09 12:34:47 +01:00
parent e7735ad131
commit 0df5175798

View File

@ -12,6 +12,7 @@ import Data.Union
import Patch
import Syntax
import Term
import Text.Show
-- | An annotated series of patches of terms.
newtype Diff syntax ann = Diff { unDiff :: DiffF syntax ann (Diff syntax ann) }
@ -113,6 +114,10 @@ instance (Eq1 f, Eq a) => Eq1 (DiffF f a) where
instance (Eq1 f, Eq a, Eq b) => Eq (DiffF f a b) where
(==) = eq1
instance Show1 f => Show1 (Diff f) where
liftShowsPrec sp sl = go where go d = showsUnaryWith (liftShowsPrec2 sp sl go (showListWith (go 0))) "Diff" d . unDiff
instance Show1 f => Show2 (DiffF f) where
liftShowsPrec2 spA slA spB slB d diff = case diff of
Copy ann r -> showsBinaryWith (liftShowsPrecBoth spA slA) (liftShowsPrec spB slB) "Copy" d ann r