Hacker News new | ask | show | jobs
by momentoftop 1921 days ago
Haskell has strict limits on side-effects, but also abstracts these functions over the thing you're "forEaching." There, a reduce can't implement a map, because a map is required to return the same type of collection you put in. A reduce can only return an arbitrarily chosen collection (say, an Array).

And without side-effects, a map can't implement a forEach.

1 comments

> And without side-effects, a map can't implement a forEach.

Yes, it can, because without side effects, forEach is a NOP. That's not difficult to implement. As long as you don't do anything with the return value from map, you're there.