Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Pretty doc = Pretty {}
- ppExpr :: Pretty doc -> Expr -> doc
- ppEditExpr :: Pretty doc -> Edit EditExpr -> doc
- ppEditExprCompact :: Pretty doc -> Edit EditExpr -> doc
- prettyPretty :: Pretty Doc
- prettyExpr :: Expr -> Doc
- prettyEditExpr :: Edit EditExpr -> Doc
- prettyEditExprCompact :: Edit EditExpr -> Doc
- ansiWlPretty :: Pretty (Doc AnsiStyle)
- ansiWlExpr :: Expr -> Doc AnsiStyle
- ansiWlEditExpr :: Edit EditExpr -> Doc AnsiStyle
- ansiWlEditExprCompact :: Edit EditExpr -> Doc AnsiStyle
- ansiWlBgPretty :: Pretty (Doc AnsiStyle)
- ansiWlBgExpr :: Expr -> Doc AnsiStyle
- ansiWlBgEditExpr :: Edit EditExpr -> Doc AnsiStyle
- ansiWlBgEditExprCompact :: Edit EditExpr -> Doc AnsiStyle
- escapeName :: String -> String
Explicit dictionary
Because we don't want to commit to single pretty printing library, we use explicit dictionary.
ppExpr :: Pretty doc -> Expr -> doc Source #
Pretty print an Expr
using explicit pretty-printing dictionary.
ppEditExprCompact :: Pretty doc -> Edit EditExpr -> doc Source #
Like ppEditExpr
but print unchanged parts only shallowly
pretty
prettyExpr :: Expr -> Doc Source #
Pretty print Expr
using pretty
.
>>>
prettyExpr $ Rec "ex" (Map.fromList [("[]", App "bar" [])])
ex {`[]` = bar}
prettyEditExprCompact :: Edit EditExpr -> Doc Source #
Compact prettyEditExpr
.
prettyprinter
ansiWlEditExprCompact :: Edit EditExpr -> Doc AnsiStyle Source #
Compact ansiWlEditExpr
background
ansiWlBgPretty :: Pretty (Doc AnsiStyle) Source #
Like ansiWlPretty
but color the background.
ansiWlBgEditExprCompact :: Edit EditExpr -> Doc AnsiStyle Source #
Compact ansiWlBgEditExpr
.
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 "_,_"
`_,_`