Module Boxes

Summary of exported operations:

top :: Alignment   
Top alignment.
bottom :: Alignment   
Botton alignment.
left :: Alignment   
Left alignment.
right :: Alignment   
Right alignment.
center1 :: Alignment   
Center-top/left alignment.
center2 :: Alignment   
Center-bottom/right alignment.
nullBox :: Box   
Creates an empty 0x0 box.
emptyBox :: Int -> Int -> Box   
Creates an empty box with the given size.
char :: Char -> Box   
Creates a 1x1 box from a character.
text :: String -> Box   
Creates a Nx1 box from a string of length N.
(<>) :: Box -> Box -> Box   
Combine two boxes horizontally with top alignment.
(<+>) :: Box -> Box -> Box   
Combine two boxes horizontally with top alignment and leave one column between the boxes.
(//) :: Box -> Box -> Box   
Combine two boxes vertically with left alignment.
(/+/) :: Box -> Box -> Box   
Combine two boxes vertically with left alignment and leave one row between the boxes.
hcat :: Alignment -> [Box] -> Box   
Combines a list of boxes horizontally with the given alignment.
hsep :: Int -> Alignment -> [Box] -> Box   
Combines a list of boxes horizontally with the given alignment and space between all boxes.
vcat :: Alignment -> [Box] -> Box   
Combines a list of boxes vertically with the given alignment.
sumMax :: (a -> Int) -> b -> (a -> b) -> [a] -> (Int,b)   
Calculate sum and maximum of a list.
vsep :: Int -> Alignment -> [Box] -> Box   
Combines a list of boxes vertically with the given alignment and space between all boxes.
punctuateH :: Alignment -> Box -> [Box] -> Box   
Combine a list of boxes horizontally with the given alignment and a copy of the given box between each two boxes.
punctuateV :: Alignment -> Box -> [Box] -> Box   
Combine a list of boxes vertically with the given alignment and a copy of the given box between each two boxes.
paraFill :: Alignment -> Int -> String -> Box   
mkParaBoxFill :: Alignment -> Int -> Int -> [String] -> Box   
para :: Alignment -> Int -> String -> Box   
Create a box of the given width, containing a specific text.
columns :: Alignment -> Int -> Int -> String -> [Box]   
Creates a list of boxes, each of a specific width and height.
mkParaBox :: Alignment -> Int -> [String] -> Box   
Creates a box of a specific height that contains a list of texts.
flow :: Int -> String -> [String]   
Flows a given text into a given width, creating many different strings.
emptyPara :: Int -> Para   
Creates an empty paragraph of the given width.
getLines :: Para -> [String]   
Returns all lines of a paragraph.
mkLine :: [Word] -> Line   
Creates a line from a list of words.
startLine :: Word -> Line   
Creates a line from a single word.
mkWord :: String -> Word   
Creates a word from a string.
addWordP :: Para -> Word -> Para   
Adds a word to a paragraph.
addWordL :: Word -> Line -> Line   
Adds a word to a line.
wordFits :: Int -> Word -> Line -> Bool   
Checks whether a word fits into a line.
alignHoriz :: Alignment -> Int -> Box -> Box   
Creates a box of a specific width containing another box's content aligned according to the given alignment.
alignVert :: Alignment -> Int -> Box -> Box   
Creates a box of a specific height containing another box's content aligned according to the given alignment.
align :: Alignment -> Alignment -> Int -> Int -> Box -> Box   
Creates a box of a specific width and height containing another box's content aligned according to the given alignment.
moveUp :: Int -> Box -> Box   
Move a box up by putting it into a larger box with extra rows, aligned to the top.
moveDown :: Int -> Box -> Box   
Move a box down by putting it into a larger box with extra rows, aligned to the bottom.
moveLeft :: Int -> Box -> Box   
Move a box left by putting it into a larger box with extra columns, aligned to the left.
moveRight :: Int -> Box -> Box   
Move a box right by putting it into a larger box with extra columns, aligned to the right.
table :: [[String]] -> [Int] -> Box   
Create a table from a list of rows.
render :: Box -> String   
Render a box to a string.
takeP :: a -> Int -> [a] -> [a]   
Takes a number of elements from a list.
fReverse :: ([a],b) -> ([a],b)   
(***) :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)   
takePA :: Alignment -> a -> Int -> [a] -> [a]   
blanks :: Int -> String   
Generates a string of spaces.
renderBox :: Box -> [String]   
Render a box as a list of lines.
renderBoxWithRows :: Int -> Box -> [String]   
Render a box as a list of lines with a given number of rows.
renderBoxWithCols :: Int -> Box -> [String]   
Render a box as a list of lines with a given number of columns.
resizeBox :: Int -> Int -> [String] -> [String]   
Resize a rendered list of lines.
resizeBoxAligned :: Int -> Int -> Alignment -> Alignment -> [String] -> [String]   
Resize a rendered list of lines using the given alignments.
printBox :: Box -> IO ()   
Print a box to stdout.
chunksOf :: Int -> [a] -> [[a]]   
sum :: [Int] -> Int   

