quickcheck-state-machine-0.9.0: 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.

ansi-wl-pprint

ansiWlPretty :: Pretty Doc Source #

Pretty via ansi-wl-pprint library (with colors).

ansiWlExpr :: Expr -> Doc Source #

Pretty print Expr using ansi-wl-pprint.

ansiWlEditExpr :: Edit EditExpr -> Doc Source #

Pretty print Edit EditExpr using ansi-wl-pprint.

background

ansiWlBgPretty :: Pretty Doc Source #

Like ansiWlPretty but color the background.

ansiWlBgExpr :: Expr -> Doc Source #

Pretty print Expr using ansi-wl-pprint.

ansiWlBgEditExpr :: Edit EditExpr -> Doc Source #

Pretty print Edit EditExpr using ansi-wl-pprint.

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 "_,_"
`_,_`