Safe Haskell | None |
---|---|
Language | GHC2021 |
Codec.CBOR.Cuddle.Pretty.Columnar
Description
This module provides some utility functions to help with aligning pretty printed values by column.
Synopsis
- data CellAlign
- newtype Row ann = Row {}
- data Cell ann = Cell {}
- cellL :: Pretty a => a -> Cell ann
- cellR :: Pretty a => a -> Cell ann
- emptyCell :: Cell ann
- isEmptyCell :: Cell ann -> Bool
- newtype Columnar ann = Columnar {}
- prettyColumnar :: Columnar ann -> Doc ann
- columnarListing :: Doc ann -> Doc ann -> Doc ann -> Columnar ann -> Doc ann
- columnarSepBy :: Doc ann -> Columnar ann -> Doc ann
- singletonRow :: Doc ann -> Row ann
Documentation
Constructors
LeftAlign | |
RightAlign |
cellL :: Pretty a => a -> Cell ann Source #
Creates a cell by pretty printing the input value and then left-aligning
the resulting Doc
within the table.
cellR :: Pretty a => a -> Cell ann Source #
Creates a cell by pretty printing the input value and then right-aligning
the resulting Doc
within the table.
isEmptyCell :: Cell ann -> Bool Source #
Checks whether the cell contains a Doc
with a rendered width of zero.
columnarListing :: Doc ann -> Doc ann -> Doc ann -> Columnar ann -> Doc ann Source #
Pretty prints the Columnar
so that the rows are separated by by the
separator Doc
provided as the third argument and then everything is
enclosed within the left and right brackets provided as the first and second
argument accordingly. The brackets will be aligned with the separators in the
first column, e.g.
```
[ foo
, bar
]
```
columnarSepBy :: Doc ann -> Columnar ann -> Doc ann Source #
Pretty prints the Columnar
so that every line after the first has a
separator prepended to it. This can be useful when you want to align the rows,
but the separator would cause all the other rows after the first to be shifted
right by one. The way you use this is you reduce the indentation on the
following lines by the width of the separator.
```
foo = x
, y
, z
```
singletonRow :: Doc ann -> Row ann Source #
A row with a single left-aligned document