casing-0.1.1.0: Convert between various source code casing conventions

Safe HaskellNone
LanguageHaskell2010

Text.Casing

Contents

Description

Conversions between several common identifier casing conventions:

  • PascalCase - no spacing between words, first letter in word is uppercase, all others are lowercase.
  • camelCase - like PascalCase, but the very first letter is lowercase.
  • kebab-case - everything lowercase, dash delimits words.
  • snake_Case - underscores delimit words, case is unrestricted.
  • quiet_snake_case - underscores delimit words, everything lowercase.
  • SCREAMING_SNAKE_CASE - underscores delimit words, everything uppercase.

Synopsis

Types

data Identifier a Source #

An opaque type that represents a parsed identifier.

Parsing

fromHumps :: String -> Identifier String Source #

Convert from "humped" casing (camelCase or PascalCase)

fromKebab :: String -> Identifier String Source #

Convert from kebab-cased-identifiers

fromSnake :: String -> Identifier String Source #

Convert from snake_cased (either flavor)

fromAny :: String -> Identifier String Source #

Convert from anything, including mixed casing.

Generating

toSnake :: Identifier String -> String Source #

To snake_Case

toQuietSnake :: Identifier String -> String Source #

To quiet_snake_case

toScreamingSnake :: Identifier String -> String Source #

To SCREAMING_SNAKE_CASE

toKebab :: Identifier String -> String Source #

To kebab-case

Shorthand functions

pascal :: String -> String Source #

Directly convert to PascalCase through fromAny

camel :: String -> String Source #

Directly convert to camelCase through fromAny

snake :: String -> String Source #

Directly convert to snake_Case through fromAny

quietSnake :: String -> String Source #

Directly convert to quiet_snake_case through fromAny

screamingSnake :: String -> String Source #

Directly convert to SCREAMING_SNAKE_CASE through fromAny

kebab :: String -> String Source #

Directly convert to kebab-case through fromAny

wordify :: String -> String Source #

Directly convert to word Case through fromAny

Miscellaneous

dropPrefix :: Identifier String -> Identifier String Source #

Drop the first word from a parsed identifier. Typical usage is between parsing and writing, e.g.: toKebab . dropPrefix . fromAny $ "strHelloWorld" == "hello-world"