forked from typelevel/cats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace apS with RigidSelective typeclass
- Loading branch information
1 parent
37594b9
commit b56130d
Showing
5 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cats | ||
|
||
import simulacrum.typeclass | ||
import scala.annotation.implicitNotFound | ||
|
||
@implicitNotFound("Could not find an instance of RigidSelective for ${F}") | ||
@typeclass trait RigidSelective[F[_]] extends Selective[F] { | ||
override def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] = { | ||
val left: F[Either[A => B, B]] = map(ff)(Left(_)) | ||
val right: F[(A => B) => B] = map(fa)((a: A) => _(a)) | ||
select(left)(right) | ||
} | ||
} | ||
|
||
object RigidSelective { | ||
/* ======================================================================== */ | ||
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ | ||
/* ======================================================================== */ | ||
|
||
/** | ||
* Summon an instance of [[RigidSelective]] for `F`. | ||
*/ | ||
@inline def apply[F[_]](implicit instance: RigidSelective[F]): RigidSelective[F] = instance | ||
|
||
@deprecated("Use cats.syntax object imports", "2.2.0") | ||
object ops { | ||
implicit def toAllRigidSelectiveOps[F[_], A](target: F[A])(implicit tc: RigidSelective[F]): AllOps[F, A] { | ||
type TypeClassType = RigidSelective[F] | ||
} = new AllOps[F, A] { | ||
type TypeClassType = RigidSelective[F] | ||
val self: F[A] = target | ||
val typeClassInstance: TypeClassType = tc | ||
} | ||
} | ||
trait Ops[F[_], A] extends Serializable { | ||
type TypeClassType <: RigidSelective[F] | ||
def self: F[A] | ||
val typeClassInstance: TypeClassType | ||
} | ||
trait AllOps[F[_], A] extends Ops[F, A] with Selective.AllOps[F, A] { | ||
type TypeClassType <: RigidSelective[F] | ||
} | ||
trait ToRigidSelectiveOps extends Serializable { | ||
implicit def toRigidSelectiveOps[F[_], A](target: F[A])(implicit tc: RigidSelective[F]): Ops[F, A] { | ||
type TypeClassType = RigidSelective[F] | ||
} = new Ops[F, A] { | ||
type TypeClassType = RigidSelective[F] | ||
val self: F[A] = target | ||
val typeClassInstance: TypeClassType = tc | ||
} | ||
} | ||
@deprecated("Use cats.syntax object imports", "2.2.0") | ||
object nonInheritedOps extends ToRigidSelectiveOps | ||
|
||
/* ======================================================================== */ | ||
/* END OF SIMULACRUM-MANAGED CODE */ | ||
/* ======================================================================== */ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters