christopherdavenport / cats-par

Abstract Type Member Parallel Instances

Website GitHub

cats-par Build Status Maven Central

Parallel has 2 types instead of 1 despite the second type generally having a canonical instance. This uses an abstract type member to allow using a single type rather than 2. As suggestions have made and plans in place for this in cats 2.0 this is an intermediate solution that will be deprecated upon its release.


Temporary Solution For typelevel/cats#2233

Initial Credit to @johnnek for the idea

Quick Start

To use cats-par in an existing SBT project with Scala 2.11 or a later version, add the following dependency to your build.sbt:

libraryDependencies += "io.chrisdavenport" %% "cats-par" % "<version>"


import cats._
import cats.implicits._
import cats.temp.par._

// Without This You Require a second type parameter and to continue, this second
// param up the entire call stack
def withoutPar[F[_]: Monad, G[_], A, C, D](as: List[A], f: A => Kleisli[F, C, D])
                                        (implicit P: Parallel[F, G]): Kleisli[F, C, List[D]] =

// With This It Is Just Another Contstraint on your Abstract F
def withPar[F[_]: Monad : Par, A, C, D](as: List[A], f: A => Kleisli[F, C, D]): Kleisli[F, C, List[D]] =