quickcheck-state-machine-0.10.1: Test monadic programs using state machine based models
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.StateMachine.TreeDiff.Pretty

Description

Utilities to pretty print Expr and EditExpr

Synopsis

Explicit dictionary

data Pretty doc Source #

Because we don't want to commit to single pretty printing library, we use explicit dictionary.

Constructors

Pretty 

Fields

ppExpr :: Pretty doc -> Expr -> doc Source #

Pretty print an Expr using explicit pretty-printing dictionary.

ppEditExpr :: Pretty doc -> Edit EditExpr -> doc Source #

Pretty print an Edit EditExpr using explicit pretty-printing dictionary.

ppEditExprCompact :: Pretty doc -> Edit EditExpr -> doc Source #

Like ppEditExpr but print unchanged parts only shallowly

pretty

prettyPretty :: Pretty Doc Source #

Pretty via pretty library.

prettyExpr :: Expr -> Doc Source #

Pretty print Expr using pretty.

>>> prettyExpr $ Rec "ex" (Map.fromList [("[]", App "bar" [])])
ex {`[]` = bar}

prettyEditExpr :: Edit EditExpr -> Doc Source #

Pretty print Edit EditExpr using pretty.

prettyprinter

ansiWlPretty :: Pretty (Doc AnsiStyle) Source #

Pretty via prettyprinter library (with colors).

ansiWlExpr :: Expr -> Doc AnsiStyle Source #

Pretty print Expr using prettyprinter.

ansiWlEditExpr :: Edit EditExpr -> Doc AnsiStyle Source #

Pretty print Edit EditExpr using prettyprinter.

background

ansiWlBgPretty :: Pretty (Doc AnsiStyle) Source #

Like ansiWlPretty but color the background.

ansiWlBgExpr :: Expr -> Doc AnsiStyle Source #

Pretty print Expr using prettyprinter.

ansiWlBgEditExpr :: Edit EditExpr -> Doc AnsiStyle Source #

Pretty print Edit EditExpr using prettyprinter.

Utilities

escapeName :: String -> String Source #

Escape field or constructor name

>>> putStrLn $ escapeName "Foo"
Foo
>>> putStrLn $ escapeName "_×_"
_×_
>>> putStrLn $ escapeName "-3"
`-3`
>>> putStrLn $ escapeName "kebab-case"
kebab-case
>>> putStrLn $ escapeName "inner space"
`inner space`
>>> putStrLn $ escapeName $ show "looks like a string"
"looks like a string"
>>> putStrLn $ escapeName $ show "tricky" ++ "   "
`"tricky"   `
>>> putStrLn $ escapeName "[]"
`[]`
>>> putStrLn $ escapeName "_,_"
`_,_`