Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module provides functions to shorten a piece of text where parts of the text are delimited to highlight the difference with another piece of text Then only the parts outside the difference are being shortened
Synopsis
- data ShortenOptions = ShortenOptions {
- _shortenSize :: Int
- _shortenText :: Text
- half :: ShortenOptions -> ShortenOptions
- shortenTokens :: ShortenOptions -> Token -> Token -> [Token] -> [Token]
- splitOnDelimiters :: Token -> Token -> [Token] -> [[Token]]
- shortenLeft :: ShortenOptions -> [Token] -> [Token]
- shortenRight :: ShortenOptions -> [Token] -> [Token]
- shortenCenter :: ShortenOptions -> [Token] -> [Token]
- whenTooLong :: ShortenOptions -> [Token] -> [Token] -> [Token]
- updateLast :: [a] -> (a -> a) -> [a]
Documentation
data ShortenOptions Source #
Size used to decide if a piece of text needs to be shortened
Instances
Show ShortenOptions Source # | |
Defined in Data.Text.Shorten showsPrec :: Int -> ShortenOptions -> ShowS # show :: ShortenOptions -> String # showList :: [ShortenOptions] -> ShowS # | |
Eq ShortenOptions Source # | |
Defined in Data.Text.Shorten (==) :: ShortenOptions -> ShortenOptions -> Bool # (/=) :: ShortenOptions -> ShortenOptions -> Bool # |
half :: ShortenOptions -> ShortenOptions Source #
Cut the shorten size in 2
shortenTokens :: ShortenOptions -> Token -> Token -> [Token] -> [Token] Source #
Shorten a piece of text that has already been tokenized
splitOnDelimiters :: Token -> Token -> [Token] -> [[Token]] Source #
Split a list of tokens into several lists when a delimiter is found abcd[efgh]ijkl[mnop]qrst -> [abcd, [efgh], ijkl, [mnop], qrst]
shortenLeft :: ShortenOptions -> [Token] -> [Token] Source #
Shorten some token on the left: ...tokens
shortenRight :: ShortenOptions -> [Token] -> [Token] Source #
Shorten some token on the right: tokens...
shortenCenter :: ShortenOptions -> [Token] -> [Token] Source #
Shorten some token in the center: ...tokens...
whenTooLong :: ShortenOptions -> [Token] -> [Token] -> [Token] Source #
Depending on the shorten option and the original list of tokens used a shorter version
Helpers
updateLast :: [a] -> (a -> a) -> [a] Source #
Update the last element of a list