-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request to Add CoflatMap Instance for Vector #818
Request to Add CoflatMap Instance for Vector #818
Conversation
Current coverage is
|
👍 |
@@ -23,6 +27,15 @@ trait VectorInstances { | |||
override def map2[A, B, Z](fa: Vector[A], fb: Vector[B])(f: (A, B) => Z): Vector[Z] = | |||
fa.flatMap(a => fb.map(b => f(a, b))) | |||
|
|||
def coflatMap[A, B](fa: Vector[A])(f: Vector[A] => B): Vector[B] = { | |||
@tailrec def loop(buf: ListBuffer[B], as: Vector[A]): Vector[B] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use VectorBuilder
instead of ListBuffer
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fthomas Yes, definitely. Done!
…plementation in order to use VectorBuilder instead of ListBuffer
👍 Thanks, @juanpedromoreno! |
…eclass-instance-to-vector Request to Add CoflatMap Instance for Vector
This PR brings the
CoflatMap
typeclass instance forVector
.Here an example session:
@non @ceedubs @adelbertc @milessabin Thanks for your consideration.