Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- headToLower :: HasCallStack => Text -> Text
- surround :: Semigroup a => a -> a -> a -> a
- dquotes :: (Semigroup a, IsString a) => a -> a
- stripFieldPrefix :: Text -> Text
- dropPrefix :: Text -> Text
- toCamel :: Text -> Text
- toPascal :: Text -> Text
- toSnake :: Text -> Text
- toSpinal :: Text -> Text
- lowerCaseCluster :: Text -> Text
Documentation
headToLower :: HasCallStack => Text -> Text Source #
Leads first character of text to lower case.
For empty text this will throw an error.
stripFieldPrefix :: Text -> Text Source #
Cut fields prefixes which we use according to the style guide.
>>>
stripFieldPrefix "cmMyField"
"myField"
dropPrefix :: Text -> Text Source #
Drops the field name prefix from a field.
We assume a convention of the prefix always being non-uppercase, and the first letter of the actual field name being uppercase.
toCamel :: Text -> Text Source #
Transform text to camelCase
.
If the text starts with a single uppercase letter, it is lowercased. If it starts with a cluster of non-lowercase letters, all but the last in the cluster are lowercased.
>>>
toCamel "MyField"
"myField">>>
toCamel "USPosition"
"usPosition">>>
toCamel "FA2Config"
"fa2Config"
toSnake :: Text -> Text Source #
Transform text to snake_case
.
Non-lowercase clusters starting with an uppercase letter are treated as separate words, except the last letter in the cluster.
>>>
toSnake "MyField"
"my_field">>>
toSnake "USPosition"
"us_position">>>
toSnake "FA2Config"
"fa2_config">>>
toSnake "MyUSPosition"
"my_us_position">>>
toSnake "MyFie123d"
"my_fie123d"
toSpinal :: Text -> Text Source #
Transform text to spinal-case
.
Non-lowercase clusters starting with an uppercase letter are treated as separate words, except the last letter in the cluster.
>>>
toSpinal "MyField"
"my-field">>>
toSpinal "USPosition"
"us-position">>>
toSpinal "FA2Config"
"fa2-config">>>
toSpinal "MyUSPosition"
"my-us-position">>>
toSpinal "MyFie123d"
"my-fie123d"
lowerCaseCluster :: Text -> Text Source #
If text starts with a cluster of non-lowercase letters, lowercase them except the last one.
>>>
lowerCaseCluster "USPosition"
"usPosition">>>
lowerCaseCluster "Position"
"Position">>>
lowerCaseCluster "FA2Config"
"fa2Config"