@@ -89,9 +89,6 @@ defCommonGeneratorOptions = CommonGeneratorOptions
90-- @TODO: specify better default function name, or throw error?
90-- @TODO: specify better default function name, or throw error?
91toValidFunctionName :: Text -> Text
91toValidFunctionName :: Text -> Text
95toValidFunctionName t =
92toValidFunctionName t =
96 case T.uncons t of
93 case T.uncons t of
97 Just (x,xs) ->
94 Just (x,xs) ->
@@ -101,29 +98,7 @@ toValidFunctionName t =
101 setFirstChar c = if firstChar c then c else '_'
98 setFirstChar c = if firstChar c then c else '_'
102 firstChar c = prefixOK c || any (Set.member c) firstLetterOK
99 firstChar c = prefixOK c || any (Set.member c) firstLetterOK
103 remainder c = prefixOK c || any (Set.member c) remainderOK
100 remainder c = prefixOK c || any (Set.member c) remainderOK
105− prefixOK c = c `elem` ['$','_']
106− -- Unicode character sets
107− firstLetterOK = [ Set.lowercaseLetter
108− , Set.uppercaseLetter
109− , Set.titlecaseLetter
110− , Set.modifierLetter
112− , Set.letterNumber ]
113− remainderOK = firstLetterOK
114− <> [ Set.nonSpacingMark
115− , Set.spacingCombiningMark
117− , Set.connectorPunctuation ]
119−toValidFunctionName (x:xs) = [setFirstChar x] <> filter remainder xs
121− setFirstChar c = if firstChar c then c else '_'
122− firstChar c = prefixOK c || any (Set.member c) firstLetterOK
123− remainder c = prefixOK c || any (Set.member c) remainderOK
125 prefixOK c = c `elem` ['$','_']
101 prefixOK c = c `elem` ['$','_']
126− -- Unicode character sets
127 firstLetterOK = [ Set.lowercaseLetter
102 firstLetterOK = [ Set.lowercaseLetter
128 , Set.uppercaseLetter
103 , Set.uppercaseLetter
129 , Set.titlecaseLetter
104 , Set.titlecaseLetter
@@ -135,8 +110,6 @@ toValidFunctionName (x:xs) = [setFirstChar x] <> filter remainder xs
135 , Set.spacingCombiningMark
110 , Set.spacingCombiningMark
136 , Set.decimalNumber
111 , Set.decimalNumber
137 , Set.connectorPunctuation ]
112 , Set.connectorPunctuation ]
138−toValidFunctionName [] = "_"
141toJSHeader :: HeaderArg -> Text
114toJSHeader :: HeaderArg -> Text
142toJSHeader (HeaderArg n) = toValidFunctionName ("header" <> n)
115toJSHeader (HeaderArg n) = toValidFunctionName ("header" <> n)