-- | Formatting tools for code generation.
module Data.Aeson.AutoType.Format(capitalize, uncapitalize) where

import Data.Text(Text)
import qualified Data.Text as Text

-- | Make the first letter of a Text upper case.
capitalize :: Text -> Text
capitalize :: Text -> Text
capitalize word :: Text
word = Text -> Text
Text.toUpper Text
first Text -> Text -> Text
`Text.append` Text
rest
  where
    (first :: Text
first, rest :: Text
rest) = Int -> Text -> (Text, Text)
Text.splitAt 1 Text
word

-- | Make the first letter of a Text lower case.
uncapitalize :: Text -> Text
uncapitalize :: Text -> Text
uncapitalize word :: Text
word = Text -> Text
Text.toLower Text
first Text -> Text -> Text
`Text.append` Text
rest
  where
    (first :: Text
first, rest :: Text
rest) = Int -> Text -> (Text, Text)
Text.splitAt 1 Text
word