3 ms·
>It leads to recursion where iteration is more natural Viewing iteration as more 'natural' than a fold seems down to mostly taste. And hell, if you really want
by ImprobableTruth 6y ago
>It leads to recursion where iteration is more natural
Viewing iteration as more 'natural' than a fold seems down to mostly taste. And hell, if you really want iteration, you can easily get that in both effectful and non-effectul variants through monads.
>ask a functional programming zealot to implement an O(1) hash map in a pure way—they will usually stammer, try to move goal posts, before finally admitting it's not possible
Except that no one - not even Haskell zealots - will argue that you never need effects, but simply that effects should be encapsulated. In Haskell, nothing prevents you from using mutable state if you really need it and mutable hash tables can be easily implemented using something called functional state threads [1][2].
[1] https://www.microsoft.com/en-us/research/wp-content/uploads/1994/06/lazy-functional-state-threads.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/...
[2] http://hackage.haskell.org/package/hashtables-1.2.4.1 http://hackage.haskell.org/package/hashtables-1.2.4.1