Note that the functions mapM and sequence generalize Prelude
functions of the same names from lists to any Traversable functor.
To avoid ambiguity, either import the Prelude hiding these names
or qualify uses of these function names with an alias for this module.

The mapAccumL function behaves like a combination of fmap
and foldl; it applies a function to each element of a structure,
passing an accumulating parameter from left to right, and returning
a final value of this accumulator together with the new structure.

The mapAccumR function behaves like a combination of fmap
and foldr; it applies a function to each element of a structure,
passing an accumulating parameter from right to left, and returning
a final value of this accumulator together with the new structure.