HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleboxes-0.1.5Haskell98

Text.PrettyPrint.Boxes

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

  • 2 types
  • 33 values
  • Packageboxes-0.1.5
  • Exports35
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBoxes.hs

Constructing boxes

7 declarations
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.

valuechar :: Char -> Box
#

A 1x1 box containing a single character.

valuetext :: String -> Box
#

A (1 x len) box containing a string of length len.

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

10 declarations
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.

valuehsep :: Foldable f => Int -> Alignment -> f Box -> Box
#

hsep sep a bs lays out bs horizontally with alignment a, with sep amount of space in between each.

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.

valuevsep :: Foldable f => Int -> Alignment -> f Box -> Box
#

vsep sep a bs lays out bs vertically with alignment a, with sep amount of space in between each.

Alignment

14 declarations
datadata Alignment
#

Data type for specifying the alignment of boxes.

Instances3Eq, Read, Show
valuecenter1 :: Alignment
#

Align boxes centered, but biased to the left/top in case of unequal parities.

valuecenter2 :: Alignment
#

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.

valuemoveRight :: Int -> Box -> Box
#

Move a box right by putting it in a larger box with extra columns, aligned right. See the disclaimer for moveLeft.

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.

valuealign :: Alignment -> Alignment -> Int -> Int -> Box -> Box
#

align ah av r c bx creates an r x c box with the contents of bx, aligned horizontally according to ah and vertically according to av.

Inspecting boxes

2 declarations

Rendering boxes

2 declarations
valuerender :: Box -> String
#

Render a Box as a String, suitable for writing to the screen or a file.

valueprintBox :: Box -> IO ()
#

A convenience function for rendering a box to stdout.