Safe Haskell | Safe-Inferred |
---|
Documentation
wordWrap :: Int -> Words -> LinesSource
Wraps a sequence of words into a sequence of lines, where each line is no more than a given maximum number of characters long.
If the maximum number of characters per line is less than 1, returns a Lines that is empty.
An individual word will be split across multiple lines only if that word is too long to fit into a single line. No hyphenation is done; the word is simply broken across two lines.
shorten :: Shortest -> Target -> Words -> WordsSource
Takes a list of words and shortens it so that it fits in the space allotted. You specify the minimum length for each word, x. It will shorten the farthest left word first, until it is only x characters long; then it will shorten the next word until it is only x characters long, etc. This proceeds until all words are just x characters long. Then words are shortened to one character. Then the leftmost words are deleted as necessary.
Assumes that the words will be printed with a separator, which matters when lengths are calculated.