haskell-servant / servant-elm

Automatically derive Elm functions to query servant webservices
BSD 3-Clause "New" or "Revised" License
164 stars 48 forks source link

Improving support for polymorphic data types #61

Closed MikePors closed 4 years ago

MikePors commented 4 years ago

Hi!

First off: I'm a huge fan of this library.

In a recent project I encountered a problem where the generated API code for an endpoint which returned an (Either [String] Identifier) was being compiled to:

, expect = jsonDec(Either (List String) Identifier) which fails to compile. This pull request changes the output in this case to:

, expect = Http.expectJson toMsg ((jsonDecEither (Json.Decode.list (Json.Decode.string))) jsonDecIdentifier)

which matches with the generated decoder.

I built the repo referenced in #58 both as-is and using the changes from this repo and the compilation issue there seems to have gone away.

k-bx commented 4 years ago

This is fantastic! Thank you for the well-made PR.

k-bx commented 4 years ago

Released as 0.7.1