2 ms·
i see, those are definitely ways to do it... > There is still state in the running program, something is remembering all clicks to the button, but your UI logi
by andrekandre 6y ago
i see, those are definitely ways to do it...
> There is still state in the running program, something is remembering all clicks to the button, but your UI logic is pure.
could this be solved by having the whole app be some kind of recursive function that passes the events as a list that gets appended to over time?
then it could remain completely pure?
- didibus 6y agoYes that's exactly how it would be bootstrapped, but that still will leave the IO itself, and that part will be impure. So as you recurse, even if you carry over the events by passing them back, you'll need to have a part where you block and wait on external input from the user, and that is inherently an impure operation. You can keep extracting the IO out, but you can't get rid of it. So Haskell or Elm would basically do the "dirty impure" IO on your behalf, so in your code it wouldn't even seem like you're doing impure IO, but your running program still will, just it'll be done by the Haskell/Elm runtime on your behalf. Or if you're not using those languages, the best you can do is extract it to your top level function.