HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecases-0.1.4.5Haskell2010

Cases

Convert arbitrary text into spinal, snake, camel, and custom case formats.

The parser is tolerant to mixed delimiters and punctuation, and it can split words out of mixed-case identifiers like myHTMLProcessor.

  • 2 types
  • 11 values
  • Packagecases-0.1.4.5
  • Exports13
  • LanguageHaskell2010
  • LicenceMIT
  • SourceCases.hs

Processor

1 declaration

Extract separate words from an arbitrary text using a smart parser and produce a new text using case transformation and delimiter functions.

Note: to skip case transformation use the id function.

Examples:

process lower spinal "abcDEF" == "abc-def"
process id camel "parse DBM XML" == "parseDbmXml"
process title whitespace "abc_def" == "Abc Def"

Case Transformers

valuelower :: CaseTransformer
#

Lower-case every word part.

process lower spinal APIResponse2XX == "api-response-2-xx"
valueupper :: CaseTransformer
#

Upper-case every word part.

process upper snake "myHtmlProcessor" == MY_HTML_PROCESSOR
valuetitle :: CaseTransformer
#

Title-case every word part.

process title whitespace "myHTMLProcessor" == "My Html Processor"

Delimiters

newtypenewtype Delimiter
#

Strategy for joining parsed parts into the output text.

A delimiter controls where separators are inserted (for example -, _, whitespace, or camel-style concatenation).

valuespinal :: Delimiter
#

Join parts with -.

Useful with lower to produce spinal case:

process lower spinal "myHTMLProcessor" == "my-html-processor"
valuesnake :: Delimiter
#

Join parts with _.

Useful with lower to produce snake case:

process lower snake "myHTMLProcessor" == "my_html_processor"
valuewhitespace :: Delimiter
#

Join parts with spaces.

process lower whitespace "myHTMLProcessor" == "my html processor"
valuecamel :: Delimiter
#

Concatenate parts and title-case every part after the first one.

process id camel "parse DBM XML" == "parseDbmXml"

Default Processors

3 declarations
valuespinalize :: Text -> Text
#

Transform an arbitrary text into a lower spinal case.

Same as (process lower spinal).

spinalize "myHTMLProcessor" == "my-html-processor"
spinalize " abc_-:,/def " == "abc-def"
valuesnakify :: Text -> Text
#

Transform an arbitrary text into a lower snake case.

Same as (process lower snake).

snakify "Ёжик лижет мёд." == "ёжик_лижет_мёд"
valuecamelize :: Text -> Text
#

Transform an arbitrary text into a camel case, while preserving the case of the first character.

Same as (process id camel).

camelize "abc-def" == "abcDef"
camelize "Abc-def" == AbcDef
camelize "parse DBM XML" == "parseDbmXml"