4 ms·
> This means we can exploit any efficiency trick an imperative program can do, including low-level stuff. The seasoned FP programmer will then proceed to encaps
by pka 10y ago
> This means we can exploit any efficiency trick an imperative program can do, including low-level stuff. The seasoned FP programmer will then proceed to encapsulate the efficiency trick in a abstract module such that the rest of the program doesn't have to worry about it.
You can do that in a pure language as well (i.e. ST monad.) Purity shouldn't be given up lightly.
- marcosdumay 10y agoI think he was talking about something like unsafePerformIO. There are plenty of tricks you can not write on pure monads, and there are many Haskell libs that use the unsafePerformIO trick too.
- pka 10y ago> There are plenty of tricks you can not write on pure monads This made me curious, could you list some?
- marcosdumay 10y agoAnything that needs rewriting a memory address without losing time by allocation and garbage collection. Handling IO exceptions and masking them as different errors. Thread, process, or machine coordination in parallel execution.
- pka 10y agoYou don't need unsafePerformIO for any of these. > Anything that needs rewriting a memory address without losing time by allocation and garbage collection. ST gives you mutable references. Or just use IO.
- marcosdumay 10y agoYou need it for doing what the OP is talking about.
- kazinator 10y agoST monad is not state; it's a convoluted way of threading a value through a chain of functions. State means we put the value into the same memory location (or CPU register, or piece of tape or whatever).
- pka 10y agoST is exactly that. You probably mean the State monad.