Shored.camelCaseToHyphenated: handle ABCDef = abc-def.

This commit is contained in:
John MacFarlane 2019-10-07 21:31:03 -07:00
parent 8fb9a0d168
commit e4ccfeab8c

View file

@ -242,8 +242,14 @@ stripFirstAndLast str =
-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
camelCaseToHyphenated :: String -> String
camelCaseToHyphenated [] = ""
camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =
a:'-':toLower b:camelCaseToHyphenated rest
camelCaseToHyphenated (a:b:rest)
| isLower a
, isUpper b = a:'-':toLower b:camelCaseToHyphenated rest
-- handle ABCDef = abc-def
camelCaseToHyphenated (a:b:c:rest)
| isUpper a
, isUpper b
, isLower c = toLower a:'-':toLower b:camelCaseToHyphenated (c:rest)
camelCaseToHyphenated (a:rest) = toLower a:camelCaseToHyphenated rest
-- | Convert number < 4000 to uppercase roman numeral.