casing-0.1.4.1: Convert between various source code casing conventions
Safe HaskellNone
LanguageHaskell2010

Text.Casing

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

newtype Identifier a Source #

An opaque type that represents a parsed identifier.

Constructors

Identifier 

Fields

Instances

Instances details
Monad Identifier Source # 
Instance details

Defined in Text.Casing

Functor Identifier Source # 
Instance details

Defined in Text.Casing

Methods

fmap :: (a -> b) -> Identifier a -> Identifier b Source #

(<$) :: a -> Identifier b -> Identifier a Source #

Applicative Identifier Source # 
Instance details

Defined in Text.Casing

Foldable Identifier Source # 
Instance details

Defined in Text.Casing

Methods

fold :: Monoid m => Identifier m -> m Source #

foldMap :: Monoid m => (a -> m) -> Identifier a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Identifier a -> m Source #

foldr :: (a -> b -> b) -> b -> Identifier a -> b Source #

foldr' :: (a -> b -> b) -> b -> Identifier a -> b Source #

foldl :: (b -> a -> b) -> b -> Identifier a -> b Source #

foldl' :: (b -> a -> b) -> b -> Identifier a -> b Source #

foldr1 :: (a -> a -> a) -> Identifier a -> a Source #

foldl1 :: (a -> a -> a) -> Identifier a -> a Source #

toList :: Identifier a -> [a] Source #

null :: Identifier a -> Bool Source #

length :: Identifier a -> Int Source #

elem :: Eq a => a -> Identifier a -> Bool Source #

maximum :: Ord a => Identifier a -> a Source #

minimum :: Ord a => Identifier a -> a Source #

sum :: Num a => Identifier a -> a Source #

product :: Num a => Identifier a -> a Source #

Traversable Identifier Source # 
Instance details

Defined in Text.Casing

Methods

traverse :: Applicative f => (a -> f b) -> Identifier a -> f (Identifier b) Source #

sequenceA :: Applicative f => Identifier (f a) -> f (Identifier a) Source #

mapM :: Monad m => (a -> m b) -> Identifier a -> m (Identifier b) Source #

sequence :: Monad m => Identifier (m a) -> m (Identifier a) Source #

Eq a => Eq (Identifier a) Source # 
Instance details

Defined in Text.Casing

Show a => Show (Identifier a) Source # 
Instance details

Defined in Text.Casing

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"