Executing HTTP requests in elm repl?

Is there a way to execute and print the result of an Http.Request from inside the REPL? Such a thing would be useful to me for developing core types, decoders, and request helpers for an app without/separately from actually building a Browser app.

I suspect the answer is that this is currently impossible, and that for it to be not-impossible would rely on extensive future work and decision making about how to implement non-Browser platforms for elm as a prerequisite to an effectful REPL.

Yep that’s exactly right!

When you type something into the REPL it gathers up the full history of expressions you’ve entered, compiles them, runs the resulting JS as a Node script, and prints the result of the last expression. There’s no long running process to wait for asynchronous responses to return. It’s all synchronous.

I guess to do this it would need a Msg type to return a value, and in the REPL you’d need a way to dynamically redefine that type as you go, as you think of new messages? That might be hard to express in Elm. Or maybe there’d be just one Msg constructor that prints everything it receives? But I’m not sure how you’d chain Tasks.

So yeah I think Elm’s restrictions and guarantees probably make this hard. There’d be a lot of design decisions to be made to do it. I’ve never seen it being mentioned as a priority.

Ellie is probably the best place to experiment with things like this!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.