mirror of
https://github.com/scarf-sh/tie.git
synced 2024-11-22 10:31:56 +03:00
toCamelCase able to decide when to camel case.
- toCamelCase will not camel cased if the word is in screaming case.
This commit is contained in:
parent
a4fca9eda8
commit
19767f0b06
@ -131,19 +131,19 @@ toJsonFieldName = PP.pretty . unName
|
||||
|
||||
toDataTypeName :: Name -> PP.Doc ann
|
||||
toDataTypeName =
|
||||
PP.pretty . Text.pack . capitalizeFirstLetter . camelCaseIfNotAllCapitalized . Text.unpack . unName
|
||||
PP.pretty . Text.pack . capitalizeFirstLetter . toCamelCase . Text.unpack . unName
|
||||
|
||||
toOneOfDataTypeName :: Name -> PP.Doc ann
|
||||
toOneOfDataTypeName =
|
||||
PP.pretty . Text.pack . capitalizeFirstLetter . camelCaseIfNotAllCapitalized . Text.unpack . unName
|
||||
PP.pretty . Text.pack . capitalizeFirstLetter . toCamelCase . Text.unpack . unName
|
||||
|
||||
toOneOfConstructorName :: Name -> Name -> PP.Doc ann
|
||||
toOneOfConstructorName (Name oneOfType) (Name variant) =
|
||||
PP.pretty $
|
||||
Text.pack $
|
||||
escapeKeyword $
|
||||
capitalizeFirstLetter (camelCaseIfNotAllCapitalized $ Text.unpack oneOfType)
|
||||
<> capitalizeFirstLetter (camelCaseIfNotAllCapitalized $ Text.unpack variant)
|
||||
capitalizeFirstLetter (toCamelCase $ Text.unpack oneOfType)
|
||||
<> capitalizeFirstLetter (toCamelCase $ Text.unpack variant)
|
||||
|
||||
toConstructorName :: Name -> PP.Doc ann
|
||||
toConstructorName = toDataTypeName
|
||||
@ -315,8 +315,3 @@ extractHaskellModule =
|
||||
[Text.intercalate "." xs]
|
||||
in concatMap extractModule . Text.words
|
||||
|
||||
camelCaseIfNotAllCapitalized :: String -> String
|
||||
camelCaseIfNotAllCapitalized word =
|
||||
if all (==True) $ isUpper <$> word
|
||||
then word
|
||||
else toCamelCase word
|
||||
|
Loading…
Reference in New Issue
Block a user