git.iko.soy/typeable/servant
on master help sign in
Fix javascript function name generation, mostly fixes #191
c20c094Dario Bertini
servant-foreign/src/Servant/Foreign/Inflections.hs+1−1
@@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
32snakeCase = view snakeCaseL
32snakeCase = view snakeCaseL
33
33
34camelCaseL :: Getter FunctionName Text
34camelCaseL :: Getter FunctionName Text
35−camelCaseL = _FunctionName . to (convert . map (replace "-" ""))
35+camelCaseL = _FunctionName . to convert
36 where
36 where
37 convert [] = ""
37 convert [] = ""
38 convert (p:ps) = mconcat $ p : map capitalize ps
38 convert (p:ps) = mconcat $ p : map capitalize ps
servant-foreign/src/Servant/Foreign/Internal.hs+1−3
@@ -316,9 +316,7 @@ instance (KnownSymbol path, HasForeign lang ftype api)
316 req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
316 req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
317 & reqFuncName . _FunctionName %~ (++ [str])
317 & reqFuncName . _FunctionName %~ (++ [str])
318 where
318 where
319− str =
320− Data.Text.map (\c -> if c == '.' then '_' else c)
321− . pack . symbolVal $ (Proxy :: Proxy path)
319+ str = pack . symbolVal $ (Proxy :: Proxy path)
322
320
323instance HasForeign lang ftype api
321instance HasForeign lang ftype api
324 => HasForeign lang ftype (RemoteHost :> api) where
322 => HasForeign lang ftype (RemoteHost :> api) where
servant-foreign/test/Servant/ForeignSpec.hs−2
@@ -19,8 +19,6 @@ camelCaseSpec = describe "camelCase" $ do
19 it "converts FunctionNames to camelCase" $ do
19 it "converts FunctionNames to camelCase" $ do
20 camelCase (FunctionName ["post", "counter", "inc"])
20 camelCase (FunctionName ["post", "counter", "inc"])
21 `shouldBe` "postCounterInc"
21 `shouldBe` "postCounterInc"
22− camelCase (FunctionName ["get", "hyphen-ated", "counter"])
23− `shouldBe` "getHyphenatedCounter"
24
22
25----------------------------------------------------------------------
23----------------------------------------------------------------------
26
24