Comments (8)
Looks like in the latest version of servant.foreign (0.16 as of writing) there is now support for this, though it still just uses the generated names (which tbh I'm fine with).
Version 0.16 isn't part of any stack lts yet though, so what I did was copy this into my code:
-- Taken from https://hackage.haskell.org/package/servant-foreign-0.16/docs/src/Servant.Foreign.Internal.html#line-518
-- But that is only available on servant-foreign 0.16, which is not in any stackage lts yet
instance HasForeign lang ftype (ToServantApi r) => HasForeign lang ftype (NamedRoutes r) where
type Foreign ftype (NamedRoutes r) = Foreign ftype (ToServantApi r)
foreignFor lang ftype Proxy req =
foreignFor lang ftype (Proxy :: Proxy (ToServantApi r)) req
And then updated my generateElmModuleWith ...
to:
generateElmModuleWith
...
(Proxy :: Proxy (ToServantApi Web.ApiRoutes))
(Added the ToServantApi
there too essentially).
from servant-elm.
My guess is that you're missing the mode
parameter on you API? My ApiRoutes
looks like this:
data ApiRoutes mode = ApiRoutes
{ ping :: mode :- "ping" :> Get '[JSON] String,
...
}
deriving (Generic)
I also have type Api = NamedRoutes ApiRoutes
but that's not the one I used ToServantApi
on.
from servant-elm.
Sorry for that, thanks a lot!
from servant-elm.
An obvious issue is that records fields can have duplicate names accross different modules. This would mean that we would still need to speciy the path (possibly of other names) in the names of the generated functions.
from servant-elm.
This is also blocked by servant-foreign not supporting this, so you should probably create an issue there.
from servant-elm.
I see, thanks, I created an issue there: haskell-servant/servant#1673
from servant-elm.
I'm not sure I get it, I have this error:
• Expected kind ‘Type -> Type’, but ‘API’ has kind ‘Type’
• In the first argument of ‘ToServantApi’, namely ‘API’
In the first argument of ‘Proxy’, namely ‘(ToServantApi API)’
In an expression type signature: Proxy (ToServantApi API)
|
42 | (Proxy :: Proxy (ToServantApi API))
| ^^^
Any idea what's going on?
from servant-elm.
Related Issues (20)
- Support generate elm api as HttpBuilder ?
- newtype encoding for query param does not match decoding by Servant
- servant-elm-0.4.0.1 test suite failure with servant-0.13 HOT 2
- Use elm-bridge instead of elm-export?
- Creating output directory automatically HOT 2
- Double `Maybe` for a QueryParam? HOT 1
- Upgrade to 0.19 HOT 3
- Expose url construction as an elm function
- Transfer repo to @haskell-servant HOT 9
- Generate BookId instead of (Key Book) for persistent's type aliases HOT 2
- Upgrade README docs according to 0.6.0.0 changes HOT 1
- Clarify that servant-elm does support elm/http 2.0.0 HOT 4
- Don't add a "query_" prefix to query params
- When query param is a bool, Elm code attempts to use String.fromInt on it HOT 5
- generating elm for polymorphic data type and type synonym is broken
- test suite failure with servant-0.18.2 HOT 1
- Custom Aeson instances HOT 1
- Looking for maintainers HOT 6
- Request to release version 0.7.3 that includes fix of broken tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from servant-elm.