Just curious, because today was the first time I used mapAccumL (to do a Vigenere cipher where the cipher was stored as an infinite list of offsets), but I’ve had experience with mapAccumM, when it comes to more esoteric for-loop likes.
Is there a master list or a blog post on all the higher order functions Haskell uses where other languages might use for loops? Of course, this isn’t “all higher order functions”; ($) and (.), for instance are HoFs, and (>>=) on deterministic types isn’t loop-like.
It’d also be interesting to have a list of loop-like HOFs because it’d help us figure out if we’re missing any loop-like HOFs.
Point of this is, at a certain point in time, the HOF approach to loop-like behavior might become predominant and the older while / for loops might end up becoming regarded as smelly as goto. From MondayMorningHaskell, it appears that in C++, replacing your for loops with template metaprogramming loop replacement has already become a thing.
It’s also a useful riposte to FP-lite advocates who think FP simplifies to map, filter, and reduce. That is to say, the family of loop-like HOFs is far larger than simply map, filter, and reduce, and you probably should learn Haskell to understand what FP is really about.