HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

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.

  • 22 values

Strict vs lazy types

0 declarations

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

0 declarations

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

0 declarations

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

0 declarations

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.

valuestripWord :: Text -> Maybe Text
#

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

3 declarations
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

2 declarations

Ellipsis

2 declarations
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

1 declaration
valuetoAcronym :: Text -> Maybe Text
#

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

1 declaration
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

6 declarations
valuetoTitle :: Text -> Text
#

O(n) Convert casing to Title Cased Phrase. Subject to fusion.

valuetoCamel :: Text -> Text
#

O(n) Convert casing to camelCasedPhrase. Subject to fusion.

valuetoPascal :: Text -> Text
#

O(n) Convert casing to PascalCasePhrase. Subject to fusion.

valuetoSnake :: Text -> Text
#

O(n) Convert casing to snake_cased_phrase. Subject to fusion.

valuetoSpinal :: Text -> Text
#

O(n) Convert casing to spinal-cased-phrase. Subject to fusion.

valuetoTrain :: Text -> Text
#

O(n) Convert casing to Train-Cased-Phrase. Subject to fusion.

Boundary predicates

2 declarations