Exported datatypes:


Box

A box has a defined size (rows x cols) and some content.

Constructors:

  • Box :: Int -> Int -> Content -> Box

    Fields:

    • rows :: Int
    • cols :: Int
    • content :: Content

Alignment

Box alignment.

Constructors:

  • AlignFirst :: Alignment : align at top/left
  • AlignCenter1 :: Alignment : centered, but biased to top/left
  • AlignCenter2 :: Alignment : centered, but biased to bottom/right
  • AlignLast :: Alignment : align at bottom/right

Content

Content of a box.

Constructors:

  • Blank :: Content : no content
  • Text :: String -> Content : a string
  • Row :: [Box] -> Content : a row of boxes
  • Col :: [Box] -> Content : a column of boxes
  • SubBox :: Alignment -> Alignment -> Box -> Content : an aligned subbox

Para

A paragraph has a width and some content.

Constructors:


ParaContent

A paragraph's content is a block consisting of many full lines and a single last line.

Constructors:

  • Block :: [Line] -> Line -> ParaContent

    Fields:


Line

A line has a length and a list of words.

Constructors:

  • Line :: Int -> [Word] -> Line

    Fields:

    • lLen :: Int
    • getWords :: [Word]

Word

A word has a length and its contents.

Constructors:

  • Word :: Int -> String -> Word

    Fields:

    • wLen :: Int
    • getWord :: String

Exported operations:

top :: Alignment   

Top alignment.

Further infos:
  • solution complete, i.e., able to compute all solutions

bottom :: Alignment   

Botton alignment.

Further infos:
  • solution complete, i.e., able to compute all solutions

left :: Alignment   

Left alignment.

Further infos:
  • solution complete, i.e., able to compute all solutions

center1 :: Alignment   

Center-top/left alignment.

Further infos:
  • solution complete, i.e., able to compute all solutions

center2 :: Alignment   

Center-bottom/right alignment.

Further infos:
  • solution complete, i.e., able to compute all solutions

nullBox :: Box   

Creates an empty 0x0 box.

Further infos:
  • solution complete, i.e., able to compute all solutions

emptyBox :: Int -> Int -> Box   

Creates an empty box with the given size.

Example call:
(emptyBox r c)
Parameters:
  • r : number of rows
  • c : number of columns
Further infos:
  • solution complete, i.e., able to compute all solutions

char :: Char -> Box   

Creates a 1x1 box from a character.

Further infos:
  • solution complete, i.e., able to compute all solutions

text :: String -> Box   

Creates a Nx1 box from a string of length N.

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

Combine two boxes horizontally with top alignment.

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

Combine two boxes horizontally with top alignment and leave one column between the boxes.

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

Combine two boxes vertically with left alignment.

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

Combine two boxes vertically with left alignment and leave one row between the boxes.

hcat :: Alignment -> [Box] -> Box   

Combines a list of boxes horizontally with the given alignment.

hsep :: Int -> Alignment -> [Box] -> Box   

