@@ -110,7 +110,7 @@ module Servant.JS
110110 , -- * Misc.
111111 listFromAPI
112112 , javascript
113− , LangJS
113+ , NoTypes
114114 , GenerateList(..)
115115 ) where
116116
@@ -123,37 +123,30 @@ import Servant.JS.Axios
123123import Servant.JS.Internal
124124import Servant.JS.JQuery
125125import Servant.JS.Vanilla
126−import Servant.Foreign (GenerateList(..), listFromAPI)
127−
128−-- Dummy type specifying target language
129−data LangJS
126+import Servant.Foreign (GenerateList(..), listFromAPI, NoTypes)
130127
131128-- | Generate the data necessary to generate javascript code
132129-- for all the endpoints of an API, as ':<|>'-separated values
133130-- of type 'AjaxReq'.
134−javascript :: HasForeign LangJS layout => Proxy layout -> Foreign layout
135−javascript p = foreignFor (Proxy :: Proxy LangJS) p defReq
131+javascript :: HasForeign NoTypes layout => Proxy layout -> Foreign layout
132+javascript p = foreignFor (Proxy :: Proxy NoTypes) p defReq
136133
137134-- | Directly generate all the javascript functions for your API
138135-- from a 'Proxy' for your API type. You can then write it to
139136-- a file or integrate it in a page, for example.
140−jsForAPI :: (HasForeign LangJS api, GenerateList (Foreign api))
137+jsForAPI :: (HasForeign NoTypes api, GenerateList (Foreign api))
141138 => Proxy api -- ^ proxy for your API type
142139 -> JavaScriptGenerator -- ^ js code generator to use (angular, vanilla js, jquery, others)
143140 -> Text -- ^ a text that you can embed in your pages or write to a file
144−jsForAPI p gen = gen (listFromAPI (Proxy :: Proxy LangJS) p)
141+jsForAPI p gen = gen (listFromAPI (Proxy :: Proxy NoTypes) p)
145142
146143-- | Directly generate all the javascript functions for your API
147144-- from a 'Proxy' for your API type using the given generator
148145-- and write the resulting code to a file at the given path.
149−writeJSForAPI :: (HasForeign LangJS api, GenerateList (Foreign api))
146+writeJSForAPI :: (HasForeign NoTypes api, GenerateList (Foreign api))
150147 => Proxy api -- ^ proxy for your API type
151148 -> JavaScriptGenerator -- ^ js code generator to use (angular, vanilla js, jquery, others)
152149 -> FilePath -- ^ path to the file you want to write the resulting javascript code into
153150 -> IO ()
154151writeJSForAPI p gen fp = writeFile fp (jsForAPI p gen)
155152
156−-- A catch all instance since JavaScript has no types.
157−instance HasForeignType LangJS a where
158− typeFor _ _ = empty
159−