HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduletext-manipulate-0.3.1.0Haskell2010

Data.Text.Manipulate

Manipulate identifiers and structurally non-complex pieces of text by delimiting word boundaries via a combination of whitespace, control-characters, and case-sensitivity.

Assumptions have been made about word boundary characteristics inherint in predominantely English text, please see individual function documentation for further details and behaviour.

Contents
  1. Strict vs lazy types
  2. Unicode
  3. Fusion
  4. Subwords
  5. Removing words
  6. Breaking on words
  7. Character manipulation
  8. Line manipulation
  9. Ellipsis
  10. Acronyms
  11. Ordinals
  12. Casing
  13. Boundary predicates
Synopsis

Strict vs lazy types

This library provides functions for manipulating both strict and lazy Text types. The strict functions are provided by the Data.Text.Manipulate module, while the lazy functions are provided by the Data.Text.Lazy.Manipulate module.

Unicode

While this library supports Unicode in a similar fashion to the underlying text library, more explicit Unicode handling of word boundaries can be found in the text-icu library.

Fusion

Many functions in this module are subject to fusion, meaning that a pipeline of such functions will usually allocate at most one Text value.

Functions that can be fused by the compiler are documented with the phrase Subject to fusion.

Subwords

Removing words

valuetakeWord :: Text -> Text

O(n) Returns the first word, or the original text if no word boundary is encountered. Subject to fusion.

valuedropWord :: Text -> Text

O(n) Return the suffix after dropping the first word. If no word boundary is encountered, the result will be empty. Subject to fusion.

O(n) Return the suffix after removing the first word, or Nothing if no word boundary is encountered.

Example1 expression
stripWord "HTML5Spaghetti"Just "Spaghetti"
Example1 expression
stripWord "noboundaries"Nothing

Breaking on words

valuebreakWord :: Text -> (Text, Text)

Break a piece of text after the first word boundary is encountered.

Example1 expression
breakWord "PascalCasedVariable"("Pacal", "CasedVariable")
Example1 expression
breakWord "spinal-cased-variable"("spinal", "cased-variable")
valuesplitWords :: Text -> [Text]

O(n) Split into a list of words delimited by boundaries.

Example1 expression
splitWords "SupercaliFrag_ilistic"["Supercali","Frag","ilistic"]

Character manipulation

valuelowerHead :: Text -> Text

Lowercase the first character of a piece of text.

Example1 expression
lowerHead "Title Cased""title Cased"
valueupperHead :: Text -> Text

Uppercase the first character of a piece of text.

Example1 expression
upperHead "snake_cased""Snake_cased"

Line manipulation

Ellipsis

valuetoEllipsisWith
  1. :: Int

    Length.

  2. -> Text

    Ellipsis.

  3. -> Text
  4. -> Text

O(n) Truncate text to a specific length. If the text was truncated the given ellipsis sign will be appended.

Acronyms

O(n) Create an adhoc acronym from a piece of cased text.

Example1 expression
toAcronym "AmazonWebServices"Just "AWS"
Example1 expression
toAcronym "Learn-You Some_Haskell"Just "LYSH"
Example1 expression
toAcronym "this_is_all_lowercase"Nothing

Ordinals

valuetoOrdinal :: Integral a => a -> Text

Render an ordinal used to denote the position in an ordered sequence.

Example1 expression
toOrdinal (101 :: Int)"101st"
Example1 expression
toOrdinal (12 :: Int)"12th"

Casing

Boundary predicates