-
-
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
Add Parallel instance for Ior #2059
Conversation
(implicit E: Semigroup[E]): Parallel[Ior[E, ?], Ior[E, ?]] = new Parallel[Ior[E, ?], Ior[E, ?]] | ||
{ | ||
|
||
def parallel: Ior[E, ?] ~> Ior[E, ?] = FunctionK.id |
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.
these could be val
do avoid the reallocations, right?
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.
👍
@@ -17,7 +16,7 @@ import scala.collection.immutable.SortedSet | |||
class ParallelSuite extends CatsSuite with ApplicativeErrorForEitherTest { | |||
|
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.
can we test the parallel laws?
/~https://github.com/typelevel/cats/blob/master/laws/src/main/scala/cats/laws/ParallelLaws.scala
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.
Will do. 👍
} | ||
} | ||
} | ||
def monad: Monad[Ior[E, ?]] = Monad[Ior[E, ?]] |
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.
this can be a val
no?
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.
👍
def parallel: Ior[E, ?] ~> Ior[E, ?] = FunctionK.id | ||
def sequential: Ior[E, ?] ~> Ior[E, ?] = FunctionK.id | ||
|
||
def applicative: Applicative[Ior[E, ?]] = new Applicative[Ior[E, ?]] { |
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.
can be a val
no?
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.
👍
ca555db
to
d4f7d01
Compare
} | ||
} | ||
} | ||
lazy val monad: Monad[Ior[E, ?]] = Monad[Ior[E, ?]] |
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.
The monad instance isn't used for the parTraverse/parSequence
use cases on Ior
, so I've used a lazy val. All the other vals/defs are used.
6d9a2b8
to
f920117
Compare
Codecov Report
@@ Coverage Diff @@
## master #2059 +/- ##
==========================================
+ Coverage 94.64% 94.66% +0.01%
==========================================
Files 318 318
Lines 5363 5379 +16
Branches 109 131 +22
==========================================
+ Hits 5076 5092 +16
Misses 287 287
Continue to review full report at Codecov.
|
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.
Thanks very much Andy! 👍
👍 |
Adds a
Parallel
instance forIor
.The parallel instance is defined as
Parallel[Ior[E, ?], Ior[E, ?]]
without any wrapper type for a "parallel Ior". We could add one, if it's useful.