License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Swarm.Pretty
Description
Common pretty-printing infrastructure for the Swarm project.
Synopsis
- class PrettyPrec a where
- prettyPrec :: Int -> a -> Doc ann
- ppr :: PrettyPrec a => a -> Doc ann
- prettyText :: PrettyPrec a => a -> Text
- prettyTextWidth :: PrettyPrec a => a -> Int -> Text
- prettyTextLine :: PrettyPrec a => a -> Text
- prettyString :: PrettyPrec a => a -> String
- docToText :: Doc a -> Text
- docToTextWidth :: Doc a -> Int -> Text
- docToString :: Doc a -> String
- pparens :: Bool -> Doc ann -> Doc ann
- pparens' :: Bool -> Doc ann -> Doc ann
- encloseWithIndent :: Int -> Doc ann -> Doc ann -> Doc ann -> Doc ann
- bquote :: Doc ann -> Doc ann
- prettyShowLow :: Show a => a -> Doc ann
- reportBug :: Doc ann
- data BulletList i = BulletList {
- bulletListHeader :: forall a. Doc a
- bulletListItems :: [i]
- prettyBinding :: (PrettyPrec a, PrettyPrec b) => (a, b) -> Doc ann
- prettyEquality :: (PrettyPrec a, PrettyPrec b) => (a, Maybe b) -> Doc ann
- data Wildcard = Wildcard
The PrettyPrec
class
class PrettyPrec a where Source #
Type class for things that can be pretty-printed, given a precedence level of their context.
Methods
prettyPrec :: Int -> a -> Doc ann Source #
Instances
Running pretty-printers
ppr :: PrettyPrec a => a -> Doc ann Source #
Pretty-print a thing, with a context precedence level of zero.
prettyText :: PrettyPrec a => a -> Text Source #
Pretty-print something and render it as Text
.
prettyTextWidth :: PrettyPrec a => a -> Int -> Text Source #
Pretty-print something and render it as Text
.
This is different than prettyText
in the sense that it also
consumes number of allowed characters in a line before introducing
a line break.
prettyTextLine :: PrettyPrec a => a -> Text Source #
Pretty-print something and render it as (preferably) one line Text
.
prettyString :: PrettyPrec a => a -> String Source #
Pretty-print something and render it as a String
.
docToTextWidth :: Doc a -> Int -> Text Source #
Render a pretty-printed document as Text
.
This function consumes number of allowed characters in a
line before introducing a line break. In other words, it
expects the space of the layouter to be supplied.
docToString :: Doc a -> String Source #
Render a pretty-printed document as a String
.
Pretty-printing utilities
pparens :: Bool -> Doc ann -> Doc ann Source #
Optionally surround a document with parentheses depending on the
Bool
argument and if it does not fit on line, indent the lines,
with the parens on separate lines.
pparens' :: Bool -> Doc ann -> Doc ann Source #
Same as pparens but does not indent the lines. Only encloses the document with parantheses.
prettyShowLow :: Show a => a -> Doc ann Source #
Turn a Show
instance into a Doc
, lowercasing it in the
process.
data BulletList i Source #
Constructors
BulletList | |
Fields
|
Instances
PrettyPrec i => PrettyPrec (BulletList i) Source # | |
Defined in Swarm.Pretty Methods prettyPrec :: Int -> BulletList i -> Doc ann Source # |
prettyBinding :: (PrettyPrec a, PrettyPrec b) => (a, b) -> Doc ann Source #
prettyEquality :: (PrettyPrec a, PrettyPrec b) => (a, Maybe b) -> Doc ann Source #
We can use the Wildcard
value to replace unification variables
when we don't care about them, e.g. to print out the shape of a
type like (_ -> _) * _
Constructors
Wildcard |