{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Inflections.Camelize
( camelize
, camelizeCustom )
where
import Data.Text (Text)
import Text.Inflections.Types
import qualified Data.Text as T
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
camelize
:: [SomeWord]
-> Text
camelize :: [SomeWord] -> Text
camelize = Bool -> [SomeWord] -> Text
camelizeCustom Bool
True
camelizeCustom
:: Bool
-> [SomeWord]
-> Text
camelizeCustom :: Bool -> [SomeWord] -> Text
camelizeCustom Bool
_ [] = Text
""
camelizeCustom Bool
c (SomeWord
x:[SomeWord]
xs) = [Text] -> Text
T.concat forall a b. (a -> b) -> a -> b
$
(Text -> Text) -> SomeWord -> Text
unSomeWord (if Bool
c then Text -> Text
T.toTitle else Text -> Text
T.toLower) SomeWord
x forall a. a -> [a] -> [a]
: ((Text -> Text) -> SomeWord -> Text
unSomeWord Text -> Text
T.toTitle forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [SomeWord]
xs)