casing-0.1.4.1: 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

newtype Identifier a Source #

An opaque type that represents a parsed identifier.

Constructors

Identifier 

Fields

Instances
Monad Identifier Source # 
Instance details

Defined in Text.Casing

Methods

(>>=) :: Identifier a -> (a -> Identifier b) -> Identifier b #

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

return :: a -> Identifier a #

fail :: String -> Identifier a #

Functor Identifier Source # 
Instance details

Defined in Text.Casing

Methods

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

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

Applicative Identifier Source # 
Instance details

Defined in Text.Casing

Methods

pure :: a -> Identifier a #

(<*>) :: Identifier (a -> b) -> Identifier a -> Identifier b #

liftA2 :: (a -> b -> c) -> Identifier a -> Identifier b -> Identifier c #

(*>) :: Identifier a -> Identifier b -> Identifier b #

(<*) :: Identifier a -> Identifier b -> Identifier a #

Foldable Identifier Source # 
Instance details

Defined in Text.Casing

Methods

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

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

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

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

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

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

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

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

toList :: Identifier a -> [a] #

null :: Identifier a -> Bool #

length :: Identifier a -> Int #

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

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

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

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

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

Traversable Identifier Source # 
Instance details

Defined in Text.Casing

Methods

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

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

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

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

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

Defined in Text.Casing

Methods

(==) :: Identifier a -> Identifier a -> Bool #

(/=) :: Identifier a -> Identifier a -> Bool #

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"