Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Pretty doc = Pretty {}
- ppExpr :: Pretty doc -> Expr -> doc
- ppEditExpr :: Pretty doc -> Edit EditExpr -> doc
- prettyPretty :: Pretty Doc
- prettyExpr :: Expr -> Doc
- prettyEditExpr :: Edit EditExpr -> Doc
- ansiWlPretty :: Pretty Doc
- ansiWlExpr :: Expr -> Doc
- ansiWlEditExpr :: Edit EditExpr -> Doc
- ansiWlBgPretty :: Pretty Doc
- ansiWlBgExpr :: Expr -> Doc
- ansiWlBgEditExpr :: Edit EditExpr -> Doc
- 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.
pretty
prettyExpr :: Expr -> Doc Source #
Pretty print Expr
using pretty
.
>>>
prettyExpr $ Rec "ex" (Map.fromList [("[]", App "bar" [])])
ex {`[]` = bar}
ansi-wl-pprint
background
ansiWlBgPretty :: Pretty Doc Source #
Like ansiWlPretty
but color the background.
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 "_,_"
`_,_`