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:
parent
094f28b42d
commit
c20c09411d
3 changed files with 2 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in a new issue