Combines a list of boxes horizontally with the given alignment and space between all boxes.

vcat :: Alignment -> [Box] -> Box   

Combines a list of boxes vertically with the given alignment.

sumMax :: (a -> Int) -> b -> (a -> b) -> [a] -> (Int,b)   

Calculate sum and maximum of a list.

vsep :: Int -> Alignment -> [Box] -> Box   

Combines a list of boxes vertically with the given alignment and space between all boxes.

punctuateH :: Alignment -> Box -> [Box] -> Box   

Combine a list of boxes horizontally with the given alignment and a copy of the given box between each two boxes.

punctuateV :: Alignment -> Box -> [Box] -> Box   

Combine a list of boxes vertically with the given alignment and a copy of the given box between each two boxes.

paraFill :: Alignment -> Int -> String -> Box   

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

para :: Alignment -> Int -> String -> Box   

Create a box of the given width, containing a specific text. The text is flowed to fit the width according to the alignment.

Example call:
(para a w c)
Parameters:
  • a : the alignment of the text
  • w : the box's width
  • c : the box's contents

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

Creates a list of boxes, each of a specific width and height. The given text is flowed into as many columns as necessary according to the given alignment.

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

Creates a box of a specific height that contains a list of texts.

flow :: Int -> String -> [String]   

Flows a given text into a given width, creating many different strings.

emptyPara :: Int -> Para   

Creates an empty paragraph of the given width.

Further infos:
  • solution complete, i.e., able to compute all solutions

getLines :: Para -> [String]   

Returns all lines of a paragraph.

mkLine :: [Word] -> Line   

Creates a line from a list of words.

startLine :: Word -> Line   

Creates a line from a single word.

mkWord :: String -> Word   

Creates a word from a string.

addWordP :: Para -> Word -> Para   

Adds a word to a paragraph.

addWordL :: Word -> Line -> Line   

Adds a word to a line.

wordFits :: Int -> Word -> Line -> Bool   

Checks whether a word fits into a line.

alignHoriz :: Alignment -> Int -> Box -> Box   

Creates a box of a specific width containing another box's content aligned according to the given alignment.

alignVert :: Alignment -> Int -> Box -> Box   

Creates a box of a specific height containing another box's content aligned according to the given alignment.

align :: Alignment -> Alignment -> Int -> Int -> Box -> Box   

Creates a box of a specific width and height containing another box's content aligned according to the given alignment.

moveUp :: Int -> Box -> Box   

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

moveDown :: Int -> Box -> Box   

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

moveLeft :: Int -> Box -> Box   

Move a box left by putting it into a larger box with extra columns, aligned to the left. Note that this will only move the box by the specified amount if it is already in a larger right-aligned box.

moveRight :: Int -> Box -> Box   

Move a box right by putting it into a larger box with extra columns, aligned to the right. See remarks for moveRight.

table :: [[String]] -> [Int] -> Box   

Create a table from a list of rows. A fixed width for each column must be specified.

render :: Box -> String   

Render a box to a string.

takeP :: a -> Int -> [a] -> [a]   

Takes a number of elements from a list. If the list is shorter than that number, fill the rest with a filler.

fReverse :: ([a],b) -> ([a],b)   

(***) :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)   

takePA :: Alignment -> a -> Int -> [a] -> [a]   

blanks :: Int -> String   

Generates a string of spaces.

renderBox :: Box -> [String]   

Render a box as a list of lines.

renderBoxWithRows :: Int -> Box -> [String]   

Render a box as a list of lines with a given number of rows.

renderBoxWithCols :: Int -> Box -> [String]   

Render a box as a list of lines with a given number of columns.

resizeBox :: Int -> Int -> [String] -> [String]   

Resize a rendered list of lines.

resizeBoxAligned :: Int -> Int -> Alignment -> Alignment -> [String] -> [String]   

Resize a rendered list of lines using the given alignments.

printBox :: Box -> IO ()   

Print a box to stdout.

chunksOf :: Int -> [a] -> [[a]]   

sum :: [Int] -> Int