The foldM function is analogous to foldl, except that its result
is encapsulated in a monad. Note that foldM works from
left-to-right over the list arguments. This could be an issue where
(>>) and the "folded function" are not commutative.