purescript-foldable-traversable icon indicating copy to clipboard operation
purescript-foldable-traversable copied to clipboard

added traverseM

Open dwhitney opened this issue 6 years ago • 2 comments

I find myself using the following so often, that I assumed the function should already exist, but it doesn't: join <$> traverse fn traversable

I've inquired on slack about it, I have see someone else inquire about it (i-am-the-slime), and someone else inquired on reddit: https://www.reddit.com/r/purescript/comments/aq31gu/i_feel_like_this_is_probably_a_standard_function/

@puffnfresh showed us that it exists in Scalaz: https://github.com/scalaz/scalaz/blob/series/7.3.x/core/src/main/scala/scalaz/Traverse.scala#L68

So I decided to make this PR to add it to Data.Traversable

dwhitney avatar Feb 14 '19 17:02 dwhitney

If we're adding this, we should also add a sequenceM at the same time (where sequenceM would be \x -> join <$> sequence x). The example you give here would probably serve better as an example for sequenceM. Also I think the definitions should be included in the docs.

hdgarrood avatar Feb 23 '19 20:02 hdgarrood

Does this pass the Fairbairn Threshold? I think we should add it, but thought it's worth discussing.

JordanMartinez avatar Oct 15 '20 00:10 JordanMartinez