Module Boxes

Summary of exported operations:

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

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  Deterministic 

Top alignment.

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

bottom :: Alignment  Deterministic 

Botton alignment.

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

left :: Alignment  Deterministic 

Left alignment.

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

center1 :: Alignment  Deterministic 

Center-top/left alignment.

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

center2 :: Alignment  Deterministic 

Center-bottom/right alignment.

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

nullBox :: Box  Deterministic 

Creates an empty 0x0 box.

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

emptyBox :: Int -> Int -> Box  Deterministic 

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  Deterministic 

Creates a 1x1 box from a character.

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

text :: String -> Box  Deterministic 

Creates a Nx1 box from a string of length N.

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

Combine two boxes horizontally with top alignment.

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

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

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

Combine two boxes vertically with left alignment.

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

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

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

Combines a list of boxes horizontally with the given alignment.

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

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

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

Combines a list of boxes vertically with the given alignment.

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

Calculate sum and maximum of a list.

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

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

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

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  Deterministic 

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  Deterministic 

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

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

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]  Deterministic 

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  Deterministic 

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

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

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

emptyPara :: Int -> Para  Deterministic 

Creates an empty paragraph of the given width.

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

getLines :: Para -> [String]  Deterministic 

Returns all lines of a paragraph.

mkLine :: [Word] -> Line  Deterministic 

Creates a line from a list of words.

startLine :: Word -> Line  Deterministic 

Creates a line from a single word.

mkWord :: String -> Word  Deterministic 

Creates a word from a string.

addWordP :: Para -> Word -> Para  Deterministic 

Adds a word to a paragraph.

addWordL :: Word -> Line -> Line  Deterministic 

Adds a word to a line.

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

Checks whether a word fits into a line.

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

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

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

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  Deterministic 

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

moveUp :: Int -> Box -> Box  Deterministic 

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  Deterministic 

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  Deterministic 

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  Deterministic 

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  Deterministic 

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

render :: Box -> String  Deterministic 

Render a box to a string.

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

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)  Deterministic 

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

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

blanks :: Int -> String  Deterministic 

Generates a string of spaces.

renderBox :: Box -> [String]  Deterministic 

Render a box as a list of lines.

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

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

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

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

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

Resize a rendered list of lines.

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

Resize a rendered list of lines using the given alignments.

printBox :: Box -> IO ()  Deterministic 

Print a box to stdout.

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

sum :: [Int] -> Int  Deterministic