casing 0.1.0.1 → 0.1.1.0
raw patch · 2 files changed
+28/−4 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Text.Casing: instance Applicative Identifier
- Text.Casing: instance Functor Identifier
- Text.Casing: instance Monad Identifier
- Text.Casing: instance Show a => Show (Identifier a)
+ Text.Casing: fromWords :: String -> Identifier String
+ Text.Casing: instance GHC.Base.Applicative Text.Casing.Identifier
+ Text.Casing: instance GHC.Base.Functor Text.Casing.Identifier
+ Text.Casing: instance GHC.Base.Monad Text.Casing.Identifier
+ Text.Casing: instance GHC.Show.Show a => GHC.Show.Show (Text.Casing.Identifier a)
+ Text.Casing: toWords :: Identifier String -> String
+ Text.Casing: wordify :: String -> String
Files
- Text/Casing.hs +27/−3
- casing.cabal +1/−1
Text/Casing.hs view
@@ -16,11 +16,24 @@ , fromHumps , fromKebab , fromSnake+, fromWords , fromAny -- * Generating-, toCamel, toPascal, toSnake, toQuietSnake, toScreamingSnake, toKebab+, toCamel+, toPascal+, toSnake+, toQuietSnake+, toScreamingSnake+, toKebab+, toWords -- * Shorthand functions-, pascal, camel, snake, quietSnake, screamingSnake, kebab+, pascal+, camel+, snake+, quietSnake+, screamingSnake+, kebab+, wordify -- * Miscellaneous , dropPrefix )@@ -53,6 +66,9 @@ let (z:zs) = go (y:xs) in (x:z):zs +fromWords :: String -> Identifier String+fromWords = Identifier . words+ -- | Convert from @kebab-cased-identifiers@ fromKebab :: String -> Identifier String fromKebab = Identifier . wordsBy (== '-')@@ -63,7 +79,7 @@ -- | Convert from anything, including mixed casing. fromAny :: String -> Identifier String-fromAny str = fromHumps str >>= fromKebab >>= fromSnake+fromAny str = fromHumps str >>= fromKebab >>= fromSnake >>= fromWords -- | To @PascalCase@ toPascal :: Identifier String -> String@@ -89,6 +105,10 @@ toScreamingSnake :: Identifier String -> String toScreamingSnake = map toUpper . toSnake +-- | To @word Case@+toWords :: Identifier String -> String+toWords = unwords . unIdentifier+ -- | Directly convert to @PascalCase@ through 'fromAny' pascal :: String -> String pascal = toPascal . fromAny@@ -112,6 +132,10 @@ -- | Directly convert to @kebab-case@ through 'fromAny' kebab :: String -> String kebab = toKebab . fromAny++-- | Directly convert to @word Case@ through 'fromAny'+wordify :: String -> String+wordify = toWords . fromAny -- | Drop the first word from a parsed identifier. Typical usage is between -- parsing and writing, e.g.: @toKebab . dropPrefix . fromAny $ "strHelloWorld" == "hello-world"@
casing.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: casing-version: 0.1.0.1+version: 0.1.1.0 synopsis: Convert between various source code casing conventions description: Converts between camelCase, PascalCase, kebab-case, and three flavors of snake_case.