Haskell forLoopM and other utilities