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

Incoherent parameter order #30

Open hadronized opened 7 years ago

hadronized commented 7 years ago

I have an endpoint that mixes both ReqBody and QueryParams:

filterOccurrences :: [Tag] -> [QueryFilter] -> …

However, the generated Elm reverses the order:

postOccurrencesFiltered : List (QueryFilter) -> List (String) -> Http.Request …

It’s clearly not a big deal, but it’s confusing and error prone (I can’t imagine the madness if both the arguments resolve to the exact same type).

mattjbray commented 6 years ago

The functions generated by servant-elm take parameters in the following order:

  1. Headers
  2. URL path captures
  3. URL query args
  4. Request body

Since we use servant-foreign's listFromAPI, we don't know the order in which they were defined in the original type.

Perhaps this would be a valuable addition to servant-foreign - I'll put something together.