HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

  • Packagetree-diff-0.4.1
  • Exports17
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourcePretty.hs

Explicit dictionary

datadata Pretty doc

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

Constructors

pretty

valueprettyExpr :: Expr -> Doc

Pretty print Expr using pretty.

Example1 expression
prettyExpr $ Rec "ex" (OMap.fromList [("[]", App "bar" [])])ex {`[]` = bar}

prettyprinter

background

Utilities

Escape field or constructor name

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