portray-diff-0.1.0.1: Visualize the structural differences between two values.
Safe HaskellNone
LanguageHaskell2010

Data.Portray.Diff

Description

Typeclass for pretty-printed diffs between two instances of a type.

Derive it for arbitrary sum-of-products types as follows:

    data Foo = Foo Int | Bar Bool
      deriving Generic
      deriving (Portray, Diff) via Wrapped Generic Foo

If the type of the compared values has a custom Eq instance, the equality comparison used by the Generic derived Diff instance *will differ* from the custom one implemented for the type. It will only check to make sure that the representations of the two types are the same. If you still want the diff algorithm to look into the type, you will need to implement a custom Diff instance alongside the custom Eq instance. If you don't want the diff algorithm to look inside a type, and instead use the custom Eq instance, use:

    data Foo = ...
    instance Diff Foo where diff = diffAtom
Synopsis

Documentation

class Diff a where Source #

Minimal complete definition

Nothing

Methods

diff :: a -> a -> Maybe Portrayal Source #

Returns Nothing when equal; or a Portrayal showing the differences.

default diff :: (Generic a, GDiff a (Rep a)) => a -> a -> Maybe Portrayal Source #

Instances

Instances details
Diff Bool Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Bool -> Bool -> Maybe Portrayal Source #

Diff Char Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Char -> Char -> Maybe Portrayal Source #

Diff Double Source # 
Instance details

Defined in Data.Portray.Diff

Diff Float Source # 
Instance details

Defined in Data.Portray.Diff

Diff Int Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Int -> Int -> Maybe Portrayal Source #

Diff Int8 Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Int8 -> Int8 -> Maybe Portrayal Source #

Diff Int16 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Int32 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Int64 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Integer Source # 
Instance details

Defined in Data.Portray.Diff

Diff Word Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Word -> Word -> Maybe Portrayal Source #

Diff Word8 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Word16 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Word32 Source # 
Instance details

Defined in Data.Portray.Diff

Diff Word64 Source # 
Instance details

Defined in Data.Portray.Diff

Diff SomeTypeRep Source # 
Instance details

Defined in Data.Portray.Diff

Diff () Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: () -> () -> Maybe Portrayal Source #

Diff Assoc Source # 
Instance details

Defined in Data.Portray.Diff

Diff Infixity Source # 
Instance details

Defined in Data.Portray.Diff

Diff IdentKind Source # 
Instance details

Defined in Data.Portray.Diff

Diff Ident Source # 
Instance details

Defined in Data.Portray.Diff

Diff Portrayal Source # 
Instance details

Defined in Data.Portray.Diff

Diff Text Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Text -> Text -> Maybe Portrayal Source #

(Portray a, Diff a) => Diff [a] Source #

Diff on lists does a diff on the zip, plus special handling for the mismatched lengths.

Instance details

Defined in Data.Portray.Diff

Methods

diff :: [a] -> [a] -> Maybe Portrayal Source #

(Portray a, Diff a) => Diff (Maybe a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Maybe a -> Maybe a -> Maybe Portrayal Source #

(Eq a, Portray a) => Diff (Ratio a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Ratio a -> Ratio a -> Maybe Portrayal Source #

Diff a => Diff (Identity a) Source # 
Instance details

Defined in Data.Portray.Diff

(Portray a, Diff a) => Diff (NonEmpty a) Source # 
Instance details

Defined in Data.Portray.Diff

(Portray a, Diff a) => Diff (IntMap a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: IntMap a -> IntMap a -> Maybe Portrayal Source #

(Portray a, Diff a) => Diff (Seq a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Seq a -> Seq a -> Maybe Portrayal Source #

(Portray a, Diff a) => Diff (PortrayalF a) Source # 
Instance details

Defined in Data.Portray.Diff

Diff a => Diff (FactorPortrayal a) Source # 
Instance details

Defined in Data.Portray.Diff

(forall a. (Portray a, Diff a) => Diff (f a), forall a. Portray a => Portray (f a)) => Diff (Fix f) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Fix f -> Fix f -> Maybe Portrayal Source #

(Eq a, Portray a) => Diff (DiffAtom a) Source # 
Instance details

Defined in Data.Portray.Diff

(Portray a, Portray b, Diff a, Diff b) => Diff (Either a b) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Either a b -> Either a b -> Maybe Portrayal Source #

Diff (TypeRep a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: TypeRep a -> TypeRep a -> Maybe Portrayal Source #

(Portray a, Portray b, Diff a, Diff b) => Diff (a, b) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: (a, b) -> (a, b) -> Maybe Portrayal Source #

(IsList a, Portray (Item a), Diff (Item a)) => Diff (Wrapped IsList a) Source #

Diff as if the type were a list, via toList.

Instance details

Defined in Data.Portray.Diff

(Generic a, GDiff a (Rep a)) => Diff (Wrapped Generic a) Source # 
Instance details

Defined in Data.Portray.Diff

(Portray a, Portray b, Portray c, Diff a, Diff b, Diff c) => Diff (a, b, c) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: (a, b, c) -> (a, b, c) -> Maybe Portrayal Source #

Diff a => Diff (Const a b) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: Const a b -> Const a b -> Maybe Portrayal Source #

Diff (a :~: b) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: (a :~: b) -> (a :~: b) -> Maybe Portrayal Source #

(Portray a, Portray b, Portray c, Portray d, Diff a, Diff b, Diff c, Diff d) => Diff (a, b, c, d) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: (a, b, c, d) -> (a, b, c, d) -> Maybe Portrayal Source #

(Portray a, Foldable f, Diff a) => Diff (Wrapped1 Foldable f a) Source #

Diff as if the type were a list, via toList.

Instance details

Defined in Data.Portray.Diff

(Portray a, Portray b, Portray c, Portray d, Portray e, Diff a, Diff b, Diff c, Diff d, Diff e) => Diff (a, b, c, d, e) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

diff :: (a, b, c, d, e) -> (a, b, c, d, e) -> Maybe Portrayal Source #

diffAtom :: (Eq a, Portray a) => a -> a -> Maybe Portrayal Source #

Diff on an atomic type, just by using the Eq and Portray instances without using any internal structure of the type.

newtype DiffAtom a Source #

Constructors

DiffAtom a 

Instances

Instances details
Eq a => Eq (DiffAtom a) Source # 
Instance details

Defined in Data.Portray.Diff

Methods

(==) :: DiffAtom a -> DiffAtom a -> Bool #

(/=) :: DiffAtom a -> DiffAtom a -> Bool #

Portray a => Portray (DiffAtom a) Source # 
Instance details

Defined in Data.Portray.Diff

(Eq a, Portray a) => Diff (DiffAtom a) Source # 
Instance details

Defined in Data.Portray.Diff