Can the style here be improved/more idiomatic?
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.11.0/SY4WWMhWQ9NvQgvIthcv15AUeA7rAIJHAHgiaSHGhdY.tar.br" }
import pf.Http
import pf.Task exposing [Task]
import pf.Stdout
import pf.Stderr
main =
request = {
method: Get,
headers: [],
url: "http://localhost:8080",
mimeType: "",
body: [],
timeout: TimeoutMilliseconds 5000,
}
sendResult =
Http.send request
|> Task.result!
processedSendResult =
Result.try sendResult Http.handleStringResponse
when processedSendResult is
Ok body ->
Stdout.line "Response body: $(body)."
Err err ->
Stderr.line (Inspect.toStr err)
I think I would use something like
when Http.send request |> Task.result |> Task.map! Http.handleStringResponse is
, though I'll caveat that by saying that I'm on my phone and havent tested it or checked the types work.
Thanks Luke, I'll give that a try :)
Last updated: Jul 06 2025 at 12:14 UTC