3 ms·
The question is asked providing the entire implementation of the respective sum functions in terms of primitives. There's no room for unsafePerformIO in the Has
by masklinn 10y ago
The question is asked providing the entire implementation of the respective sum functions in terms of primitives. There's no room for unsafePerformIO in the Haskell code (assuming prelude's `(+)` and `foldl`).
There could be if the Haskell version was typed on `Num a`, but it's typed on `Int`, which is a standard type with a known pure Num instance.
- bbcbasic 10y agoOk sure but I was meaning in general. Anyway pass in (repeat 0) and you get a side effect. :-)
- masklinn 10y ago> Ok sure but I was meaning in general. So was I, the article denotes that JS functions can be impure because values carry a "purity stigma" (the value itself can embed impure operations in its manipulation or evaluation). > Anyway pass in (repeat 0) and you get a side effect. :-) That's a good point, laziness also carries a "purity stigma". You could actually sneak in unsafePerformIO with an unfold or a lazy list construction.
- tel 10y agoHaskell is well-known not to be pure in supporting non-terminating computation.
- lmm 10y agoSure, that's an issue with Haskell - much better to use Idris.