Module Boxes

Exported Datatypes


data Box

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

Constructors:


data 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

data 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

data Para

A paragraph has a width and some content.

Constructors:


data ParaContent

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

Constructors:

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

    Fields:


data Line

A line has a length and a list of words.

Constructors:

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

    Fields:


data Word

A word has a length and its contents.

Constructors:


Exported Functions


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

right :: Alignment  Deterministic 

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

:: Int  number of rows
-> Int  number of columns
-> Box 
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 b => (a -> Int) -> b -> (a -> b) -> [a] -> (Int, b)  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.

:: Alignment  the alignment of the text
-> Int  the box's width
-> String  the box's contents
-> Box 

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.

Further infos:
  • partially defined

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.

Further infos:
  • partially defined

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