vt-utils-1.3.0.0: Vector and Text utilities

Safe HaskellNone
LanguageHaskell2010

VtUtils.Text

Description

Text utilities

Synopsis

Documentation

textShow :: (Show a, Typeable a) => a -> Text Source #

Stringifies specified value

If input is Text, String or ByteString, it is returned as a Text string without additional quotes around it

Arguments:

  • val :: a: Value to stringify

Return value: Text string representation of a specified value

textSplit :: Text -> Text -> Vector Text Source #

Splits specified Text string into a Vector of parts using specified delimiter

Delimiter must be non-empty

Arguments:

  • haystack :: Text: string to split
  • needle :: Text delimiter

Return value: Vector Text vector containing the parts of the input string

textFormatParts :: Vector Text -> Vector Text -> Text Source #

Concatenates specified Vector of string parts interspersing it with specified parameters

If length of parameters Vector is less than a number of parts - 1, then remaining parameters are filled with empty strings. If parameters vector is too long, excessive parameters are ignored.

Arguments:

  • parts :: Vector Text: string parts
  • params :: Vector Text parameters to intersperse into the parts

Return value: Vector Text vector containing the parts of the input string

textFormat :: Text -> Vector Text -> Text Source #

Formats specified template with specified parameters Vector

Template must use {} string for placeholders.

If length of parameters Vector is less than a number of holes in template, then remaining parameters are filled with empty strings. If parameters vector is too long, excessive parameters are ignored.

Template preparation is relatively expensive, consider using textFormatParts for frequently used templates.

Arguments:

  • template :: Text: string parts
  • params :: Vector Text parameters to intersperse into the parts

Return value: Vector Text vector containing the parts of the input string

textDecodeUtf8 :: ByteString -> Text Source #

Decodes ByteString into Text using UTF-8 encoding

Invalid byte sequences are replaced with U+FFFD

Arguments:

  • bytes :: ByteString: Byte string

Return value: Text string