News for hackers. Stuff that matters.
Re:Why do our programs need to read input and write output? by millstone on Sunday October 08, 2017 @01:48PM (#15429144)
Say the user clicks somewhere in my program’s window. How does my program discover the location of the click without reading some input?
Re:Why do our programs need to read input and write output? by tree_of_item on Sunday October 08, 2017 @01:54PM (#15429168)
As one example, the program might be written in model-view-controller style:

* Your "model" is a type `Model`.

* Your "view" is a function of type `Model -> Display`.

* Your "controller" is a function of type `(Model * Event) -> Model`.

So you don't need to perform IO to get the mouse click, since your program definition was already setup to handle incoming events. The runtime is responsible for feeding your controller events to get a new model, then running your view on the new model to create a display, then actually rendering that display.

Re:Why do our programs need to read input and write output? by Gabriel439 on Sunday October 08, 2017 @02:08PM (#15429218)
To clarify: the idea is that both the view and controller are built into the interpreter. The interpreted program builds the model and is written in a a purely functional and effect-free language
Re:Why do our programs need to read input and write output? by JetSpiegel on Sunday October 08, 2017 @03:10PM (#15429463)
Isn't that just pushing the side-effects to the runtime? What does it achieve?
Re:Why do our programs need to read input and write output? by tree_of_item on Sunday October 08, 2017 @03:13PM (#15429478)
It achieves the goal of making your code side-effect free. The explicit goal of these sorts of projects is to push the side-effects to the very edge of the stack.