Is there an example of the Haskell analog 'mapM with IO' in arrow core or arrow fx ?
I want to build a List (or Traversable, ..) of IO actions, and run them by mapM'ing over that data.
is it only foldMapM from ListKFoldable ? or is there a more compact way somewhere ?
s
simon.vergauwen
05/29/2020, 11:18 AM
You’re looking to transform
List<A>
into
IO<B>
using
(B, A) -> B
?
simon.vergauwen
05/29/2020, 11:19 AM
In that case you’d want to use
foldMapM
from
Foldable
yes.
Copy code
listOf(1, 2, 3).foldMapM(IO.monad()) { acc, i ->
IO { acc + i }
} // IO(6)