Stream: API design

Topic: Should Http.send! return a Result


view this post on Zulip Oskar Hahn (Jan 05 2025 at 11:35):

With the last release of basic-cli, the signature from Http.send! changed from Request => Result Response [HttpErr Err] to Request => Response ( I changed the old signature to use purity inference for better comparison).

Here is the related PR.

I could not find any discussion about this.

The old API distinct between an error that happens on the other computer (the webserver) and on your own computer. When the webserver returns an 500er, the function returns Ok Result{status: 500,...}. When the request can not be send (for example, there is no internet connection or the url can not be resolved), it returns an Err (HttpErr Err).

The new API always returns a Response. If a local error happens, it generates an Response object with the status 500 and uses the body field for the error message.

I liked the old API better. I think the Response should only represent the data, that is returned from the webserver. If an error happens on your own computer, it is not a Response, it is an error.

Would you consider changing it back to the old behavior?

view this post on Zulip Isaac Van Doren (Jan 05 2025 at 14:43):

I agree, I think it should return a result

view this post on Zulip Brendan Hansknecht (Jan 05 2025 at 15:01):

I feel like the change was a mistake

view this post on Zulip Brendan Hansknecht (Jan 05 2025 at 15:05):

Probably unified with some basic webserver apis

view this post on Zulip Brendan Hansknecht (Jan 05 2025 at 15:05):

Anyway, almost certainly should return a result

view this post on Zulip Anton (Jan 06 2025 at 10:32):

@Luke Boswell should be able to provide some good info here

view this post on Zulip Luke Boswell (Jan 06 2025 at 11:17):

I dont think it was a deliberate decision, just when unifying the API I must have overlooked it. Agree it makes more sense and we should change it back.

view this post on Zulip Luke Boswell (Jan 09 2025 at 07:06):

Implemented in https://github.com/roc-lang/basic-cli/pull/309

It's just one commit built on top of the latest breaking change... so the PR looks much bigger than it really is.

view this post on Zulip Luke Boswell (Jan 09 2025 at 07:06):

Needs some QA/testing at some point.

view this post on Zulip Ian McLerran (Jan 10 2025 at 15:14):

With this (and snake builtins) merged, is there any plan for a v0.19.0 on the near horizon?

view this post on Zulip Sam Mohr (Jan 10 2025 at 15:16):

We're making a whole lot of breaking changes soon with snake_case builtins, PNC syntax, and more

view this post on Zulip Sam Mohr (Jan 10 2025 at 15:16):

Once that drops, yes

view this post on Zulip Sam Mohr (Jan 10 2025 at 15:16):

Before that can happen, we want to finish with the easy breaking syntax changes

view this post on Zulip Sam Mohr (Jan 10 2025 at 15:16):

Aka ${interpolation} and || x + 123

view this post on Zulip Ian McLerran (Jan 10 2025 at 15:18):

Sweet, makes sense. :working_on_it:


Last updated: Jul 06 2025 at 12:14 UTC