-- | Formatting tools for code generation.
module JsonToType.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 Text
word = Text -> Text
Text.toUpper Text
first Text -> Text -> Text
`Text.append` Text
rest
  where
    (Text
first, Text
rest) = Int -> Text -> (Text, Text)
Text.splitAt Int
1 Text
word

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