Merge pull request #668 from phadej/fix_js_function_identifiers

Fix js function identifiers
This commit is contained in:
Oleg Grenrus 2017-01-16 12:15:35 +02:00 committed by GitHub
commit 48014f4a66
4 changed files with 10 additions and 5 deletions

View file

@ -1,3 +1,9 @@
0.10
----
* Do not apply JavaScript specific mangling to the names.
([#191](https://github.com/haskell-servant/servant/issues/191))
0.7.1 0.7.1
----- -----

View file

@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
snakeCase = view snakeCaseL snakeCase = view snakeCaseL
camelCaseL :: Getter FunctionName Text camelCaseL :: Getter FunctionName Text
camelCaseL = _FunctionName . to (convert . map (replace "-" "")) camelCaseL = _FunctionName . to convert
where where
convert [] = "" convert [] = ""
convert (p:ps) = mconcat $ p : map capitalize ps convert (p:ps) = mconcat $ p : map capitalize ps

View file

@ -316,9 +316,7 @@ instance (KnownSymbol path, HasForeign lang ftype api)
req & reqUrl . path <>~ [Segment (Static (PathSegment str))] req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
& reqFuncName . _FunctionName %~ (++ [str]) & reqFuncName . _FunctionName %~ (++ [str])
where where
str = str = pack . symbolVal $ (Proxy :: Proxy path)
Data.Text.map (\c -> if c == '.' then '_' else c)
. pack . symbolVal $ (Proxy :: Proxy path)
instance HasForeign lang ftype api instance HasForeign lang ftype api
=> HasForeign lang ftype (RemoteHost :> api) where => HasForeign lang ftype (RemoteHost :> api) where

View file

@ -20,7 +20,8 @@ camelCaseSpec = describe "camelCase" $ do
camelCase (FunctionName ["post", "counter", "inc"]) camelCase (FunctionName ["post", "counter", "inc"])
`shouldBe` "postCounterInc" `shouldBe` "postCounterInc"
camelCase (FunctionName ["get", "hyphen-ated", "counter"]) camelCase (FunctionName ["get", "hyphen-ated", "counter"])
`shouldBe` "getHyphenatedCounter" `shouldBe` "getHyphen-atedCounter"
---------------------------------------------------------------------- ----------------------------------------------------------------------