pretty-diff-0.4.0.3: Pretty printing a diff of two values.

Safe HaskellSafe
LanguageHaskell2010

Pretty.Diff

Contents

Description

Printing nice and simple diffs of two values.

import qualified Pretty.Diff as Diff
import Data.Default (def)

Diff.pretty def "1234" "_23"

Will create a string that looks like this:

 ▼ ▼
"1234"
╷
│
╵
"_23"
 ▲
Synopsis

Configuration

data Config Source #

Configuration for pretty.

Constructors

Config 

Fields

  • separatorText :: Maybe Text

    Text that gets displayed inbetween the diffed values

    Diff.pretty def { Diff.separatorText = "differing" } "1234" "_23"
    

    Will create a string that looks like this:

     ▼ ▼
    "1234"
    ╷
    │ differing
    ╵
    "_23"
     ▲
    
  • wrapping :: Wrapping

    Wrapping text to multiple lines if they are longer than the provided length. This is useful in combination with terminal-size.

    Diff.pretty def { Diff.wrapping = Diff.Wrap 6 } "0900000000" "9000000000"
    

    Will create a string that looks like this:

     ▼
    "09000
    00000"
    ╷
    │
    ╵
    "90000
    00000"
        ▲
    
  • multilineContext :: MultilineContext

    Only used if text passed in is multiline. Options are full or a some surrounding number of lines

Instances
Default Config Source # 
Instance details

Defined in Pretty.Diff

Methods

def :: Config #

data Wrapping Source #

Define whether or not to wrap the diffing lines.

Constructors

Wrap Int 
NoWrap 

data MultilineContext Source #

Define how much context surrounding diffs you'd like to show.

pretty printing

pretty :: Config -> Text -> Text -> Text Source #

Printing a full diff of both values separated by some pipes.

above :: Wrapping -> MultilineContext -> Text -> Text -> Text Source #

Printing The first value and the diff indicator above.

 Diff.above Diff.NoWrap Diff.FullContext Diff.FullContext "1234" "_23"
 
 ▼ ▼
"1234"
 

below :: Wrapping -> MultilineContext -> Text -> Text -> Text Source #

Printing The second value and the diff indicator below.

 Diff.below Diff.NoWrap Diff.FullContext "1234" "_23"
 
"_23"
 ▲