git.iko.soy/typeable/servant
on master help sign in
Make servant-foreign code nicer

* non-messy imports * got rid of most long lines (>80 chars) * prisms for sum types and newtypes(we use lens anyway, so why not) * consistent indentation

commite6e13fde8452dac7651033d52d99001ad627b9ab authorDenis Redozubov <denis.redozubov@gmail.com> dateThu 11 Feb 2016, 13:41 (11 years ago) parent761443f
8 files changed+200−157
servant-foreign/src/Servant/Foreign.hs+35−21 servant-foreign/src/Servant/Foreign/Internal.hs+85−65 servant-foreign/test/Servant/ForeignSpec.hs+63−61 servant-js/src/Servant/JS/Angular.hs+1−1 servant-js/src/Servant/JS/Axios.hs+1−1 servant-js/src/Servant/JS/Internal.hs+13−6 servant-js/src/Servant/JS/JQuery.hs+1−1 servant-js/src/Servant/JS/Vanilla.hs+1−1
servant-foreign/src/Servant/Foreign.hs+35−21
@@ -1,36 +1,50 @@
11-- | Generalizes all the data needed to make code generation work with
22-- arbitrary programming languages.
33module Servant.Foreign
4− ( HasForeign(..)
5− , HasForeignType(..)
4+ ( ArgType(..)
5+ , HeaderArg(..)
6+ , QueryArg(..)
7+ , Req(..)
68 , Segment(..)
79 , SegmentType(..)
10+ , Url(..)
11+ -- aliases
12+ , Path
13+ , ForeignType
14+ , Arg
815 , FunctionName
9− , QueryArg(..)
10− , HeaderArg(..)
11− , ArgType(..)
12− , Req
13− , captureArg
14− , defReq
15− , concatCase
16− , snakeCase
17− , camelCase
18− -- lenses
19− , argType
20− , argName
21− , isCapture
22− , funcName
23− , path
16+ -- lenses
2417 , reqUrl
25− , reqBody
26− , reqHeaders
2718 , reqMethod
19+ , reqHeaders
20+ , reqBody
2821 , reqReturnType
29− , segment
22+ , reqFuncName
23+ , path
3024 , queryStr
31− , listFromAPI
25+ , argName
26+ , argType
27+ -- prisms
28+ , _HeaderArg
29+ , _ReplaceHeaderArg
30+ , _Static
31+ , _Cap
32+ , _Normal
33+ , _Flag
34+ , _List
35+ -- rest of it
36+ , HasForeign(..)
37+ , HasForeignType(..)
38+ , HasNoForeignType
3239 , GenerateList(..)
3340 , NoTypes
41+ , captureArg
42+ , isCapture
43+ , concatCase
44+ , snakeCase
45+ , camelCase
46+ , defReq
47+ , listFromAPI
3448 -- re-exports
3549 , module Servant.API
3650 ) where
servant-foreign/src/Servant/Foreign/Internal.hs+85−65
@@ -19,17 +19,19 @@
1919-- arbitrary programming languages.
2020module Servant.Foreign.Internal where
2121
22−import Control.Lens (makeLenses, (%~), (&), (.~), (<>~))
23−import qualified Data.Char as C
22+import Control.Lens (makeLenses, makePrisms, (%~), (&), (.~), (<>~))
23+import qualified Data.Char as C
2424import Data.Proxy
2525import Data.Text
26−import Data.Text.Encoding (decodeUtf8)
27−import GHC.Exts (Constraint)
26+import Data.Text.Encoding (decodeUtf8)
27+import GHC.Exts (Constraint)
2828import GHC.TypeLits
29−import qualified Network.HTTP.Types as HTTP
30−import Prelude hiding (concat)
29+import qualified Network.HTTP.Types as HTTP
30+import Prelude hiding (concat)
3131import Servant.API
3232
33+type FunctionName = [Text]
34+
3335-- | Function name builder that simply concat each part together
3436concatCase :: FunctionName -> Text
3537concatCase = concat
@@ -49,36 +51,50 @@ camelCase = camelCase' . Prelude.map (replace "-" "")
4951 capitalize name = C.toUpper (Data.Text.head name) `cons` Data.Text.tail name
5052
5153type ForeignType = Text
54+
5255type Arg = (Text, ForeignType)
5356
54−newtype Segment = Segment { _segment :: SegmentType }
57+data SegmentType
58+ = Static Text
59+ -- ^ a static path segment. like "/foo"
60+ | Cap Arg
61+ -- ^ a capture. like "/:userid"
5562 deriving (Eq, Show)
5663
57−data SegmentType = Static Text -- ^ a static path segment. like "/foo"
58− | Cap Arg -- ^ a capture. like "/:userid"
64+makePrisms ''SegmentType
65+
66+newtype Segment = Segment { unSegment :: SegmentType }
5967 deriving (Eq, Show)
6068
69+makePrisms ''Segment
70+
6171type Path = [Segment]
6272
63−data ArgType =
64− Normal
73+data ArgType
74+ = Normal
6575 | Flag
6676 | List
6777 deriving (Eq, Show)
6878
79+makePrisms ''ArgType
80+
6981data QueryArg = QueryArg
7082 { _argName :: Arg
7183 , _argType :: ArgType
7284 } deriving (Eq, Show)
7385
86+makeLenses ''QueryArg
87+
7488data HeaderArg = HeaderArg
75− { headerArg :: Arg
76− }
89+ { headerArg :: Arg }
7790 | ReplaceHeaderArg
78− { headerArg :: Arg
79− , headerPattern :: Text
80− } deriving (Eq, Show)
91+ { headerArg :: Arg
92+ , headerPattern :: Text
93+ } deriving (Eq, Show)
8194
95+makeLenses ''HeaderArg
96+
97+makePrisms ''HeaderArg
8298
8399data Url = Url
84100 { _path :: Path
@@ -88,7 +104,7 @@ data Url = Url
88104defUrl :: Url
89105defUrl = Url [] []
90106
91−type FunctionName = [Text]
107+makeLenses ''Url
92108
93109data Req = Req
94110 { _reqUrl :: Url
@@ -96,12 +112,9 @@ data Req = Req
96112 , _reqHeaders :: [HeaderArg]
97113 , _reqBody :: Maybe ForeignType
98114 , _reqReturnType :: ForeignType
99− , _funcName :: FunctionName
115+ , _reqFuncName :: FunctionName
100116 } deriving (Eq, Show)
101117
102−makeLenses ''QueryArg
103−makeLenses ''Segment
104−makeLenses ''Url
105118makeLenses ''Req
106119
107120isCapture :: Segment -> Bool
@@ -155,66 +168,66 @@ type family Elem (a :: *) (ls::[*]) :: Constraint where
155168-- >
156169--
157170class HasForeignType lang a where
158− typeFor :: Proxy lang -> Proxy a -> ForeignType
171+ typeFor :: Proxy lang -> Proxy a -> ForeignType
159172
160173data NoTypes
161174
162−instance HasForeignType NoTypes a where
163− typeFor _ _ = empty
175+instance HasForeignType NoTypes ftype where
176+ typeFor _ _ = empty
177+
178+type HasNoForeignType = HasForeignType NoTypes
164179
165180class HasForeign lang (layout :: *) where
166181 type Foreign layout :: *
167182 foreignFor :: Proxy lang -> Proxy layout -> Req -> Foreign layout
168183
169184instance (HasForeign lang a, HasForeign lang b)
170− => HasForeign lang (a :<|> b) where
185+ => HasForeign lang (a :<|> b) where
171186 type Foreign (a :<|> b) = Foreign a :<|> Foreign b
172187
173188 foreignFor lang Proxy req =
174189 foreignFor lang (Proxy :: Proxy a) req
175190 :<|> foreignFor lang (Proxy :: Proxy b) req
176191
177−instance (KnownSymbol sym, HasForeignType lang a, HasForeign lang sublayout)
178− => HasForeign lang (Capture sym a :> sublayout) where
192+instance (KnownSymbol sym, HasForeignType lang ftype, HasForeign lang sublayout)
193+ => HasForeign lang (Capture sym ftype :> sublayout) where
179194 type Foreign (Capture sym a :> sublayout) = Foreign sublayout
180195
181196 foreignFor lang Proxy req =
182197 foreignFor lang (Proxy :: Proxy sublayout) $
183198 req & reqUrl.path <>~ [Segment (Cap arg)]
184− & funcName %~ (++ ["by", str])
185−
199+ & reqFuncName %~ (++ ["by", str])
186200 where
187− str = pack . symbolVal $ (Proxy :: Proxy sym)
188− arg = (str, typeFor lang (Proxy :: Proxy a))
201+ str = pack . symbolVal $ (Proxy :: Proxy sym)
202+ arg = (str, typeFor lang (Proxy :: Proxy ftype))
189203
190204instance (Elem JSON list, HasForeignType lang a, ReflectMethod method)
191− => HasForeign lang (Verb method status list a) where
205+ => HasForeign lang (Verb method status list a) where
192206 type Foreign (Verb method status list a) = Req
193207
194208 foreignFor lang Proxy req =
195− req & funcName %~ (methodLC :)
209+ req & reqFuncName %~ (methodLC :)
196210 & reqMethod .~ method
197211 & reqReturnType .~ retType
198212 where
199− retType = typeFor lang (Proxy :: Proxy a)
200− method = reflectMethod (Proxy :: Proxy method)
201− methodLC = toLower $ decodeUtf8 method
213+ retType = typeFor lang (Proxy :: Proxy a)
214+ method = reflectMethod (Proxy :: Proxy method)
215+ methodLC = toLower $ decodeUtf8 method
202216
203217instance (KnownSymbol sym, HasForeignType lang a, HasForeign lang sublayout)
204− => HasForeign lang (Header sym a :> sublayout) where
218+ => HasForeign lang (Header sym a :> sublayout) where
205219 type Foreign (Header sym a :> sublayout) = Foreign sublayout
206220
207221 foreignFor lang Proxy req =
208222 foreignFor lang subP $ req
209223 & reqHeaders <>~ [HeaderArg arg]
210−
211224 where
212− hname = pack . symbolVal $ (Proxy :: Proxy sym)
213− arg = (hname, typeFor lang (Proxy :: Proxy a))
214− subP = Proxy :: Proxy sublayout
225+ hname = pack . symbolVal $ (Proxy :: Proxy sym)
226+ arg = (hname, typeFor lang (Proxy :: Proxy a))
227+ subP = Proxy :: Proxy sublayout
215228
216229instance (KnownSymbol sym, HasForeignType lang a, HasForeign lang sublayout)
217− => HasForeign lang (QueryParam sym a :> sublayout) where
230+ => HasForeign lang (QueryParam sym a :> sublayout) where
218231 type Foreign (QueryParam sym a :> sublayout) = Foreign sublayout
219232
220233 foreignFor lang Proxy req =
@@ -222,38 +235,37 @@ instance (KnownSymbol sym, HasForeignType lang a, HasForeign lang sublayout)
222235 req & reqUrl.queryStr <>~ [QueryArg arg Normal]
223236
224237 where
225− str = pack . symbolVal $ (Proxy :: Proxy sym)
226− arg = (str, typeFor lang (Proxy :: Proxy a))
238+ str = pack . symbolVal $ (Proxy :: Proxy sym)
239+ arg = (str, typeFor lang (Proxy :: Proxy a))
227240
228−instance (KnownSymbol sym, HasForeignType lang [a], HasForeign lang sublayout)
229− => HasForeign lang (QueryParams sym a :> sublayout) where
241+instance
242+ (KnownSymbol sym, HasForeignType lang [a], HasForeign lang sublayout)
243+ => HasForeign lang (QueryParams sym a :> sublayout) where
230244 type Foreign (QueryParams sym a :> sublayout) = Foreign sublayout
231−
232245 foreignFor lang Proxy req =
233246 foreignFor lang (Proxy :: Proxy sublayout) $
234247 req & reqUrl.queryStr <>~ [QueryArg arg List]
235−
236248 where
237− str = pack . symbolVal $ (Proxy :: Proxy sym)
238− arg = (str, typeFor lang (Proxy :: Proxy [a]))
249+ str = pack . symbolVal $ (Proxy :: Proxy sym)
250+ arg = (str, typeFor lang (Proxy :: Proxy [a]))
239251
240−instance (KnownSymbol sym, HasForeignType lang a, a ~ Bool, HasForeign lang sublayout)
241− => HasForeign lang (QueryFlag sym :> sublayout) where
252+instance
253+ (KnownSymbol sym, HasForeignType lang Bool, HasForeign lang sublayout)
254+ => HasForeign lang (QueryFlag sym :> sublayout) where
242255 type Foreign (QueryFlag sym :> sublayout) = Foreign sublayout
243256
244257 foreignFor lang Proxy req =
245258 foreignFor lang (Proxy :: Proxy sublayout) $
246259 req & reqUrl.queryStr <>~ [QueryArg arg Flag]
247−
248260 where
249− str = pack . symbolVal $ (Proxy :: Proxy sym)
250− arg = (str, typeFor lang (Proxy :: Proxy a))
261+ str = pack . symbolVal $ (Proxy :: Proxy sym)
262+ arg = (str, typeFor lang (Proxy :: Proxy Bool))
251263
252264instance HasForeign lang Raw where
253265 type Foreign Raw = HTTP.Method -> Req
254266
255267 foreignFor _ Proxy req method =
256− req & funcName %~ ((toLower $ decodeUtf8 method) :)
268+ req & reqFuncName %~ ((toLower $ decodeUtf8 method) :)
257269 & reqMethod .~ method
258270
259271instance (Elem JSON list, HasForeignType lang a, HasForeign lang sublayout)
@@ -271,19 +283,21 @@ instance (KnownSymbol path, HasForeign lang sublayout)
271283 foreignFor lang Proxy req =
272284 foreignFor lang (Proxy :: Proxy sublayout) $
273285 req & reqUrl.path <>~ [Segment (Static str)]
274− & funcName %~ (++ [str])
275−
286+ & reqFuncName %~ (++ [str])
276287 where
277− str = Data.Text.map (\c -> if c == '.' then '_' else c)
278− . pack . symbolVal $ (Proxy :: Proxy path)
288+ str =
289+ Data.Text.map (\c -> if c == '.' then '_' else c)
290+ . pack . symbolVal $ (Proxy :: Proxy path)
279291
280−instance HasForeign lang sublayout => HasForeign lang (RemoteHost :> sublayout) where
292+instance HasForeign lang sublayout
293+ => HasForeign lang (RemoteHost :> sublayout) where
281294 type Foreign (RemoteHost :> sublayout) = Foreign sublayout
282295
283296 foreignFor lang Proxy req =
284297 foreignFor lang (Proxy :: Proxy sublayout) req
285298
286−instance HasForeign lang sublayout => HasForeign lang (IsSecure :> sublayout) where
299+instance HasForeign lang sublayout
300+ => HasForeign lang (IsSecure :> sublayout) where
287301 type Foreign (IsSecure :> sublayout) = Foreign sublayout
288302
289303 foreignFor lang Proxy req =
@@ -302,7 +316,8 @@ instance HasForeign lang sublayout =>
302316
303317 foreignFor lang Proxy = foreignFor lang (Proxy :: Proxy sublayout)
304318
305−instance HasForeign lang sublayout => HasForeign lang (HttpVersion :> sublayout) where
319+instance HasForeign lang sublayout
320+ => HasForeign lang (HttpVersion :> sublayout) where
306321 type Foreign (HttpVersion :> sublayout) = Foreign sublayout
307322
308323 foreignFor lang Proxy req =
@@ -317,10 +332,15 @@ class GenerateList reqs where
317332instance GenerateList Req where
318333 generateList r = [r]
319334
320−instance (GenerateList start, GenerateList rest) => GenerateList (start :<|> rest) where
335+instance (GenerateList start, GenerateList rest)
336+ => GenerateList (start :<|> rest) where
321337 generateList (start :<|> rest) = (generateList start) ++ (generateList rest)
322338
323339-- | Generate the necessary data for codegen as a list, each 'Req'
324340-- describing one endpoint from your API type.
325−listFromAPI :: (HasForeign lang api, GenerateList (Foreign api)) => Proxy lang -> Proxy api -> [Req]
341+listFromAPI
342+ :: (HasForeign lang api, GenerateList (Foreign api))
343+ => Proxy lang
344+ -> Proxy api
345+ -> [Req]
326346listFromAPI lang p = generateList (foreignFor lang p defReq)
servant-foreign/test/Servant/ForeignSpec.hs+63−61
@@ -15,7 +15,6 @@ module Servant.ForeignSpec where
1515import Data.Monoid ((<>))
1616import Data.Proxy
1717import Servant.Foreign
18−import Servant.Foreign.Internal
1918
2019import Test.Hspec
2120
@@ -35,15 +34,19 @@ camelCaseSpec = describe "camelCase" $ do
3534data LangX
3635
3736instance HasForeignType LangX () where
38− typeFor _ _ = "voidX"
37+ typeFor _ _ = "voidX"
38+
3939instance HasForeignType LangX Int where
40− typeFor _ _ = "intX"
40+ typeFor _ _ = "intX"
41+
4142instance HasForeignType LangX Bool where
42− typeFor _ _ = "boolX"
43+ typeFor _ _ = "boolX"
44+
4345instance OVERLAPPING_ HasForeignType LangX String where
44− typeFor _ _ = "stringX"
46+ typeFor _ _ = "stringX"
47+
4548instance OVERLAPPABLE_ HasForeignType LangX a => HasForeignType LangX [a] where
46− typeFor lang _ = "listX of " <> typeFor lang (Proxy :: Proxy a)
49+ typeFor lang _ = "listX of " <> typeFor lang (Proxy :: Proxy a)
4750
4851type TestApi
4952 = "test" :> Header "header" [String] :> QueryFlag "flag" :> Get '[JSON] Int
@@ -56,58 +59,57 @@ testApi = listFromAPI (Proxy :: Proxy LangX) (Proxy :: Proxy TestApi)
5659
5760listFromAPISpec :: Spec
5861listFromAPISpec = describe "listFromAPI" $ do
59− it "generates 4 endpoints for TestApi" $ do
60− length testApi `shouldBe` 4
61−
62− let [getReq, postReq, putReq, deleteReq] = testApi
63−
64− it "collects all info for get request" $ do
65− shouldBe getReq $ defReq
66− { _reqUrl = Url
67− [ Segment $ Static "test" ]
68− [ QueryArg ("flag", "boolX") Flag ]
69− , _reqMethod = "GET"
70− , _reqHeaders = [HeaderArg ("header", "listX of stringX")]
71− , _reqBody = Nothing
72− , _reqReturnType = "intX"
73− , _funcName = ["get", "test"]
74− }
75−
76− it "collects all info for post request" $ do
77− shouldBe postReq $ defReq
78− { _reqUrl = Url
79− [ Segment $ Static "test" ]
80− [ QueryArg ("param", "intX") Normal ]
81− , _reqMethod = "POST"
82− , _reqHeaders = []
83− , _reqBody = Just "listX of stringX"
84− , _reqReturnType = "voidX"
85− , _funcName = ["post", "test"]
86− }
87−
88− it "collects all info for put request" $ do
89− shouldBe putReq $ defReq
90− { _reqUrl = Url
91− [ Segment $ Static "test" ]
92− -- Shoud this be |intX| or |listX of intX| ?
93− [ QueryArg ("params", "listX of intX") List ]
94− , _reqMethod = "PUT"
95− , _reqHeaders = []
96− , _reqBody = Just "stringX"
97− , _reqReturnType = "voidX"
98− , _funcName = ["put", "test"]
99− }
100−
101− it "collects all info for delete request" $ do
102− shouldBe deleteReq $ defReq
103− { _reqUrl = Url
104− [ Segment $ Static "test"
105− , Segment $ Cap ("id", "intX") ]
106− []
107− , _reqMethod = "DELETE"
108− , _reqHeaders = []
109− , _reqBody = Nothing
110− , _reqReturnType = "voidX"
111− , _funcName = ["delete", "test", "by", "id"]
112− }
113−
62+ it "generates 4 endpoints for TestApi" $ do
63+ length testApi `shouldBe` 4
64+
65+ let [getReq, postReq, putReq, deleteReq] = testApi
66+
67+ it "collects all info for get request" $ do
68+ shouldBe getReq $ defReq
69+ { _reqUrl = Url
70+ [ Segment $ Static "test" ]
71+ [ QueryArg ("flag", "boolX") Flag ]
72+ , _reqMethod = "GET"
73+ , _reqHeaders = [HeaderArg ("header", "listX of stringX")]
74+ , _reqBody = Nothing
75+ , _reqReturnType = "intX"
76+ , _reqFuncName = ["get", "test"]
77+ }
78+
79+ it "collects all info for post request" $ do
80+ shouldBe postReq $ defReq
81+ { _reqUrl = Url
82+ [ Segment $ Static "test" ]
83+ [ QueryArg ("param", "intX") Normal ]
84+ , _reqMethod = "POST"
85+ , _reqHeaders = []
86+ , _reqBody = Just "listX of stringX"
87+ , _reqReturnType = "voidX"
88+ , _reqFuncName = ["post", "test"]
89+ }
90+
91+ it "collects all info for put request" $ do
92+ shouldBe putReq $ defReq
93+ { _reqUrl = Url
94+ [ Segment $ Static "test" ]
95+ -- Shoud this be |intX| or |listX of intX| ?
96+ [ QueryArg ("params", "listX of intX") List ]
97+ , _reqMethod = "PUT"
98+ , _reqHeaders = []
99+ , _reqBody = Just "stringX"
100+ , _reqReturnType = "voidX"
101+ , _reqFuncName = ["put", "test"]
102+ }
103+
104+ it "collects all info for delete request" $ do
105+ shouldBe deleteReq $ defReq
106+ { _reqUrl = Url
107+ [ Segment $ Static "test"
108+ , Segment $ Cap ("id", "intX") ]
109+ []
110+ , _reqMethod = "DELETE"
111+ , _reqHeaders = []
112+ , _reqBody = Nothing
113+ , _reqReturnType = "voidX"
114+ , _reqFuncName = ["delete", "test", "by", "id"]
115+ }
servant-js/src/Servant/JS/Angular.hs+1−1
@@ -128,7 +128,7 @@ generateAngularJSWith ngOptions opts req = "\n" <>
128128
129129 fsep = if hasService then ":" else " ="
130130
131− fname = namespace <> (functionNameBuilder opts $ req ^. funcName)
131+ fname = namespace <> (functionNameBuilder opts $ req ^. reqFuncName)
132132
133133 method = req ^. reqMethod
134134 url = if url' == "'" then "'/'" else url'
servant-js/src/Servant/JS/Axios.hs+1−1
@@ -116,7 +116,7 @@ generateAxiosJSWith aopts opts req = "\n" <>
116116 where
117117 hasNoModule = moduleName opts == ""
118118
119− fname = namespace <> (functionNameBuilder opts $ req ^. funcName)
119+ fname = namespace <> (functionNameBuilder opts $ req ^. reqFuncName)
120120
121121 method = T.toLower . decodeUtf8 $ req ^. reqMethod
122122 url = if url' == "'" then "'/'" else url'
servant-js/src/Servant/JS/Internal.hs+13−6
@@ -51,12 +51,19 @@ type JavaScriptGenerator = [Req] -> Text
5151-- customize the output
5252data CommonGeneratorOptions = CommonGeneratorOptions
5353 {
54− functionNameBuilder :: FunctionName -> Text -- ^ function generating function names
55− , requestBody :: Text -- ^ name used when a user want to send the request body (to let you redefine it)
56− , successCallback :: Text -- ^ name of the callback parameter when the request was successful
57− , errorCallback :: Text -- ^ name of the callback parameter when the request reported an error
58− , moduleName :: Text -- ^ namespace on which we define the foreign function (empty mean local var)
59− , urlPrefix :: Text -- ^ a prefix we should add to the Url in the codegen
54+ functionNameBuilder :: FunctionName -> Text
55+ -- ^ function generating function names
56+ , requestBody :: Text
57+ -- ^ name used when a user want to send the request body
58+ -- (to let you redefine it)
59+ , successCallback :: Text
60+ -- ^ name of the callback parameter when the request was successful
61+ , errorCallback :: Text
62+ -- ^ name of the callback parameter when the request reported an error
63+ , moduleName :: Text
64+ -- ^ namespace on which we define the foreign function (empty mean local var)
65+ , urlPrefix :: Text
66+ -- ^ a prefix we should add to the Url in the codegen
6067 }
6168
6269-- | Default options.
servant-js/src/Servant/JS/JQuery.hs+1−1
@@ -81,7 +81,7 @@ generateJQueryJSWith opts req = "\n" <>
8181 namespace = if (moduleName opts) == ""
8282 then "var "
8383 else (moduleName opts) <> "."
84− fname = namespace <> (functionNameBuilder opts $ req ^. funcName)
84+ fname = namespace <> (functionNameBuilder opts $ req ^. reqFuncName)
8585
8686 method = req ^. reqMethod
8787 url = if url' == "'" then "'/'" else url'
servant-js/src/Servant/JS/Vanilla.hs+1−1
@@ -93,7 +93,7 @@ generateVanillaJSWith opts req = "\n" <>
9393 namespace = if moduleName opts == ""
9494 then "var "
9595 else (moduleName opts) <> "."
96− fname = namespace <> (functionNameBuilder opts $ req ^. funcName)
96+ fname = namespace <> (functionNameBuilder opts $ req ^. reqFuncName)
9797
9898 method = req ^. reqMethod
9999 url = if url' == "'" then "'/'" else url'