@@ -20,20 +20,31 @@ import Prelude hiding
20 (head, tail)
20 (head, tail)
21import Servant.Foreign.Internal
21import Servant.Foreign.Internal
23+-- | Simply concat each part of the FunctionName together.
25+-- @[ "get", "documents", "by", "id" ] → "getdocumentsbyid"@
26+concatCase :: FunctionName -> Text
27+concatCase = view concatCaseL
23concatCaseL :: Getter FunctionName Text
29concatCaseL :: Getter FunctionName Text
24concatCaseL = _FunctionName . to mconcat
30concatCaseL = _FunctionName . to mconcat
26−-- | Function name builder that simply concat each part together
32+-- | Use the snake_case convention.
33+-- Each part is separated by a single underscore character.
35+-- @[ "get", "documents", "by", "id" ] → "get_documents_by_id"@
27−concatCase :: FunctionName -> Text
36+snakeCase :: FunctionName -> Text
28−concatCase = view concatCaseL
37+snakeCase = view snakeCaseL
30snakeCaseL :: Getter FunctionName Text
39snakeCaseL :: Getter FunctionName Text
31snakeCaseL = _FunctionName . to (intercalate "_")
40snakeCaseL = _FunctionName . to (intercalate "_")
33−-- | Function name builder using the snake_case convention.
42+-- | Use the camelCase convention.
34−-- each part is separated by a single underscore character.
43+-- The first part is lower case, every other part starts with an upper case character.
45+-- @[ "get", "documents", "by", "id" ] → "getDocumentsById"@
35−snakeCase :: FunctionName -> Text
46+camelCase :: FunctionName -> Text
36−snakeCase = view snakeCaseL
47+camelCase = view camelCaseL
38camelCaseL :: Getter FunctionName Text
49camelCaseL :: Getter FunctionName Text
39camelCaseL = _FunctionName . to convert
50camelCaseL = _FunctionName . to convert
@@ -42,8 +53,3 @@ camelCaseL = _FunctionName . to convert
42 convert (p:ps) = mconcat $ p : map capitalize ps
53 convert (p:ps) = mconcat $ p : map capitalize ps
43 capitalize "" = ""
54 capitalize "" = ""
44 capitalize name = C.toUpper (head name) `cons` tail name
55 capitalize name = C.toUpper (head name) `cons` tail name
46−-- | Function name builder using the CamelCase convention.
47−-- each part begins with an upper case character.
48−camelCase :: FunctionName -> Text
49−camelCase = view camelCaseL