Stability | experimental |
---|---|
Maintainer | conal@conal.net |
Pretty class with precedence
- class Pretty a => PrettyPrec a where
- prettyPrec :: Int -> a -> Doc
- showsPretty :: Pretty a => Int -> a -> ShowS
- showsPretty' :: Pretty a => Float -> Int -> Int -> a -> ShowS
- showsPrettyPrec :: PrettyPrec a => Int -> a -> ShowS
- showsPrettyPrec' :: PrettyPrec a => Float -> Int -> Int -> a -> ShowS
Documentation
class Pretty a => PrettyPrec a whereSource
Pretty printing with precedence. A cross between Show
and Pretty
.
The prettyPrec
method defaults to discarding the context precedence
and invoking pretty
. The reason PrettyPrec
derives from Pretty is
that so that this default is possible.
To make a Show
instance for a PrettyPrec
instance Foo
, define
instance Show Foo where showsPrec p e = showsPrec p (prettyPrec p e)
prettyPrec :: Int -> a -> DocSource
PrettyPrec Bool | |
PrettyPrec Char | |
PrettyPrec Double | |
PrettyPrec Float | |
PrettyPrec Int | |
PrettyPrec Integer | |
PrettyPrec () | |
PrettyPrec Doc | |
PrettyPrec Expr | |
Pretty a => PrettyPrec [a] | |
Integral a => PrettyPrec (Ratio a) | |
PrettyPrec a => PrettyPrec (Maybe a) | |
PrettyPrec (Type t) | |
PrettyPrec (E a) | |
HasExpr a => PrettyPrec (V a) | |
(Pretty a, Pretty b) => PrettyPrec (a, b) | |
(IsNat n, IsScalar a, Pretty a) => PrettyPrec (Vec n a) | |
(HasExpr a, HasExprU f) => PrettyPrec (Glom f a) | |
(Pretty a, Pretty b, Pretty c) => PrettyPrec (a, b, c) |
Show
helpers
showsPretty :: Pretty a => Int -> a -> ShowSSource
Convenient definition for showsPrec
in a Show
instance. Uses
ribbon fraction of 0.9 and width of 80. To set these values, use
showsPretty'
instead. If you want to take precedence into account,
use showsPrettyPrec
instead.
showsPretty' :: Pretty a => Float -> Int -> Int -> a -> ShowSSource
Convenient definition for showsPrec
in a Show
instance.
Arguments are ribbon fraction and line width. To get my defaults, use
showsPretty
instead. Ignores precedence, which Pretty
doesn't
understand. If you have a PrettyPrec
instance, you can use
showsPrettyPrec
instead.
showsPrettyPrec :: PrettyPrec a => Int -> a -> ShowSSource
Convenient definition for showsPrec
in a Show
instance. Uses
ribbon fraction of 0.9 and width of 80. To set these values, use
showsPrettyPrec'
instead. See also showsPretty
.
showsPrettyPrec' :: PrettyPrec a => Float -> Int -> Int -> a -> ShowSSource