cuddle-0.5.0.0: CDDL Generator and test utilities
Safe HaskellNone
LanguageGHC2021

Codec.CBOR.Cuddle.Pretty.Columnar

Description

This module provides some utility functions to help with aligning pretty printed values by column.

Synopsis

Documentation

newtype Row ann Source #

A row within the table.

Constructors

Row 

Fields

data Cell ann Source #

Constructors

Cell 

Fields

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.

emptyCell :: Cell ann Source #

A cell that takes up a cell but has no content.

isEmptyCell :: Cell ann -> Bool Source #

Checks whether the cell contains a Doc with a rendered width of zero.

newtype Columnar ann Source #

Columnar is a two-dimensional table of Docs. When rendered, the cells within each row will be aligned with the cells of every other row in the same column.

Constructors

Columnar 

Fields

prettyColumnar :: Columnar ann -> Doc ann Source #

Pretty print the Columnar as a table.

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