Is there any scala library that enriches basic scala tuples with monad syntax. Something similar to the Writer monad but adjusted for usage with tuples.
What I look for:
val pair = (2, "as")
pair >>= (a => point(a+1))
should equal to (3, "as")
. As well as
for (p <- pair) yield (p+1)
Yep, Scalaz provides monad instances for tuples (up to
Tuple8
):(Note that the type alias isn't necessary—it just makes using
point
a little easier.)