Skip to content
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

Merged
merged 2 commits into from
Dec 1, 2017
Merged

Conversation

andyscott
Copy link
Contributor

@andyscott andyscott commented Dec 1, 2017

Adds a Parallel instance for Ior.

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.

(implicit E: Semigroup[E]): Parallel[Ior[E, ?], Ior[E, ?]] = new Parallel[Ior[E, ?], Ior[E, ?]]
{

def parallel: Ior[E, ?] ~> Ior[E, ?] = FunctionK.id
Copy link
Contributor

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?

Copy link
Contributor Author

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 {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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, ?]]
Copy link
Contributor

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?

Copy link
Contributor Author

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, ?]] {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
}
lazy val monad: Monad[Ior[E, ?]] = Monad[Ior[E, ?]]
Copy link
Contributor Author

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.

@codecov-io
Copy link

codecov-io commented Dec 1, 2017

Codecov Report

Merging #2059 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
core/src/main/scala/cats/data/Ior.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f29dc72...f920117. Read the comment docs.

Copy link
Member

@LukaJCB LukaJCB left a 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! 👍

@johnynek
Copy link
Contributor

johnynek commented Dec 1, 2017

👍

@johnynek johnynek merged commit c51fe61 into typelevel:master Dec 1, 2017
@andyscott andyscott deleted the parallel-ior branch December 1, 2017 21:00
@kailuowang kailuowang added this to the 1.0.0 milestone Dec 1, 2017
@LukaJCB LukaJCB mentioned this pull request Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants