Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Generic pretty-printing of expression trees.
TODO:
- make the style configurable (so that we can print the same expression in different formats) (in Haskell98, we have to use the record instead of class trick for this?)
- corresponding parser?
Synopsis
- data Assoc
- data Bracket = Bracket !String !String
- type Separator = String
- data AppStyle
- data MixWord
- mixWords :: [MixWord] -> [ShowS] -> ShowS
- data Fixity
- fixityPrecedence :: Fixity -> Int
- class (Functor f, Foldable f) => Pretty f where
- pretty :: Pretty f => Mu f -> String
- prettyS :: Pretty f => Mu f -> ShowS
- prettyPrec :: Pretty f => Int -> Mu f -> ShowS
Documentation
Associativity
A pair of matching brackets, eg. Bracket "(" ")"
or Bracket "[|" "|]"
.
Application style
Haskell | eg. |
Algol !Bracket !Separator | eg. |
Mixfix style. Example:
[ Keyword "if" , Placeholder , keyword "then" , Placeholder , keyword "else" , Placeholder ]
Fixities. TODO: separate non-fixity stuff like style and words
Atom | eg. |
Application !AppStyle | eg. |
Prefix !Int | eg. |
Infix !Assoc !Int | eg. |
Postfix !Int | eg. |
Mixfix [MixWord] | eg. |
Custom !Int | for your custom rendering |
fixityPrecedence :: Fixity -> Int Source #
class (Functor f, Foldable f) => Pretty f where Source #
A class encoding fixity and rendering of nodes if the tree.
Minimum complete definition: fixity
, and showNode
or showsPrecNode
.
Unless you want some type of rendering not directly supported, you shouldn't specify showsPrecNode
.