module DomainDriven.Internal.Text where

import Data.Char
    ( toLower
    , toUpper
    )
import Data.Text (Text)
import qualified Data.Text as T
import Prelude

lowerFirst :: String -> String
lowerFirst :: String -> String
lowerFirst = \case
    [] -> []
    Char
c : String
cs -> Char -> Char
toLower Char
c forall a. a -> [a] -> [a]
: String
cs

lowerFirstT :: Text -> Text
lowerFirstT :: Text -> Text
lowerFirstT = String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
lowerFirst forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack

upperFirst :: String -> String
upperFirst :: String -> String
upperFirst = \case
    [] -> []
    Char
c : String
cs -> Char -> Char
toUpper Char
c forall a. a -> [a] -> [a]
: String
cs

upperFirstT :: Text -> Text
upperFirstT :: Text -> Text
upperFirstT = String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
upperFirst forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack

camelAppend :: String -> String -> String
camelAppend :: String -> String -> String
camelAppend String
a String
b = String
a forall a. Semigroup a => a -> a -> a
<> String -> String
upperFirst String
b

camelAppendT :: Text -> Text -> Text
camelAppendT :: Text -> Text -> Text
camelAppendT Text
a Text
b = Text
a forall a. Semigroup a => a -> a -> a
<> Text -> Text
upperFirstT Text
b