Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- (<>) :: Semigroup a => a -> a -> a
- class Pretty a where
- pPrintPrec :: PrettyLevel -> Rational -> a -> Doc
- pPrint :: a -> Doc
- data Doc
- class Pretty a where
- pPrintPrec :: PrettyLevel -> Rational -> a -> Doc
- pPrint :: a -> Doc
- text :: String -> Doc
- brackets :: Doc -> Doc
- comma :: Doc
- hcat :: [Doc] -> Doc
- nest :: Int -> Doc -> Doc
- punctuate :: Doc -> [Doc] -> [Doc]
- fsep :: [Doc] -> Doc
- prettyShow :: Pretty a => a -> String
- data Associativity
- type Precedence = forall a. Num a => a
- class HasFixity x where
- precedence :: x -> Precedence
- associativity :: x -> Associativity
- data Side
- testParen :: (Eq a, Ord a, Num a) => Side -> a -> a -> Associativity -> Bool
- assertEqual' :: (?loc :: CallStack, Eq a, Pretty a) => String -> a -> a -> Assertion
- testEquals :: String -> ExpQ
- leafPrec :: Num a => a
- boolPrec :: Num a => a
- notPrec :: Num a => a
- atomPrec :: Num a => a
- andPrec :: Num a => a
- orPrec :: Num a => a
- impPrec :: Num a => a
- iffPrec :: Num a => a
- quantPrec :: Num a => a
- eqPrec :: Num a => a
- pAppPrec :: Num a => a
Documentation
(<>) :: Semigroup a => a -> a -> a infixr 6 #
An associative operation.
>>>
[1,2,3] <> [4,5,6]
[1,2,3,4,5,6]
Pretty printing class. The precedence level is used in a similar way as in
the Show
class. Minimal complete definition is either pPrintPrec
or
pPrint
.
pPrintPrec :: PrettyLevel -> Rational -> a -> Doc #
Instances
The abstract type of documents. A Doc represents a set of layouts. A Doc with no occurrences of Union or NoDoc represents just one layout.
Pretty printing class. The precedence level is used in a similar way as in
the Show
class. Minimal complete definition is either pPrintPrec
or
pPrint
.
pPrintPrec :: PrettyLevel -> Rational -> a -> Doc #
Instances
Nest (or indent) a document by a given number of positions
(which may also be negative). nest
satisfies the laws:
nest
0 x = xnest
k (nest
k' x) =nest
(k+k') xnest
k (x<>
y) =nest
k x<>
nest
k ynest
k (x$$
y) =nest
k x$$
nest
k ynest
kempty
=empty
x
, if<>
nest
k y = x<>
yx
non-empty
The side condition on the last law is needed because
empty
is a left identity for <>
.
punctuate :: Doc -> [Doc] -> [Doc] #
punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]
prettyShow :: Pretty a => a -> String #
Pretty print a value with the prettyNormal
level.
data Associativity Source #
Instances
Show Associativity Source # | |
Defined in Data.Logic.ATP.Pretty showsPrec :: Int -> Associativity -> ShowS # show :: Associativity -> String # showList :: [Associativity] -> ShowS # |
type Precedence = forall a. Num a => a Source #
Use the same precedence type as the pretty package
class HasFixity x where Source #
A class to extract the fixity of a formula so they can be properly parenthesized.
The Haskell FixityDirection type is concerned with how to interpret
a formula formatted in a certain way, but here we are concerned
with how to format a formula given its interpretation. As such,
one case the Haskell type does not capture is whether the operator
follows the associative law, so we can omit parentheses in an
expression such as a & b & c
. Hopefully, we can generate
formulas so that an associative operator with left associative
fixity direction appears as (a+b)+c rather than a+(b+c).
Nothing
precedence :: x -> Precedence Source #
associativity :: x -> Associativity Source #
Instances
What side of the parent formula are we rendering?
testParen :: (Eq a, Ord a, Num a) => Side -> a -> a -> Associativity -> Bool Source #
Decide whether to parenthesize based on which side of the parent binary operator we are rendering, the parent operator's precedence, and the precedence and associativity of the operator we are rendering. testParen :: Side -> Precedence -> Precedence -> Associativity -> Bool
:: (?loc :: CallStack, Eq a, Pretty a) | |
=> String | The message prefix |
-> a | The expected value |
-> a | The actual value |
-> Assertion |
Version of assertEqual that uses the pretty printer instead of show.
testEquals :: String -> ExpQ Source #
Orphan instances
Pretty a => Pretty (Set a) Source # | |
pPrintPrec :: PrettyLevel -> Rational -> Set a -> Doc # pPrintList :: PrettyLevel -> [Set a] -> Doc # | |
(Pretty v, Pretty term) => Pretty (Map v term) Source # | |
pPrintPrec :: PrettyLevel -> Rational -> Map v term -> Doc # pPrintList :: PrettyLevel -> [Map v term] -> Doc # |