Fix javascript function name generation, mostly fixes #191

and remove js-specific code in servant-foreign (code which would now be dead)
This commit is contained in:
Dario Bertini 2016-07-24 15:46:55 +02:00 committed by Oleg Grenrus
parent 094f28b42d
commit c20c09411d
3 changed files with 2 additions and 6 deletions

View file

@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
snakeCase = view snakeCaseL
camelCaseL :: Getter FunctionName Text
camelCaseL = _FunctionName . to (convert . map (replace "-" ""))
camelCaseL = _FunctionName . to convert
where
convert [] = ""
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))]
& reqFuncName . _FunctionName %~ (++ [str])
where
str =
Data.Text.map (\c -> if c == '.' then '_' else c)
. pack . symbolVal $ (Proxy :: Proxy path)
str = pack . symbolVal $ (Proxy :: Proxy path)
instance HasForeign lang ftype api
=> HasForeign lang ftype (RemoteHost :> api) where

View file

@ -19,8 +19,6 @@ camelCaseSpec = describe "camelCase" $ do
it "converts FunctionNames to camelCase" $ do
camelCase (FunctionName ["post", "counter", "inc"])
`shouldBe` "postCounterInc"
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
`shouldBe` "getHyphenatedCounter"
----------------------------------------------------------------------