Having
(Some(1), Some(2))
I expect to get
Some((1, 2))
and having
(Some(1), None)
I expect to get
None
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the fact that Scalaz 7 provides a
Bitraverseinstance for tuples and then sequence as usual (but withbisequenceinstead ofsequence):Unfortunately Scalaz 7 currently needs the type annotation here.
In a comment Yo Eight states that the type annotation will remain mandatory here. I’m not sure what his or her reasoning is, but it’s in fact perfectly easy to write your own wrapper that will provide any appropriately typed tuple with a
bisequencemethod and won’t require a type annotation:Now
(some(1), some("a")).bisequencewill compile just fine.I can’t think of a good reason Scalaz wouldn’t include something like this. Whether or not you want to add it in the meantime is a matter of taste, but there’s definitely no theoretical obstacle to letting the compiler do the typing here.