sifflet-2.3.0: Simple, visual, functional language for learning about recursion.

Safe HaskellSafe
LanguageHaskell2010

Text.Sifflet.Pretty

Synopsis

Documentation

class Pretty a where Source

The class of types that can be pretty-printed. (Unfortunately this is not very useful, because and Expr can be pretty Haskell or pretty Python or pretty Scheme, leading to overlapping instance declarations.)

pretty x is a pretty String representation of x. prettyList prefix infix postfix xs is a pretty String representation of the list xs, with prefix, infix, and postfix specifying the punctuation. For example, if (pretty x) => "x", then prettyList "[" ", " "]" [x, x, x] => "[x, x, x]".

Minimal complete implementation: define pretty.

Minimal complete definition

pretty

Methods

pretty :: a -> String Source

prettyList :: String -> String -> String -> [a] -> String Source

indentLine :: Int -> String -> String Source

Indent a single line n spaces.

sepLines :: [String] -> String Source

sepLines is like unlines, but omits the n at the end of the last line.

sepLines2 :: [String] -> String Source

sepLines2 is like sepLines, but adds an extra n between each pair of lines so they are "double spaced."

sepComma :: [String] -> String Source

Separate strings by commas and nothing else (",")

sepCommaSp :: [String] -> String Source

Separate strings by commas and spaces (", ")

sepSpace :: [String] -> String Source

Separate strings by just spaces (" ")