4 ms·
World cannot be inspected in any meaningful way in this paradigm so it is fully deterministic because the differences aren't important. > So the (a, World) res
by Guvante 10y ago
World cannot be inspected in any meaningful way in this paradigm so it is fully deterministic because the differences aren't important.
> So the (a, World) result isnt fully deterministic from World. Even if you make each IO operation atomic, a chain of IO is still impure because the final (a, World) result depends on mutations introduced during execution.
It is fully deterministic from World but you cannot possibly describe a World so you can't supply it nor replicate it.
> So Haskell is "pure" when it comes to IO, but not in the way anyone except overly pedantic people mean the term.
You can't create a World so it is pedantic in that fashion but you are able to think of the functions as pure otherwise making integration easier.
A simple example is that IO happens in the correct order in Haskell because of the evaluation order not due to some external construct ensuring that lazy doesn't bite you.
- spion 10y agoWhich only goes to show that you can't apply real world reasoning to explain an academic concept. In this purely theoretical concept, World (which cannot be inspected) does contain the entirety of the world, including all other actions running in parallel, the current time and the state of every atom in the universe. So given the exact same state of the universe and assuming purely deterministic laws governing it (or the state of the world containing the future of the world too), yes, the action will produce the exact same output, because all other actions running in parallel or the things that will lead to the future actions are also part of that input World state. Thats my best attempt, and it still sucks! I bet someone will start wondering about the uncertainty principle there... So lets just use a free monad or thunks in a strict language function pureAction() { return function() { return impureAction(); } } function chain(pureAction, fnReturningOtherAction) { return function() { var impureResult = pureAction(); var newAction = fnReturningOtherAction(impureResult); return newAction(); } } function interpreter(mainAction) { return mainAction(); } Everything is pure, since all the functions don't do anything but return thunks for the interpreter to run. Except the interpreter which actually runs those. This isn't even a theoretical explanation - its exactly how PureScript's Eff works.