I know there is the mapM
function that applies a monadic action to a list and returns one monadic value containing a list. (See e.g.
What is the difference between mapM_ and mapM in Haskell?)
But I couldn't find any mapM
(or mapM_
or the underlying sequence
) function in idris2 (as of 0.6.0). The only thing I could find is a foldM.
Am I expected to roll out my own version of mapM
based on foldM
, or is it provided elsewhere in Idris2?
I think you want
traverse : Traversable t => Applicative f => (a -> f b) -> t a -> f (t b)
traverse_ : Applicative f => Foldable t => (a -> f b) -> t a -> f ()
Note sequence = traverse id
.