haskell / play-haskell

Haskell Playground
123 stars 8 forks source link

Allow user input #49

Open ulysses4ever opened 1 month ago

ulysses4ever commented 1 month ago

Hey! This surely has come up before somewhere: how hard would it be to add the ability to read user's input? I guess the most annoying part is how to structure the UI?

There's a post on Discourse from someone learning Haskell and trying to get a LYAH example with input working... https://discourse.haskell.org/t/9859

tomsmeding commented 1 month ago

The primary issue is that the current execution model is completely batch-based: the program is sent to the server, which assigns a worker to compile and run it; the worker then sends back the output, which gets routed back to your browser. If the user input functionality is supposed to be interactive (just an additional field for an input blob which is sent to stdin as-is is not very useful, I think), this overturns this whole model. And if we are to support such an interactive session anyway, it would be even better if we could also have an interactive ghci session on the playground.

But all that takes a surprising amount of engineering, and raises questions around time allocation and spam control. That's why none of this has been implemented yet.

Unless you think an extra <textarea> for input to be made available on stdin is more useful than I thought?

ulysses4ever commented 1 month ago

just an additional field for an input blob which is sent to stdin as-is is not very useful

Agreed.

If the user input functionality is supposed to be interactive... this overturns this whole model.

Oh my, I keep forgetting about this model although I learned it at some point. Yeah, this sounds like a big undertaking.

I won't hold my breath then. But this ticket may be useful for future reference. Thanks!