Re:Why Functional Programming Matters (1984) [pdf]
by marcosdumay on Thursday December 08, 2016 @09:29AM
(#13130441)
I 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.
Re:Why Functional Programming Matters (1984) [pdf]
by pka on Thursday December 08, 2016 @09:57AM
(#13130626)
> There are plenty of tricks you can not write on pure monads
This made me curious, could you list some?
Re:Why Functional Programming Matters (1984) [pdf]
by marcosdumay on Thursday December 08, 2016 @11:56AM
(#13131733)
Anything 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.
Re:Why Functional Programming Matters (1984) [pdf]
by pka on Thursday December 08, 2016 @03:21PM
(#13133909)
You 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.
Re:Why Functional Programming Matters (1984) [pdf]
by marcosdumay on Thursday December 08, 2016 @07:03PM
(#13135544)
You need it for doing what the OP is talking about.
Re:Why Functional Programming Matters (1984) [pdf]
by kazinator on Saturday December 10, 2016 @09:09PM
(#13149197)
ST 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).
You can do that in a pure language as well (i.e. ST monad.) Purity shouldn't be given up lightly.