elm / http

Make HTTP requests in Elm
https://package.elm-lang.org/packages/elm/http/latest
BSD 3-Clause "New" or "Revised" License
155 stars 46 forks source link

Feature request: Type alias for the argument to Http.request #38

Closed JordyMoos closed 5 years ago

JordyMoos commented 6 years ago

Can we have a type alias for the argument going to Http.request?

Current:

request : { method : String, headers : List Header, url : String, body : Body, expect : Expect a, timeout : Maybe Time, withCredentials : Bool } -> Request a

Requested:

-- Sugestions for better namings are welcome
type alias Configuration =
    { method : String
    , headers : List Header
    , url : String
    , body : Body
    , expect : Expect a
    , timeout : Maybe Time
    , withCredentials : Bool
    }

request : Configuration -> Request a

Because now i have two choices:

  1. Put the whole record in all the functions that want to receive and return that record.

  2. Make an alias myself. But the issue is that i have one request handlers that use that. And also multiple interceptors that use that record. Creating the alias in the handler gives me circular dependencies. So the only option is to move the type alias into an other file where they both depend on.

I think it does make sense to create the alias in this package

process-bot commented 6 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 5 years ago

I think adding this type would detract from the clarity of the API because now to understand Http.request you have to start jumping around. So I get that it'd be convenient once you already know things, but the other concern is a bigger design goal.

JordyMoos commented 5 years ago

Ok, thanks for answering the issue