HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleboxes-0.1.5Haskell98

Text.PrettyPrint.Boxes

A pretty-printing library for laying out text in two dimensions, using a simple box model.

Contents
  1. Constructing boxes
  2. Layout of boxes
  3. Alignment
  4. Inspecting boxes
  5. Rendering boxes
Synopsis
  • Packageboxes-0.1.5
  • Exports35
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBoxes.hs

Constructing boxes

datadata Box

The basic data type. A box has a specified size and some sort of contents.

Instances2Show, IsString
  • Show BoxDefined in boxes-0.1.5 · Text.PrettyPrint.Boxes
  • IsString BoxDefined in boxes-0.1.5 · Text.PrettyPrint.Boxes

    Convenient ability to use bare string literals as boxes.

valuenullBox :: Box

The null box, which has no content and no size. It is quite useless.

valueemptyBox :: Int -> Int -> Box

emptyBox r c is an empty box with r rows and c columns. Useful for effecting more fine-grained positioning of other boxes, by inserting empty boxes of the desired size in between them.

valuepara :: Alignment -> Int -> String -> Box

para algn w t is a box of width w, containing text t, aligned according to algn, flowed to fit within the given width.

valuecolumns :: Alignment -> Int -> Int -> String -> [Box]

columns w h t is a list of boxes, each of width w and height at most h, containing text t flowed into as many columns as necessary.

Layout of boxes

value(<>) :: Box -> Box -> Box

Paste two boxes together horizontally, using a default (top) alignment.

value(<+>) :: Box -> Box -> Box

Paste two boxes together horizontally with a single intervening column of space, using a default (top) alignment.

value(//) :: Box -> Box -> Box

Paste two boxes together vertically, using a default (left) alignment.

value(/+/) :: Box -> Box -> Box

Paste two boxes together vertically with a single intervening row of space, using a default (left) alignment.

Alignment

datadata Alignment

Data type for specifying the alignment of boxes.

Instances3Eq, Read, Show

Align boxes centered, but biased to the right/bottom in case of unequal parities.

valuemoveLeft :: Int -> Box -> Box

Move a box left by putting it in a larger box with extra columns, aligned left. Note that the name of this function is something of a white lie, as this will only result in the box being moved left by the specified amount if it is already in a larger right-aligned context.

valuemoveUp :: Int -> Box -> Box

Move a box "up" by putting it in a larger box with extra rows, aligned to the top. See the disclaimer for moveLeft.

valuemoveDown :: Int -> Box -> Box

Move a box down by putting it in a larger box with extra rows, aligned to the bottom. See the disclaimer for moveLeft.

valuealignHoriz :: Alignment -> Int -> Box -> Box

alignHoriz algn n bx creates a box of width n, with the contents and height of bx, horizontally aligned according to algn.

valuealignVert :: Alignment -> Int -> Box -> Box

alignVert algn n bx creates a box of height n, with the contents and width of bx, vertically aligned according to algn.

Inspecting boxes

Rendering boxes