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 Endo type alias for (A =>A) #2076

Merged
merged 4 commits into from Dec 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/function.scala
Expand Up @@ -88,7 +88,7 @@ private[instances] sealed trait Function1Instances extends Function1Instances0 {
def compose[A, B, C](f: B => C, g: A => B): A => C = f.compose(g)
}

implicit val catsStdMonoidKForFunction1: MonoidK[λ[α => Function1[α, α]]] =
implicit val catsStdMonoidKForFunction1: MonoidK[Endo] =
Category[Function1].algebraK
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/cats/package.scala
Expand Up @@ -32,6 +32,7 @@ package object cats {
* encodes pure unary function application.
*/
type Id[A] = A
type Endo[A] = A => A
implicit val catsInstancesForId: Bimonad[Id] with CommutativeMonad[Id] with Comonad[Id] with NonEmptyTraverse[Id] =
new Bimonad[Id] with CommutativeMonad[Id] with Comonad[Id] with NonEmptyTraverse[Id] {
def pure[A](a: A): A = a
Expand Down
1 change: 0 additions & 1 deletion tests/src/test/scala/cats/tests/CategorySuite.scala
Expand Up @@ -9,7 +9,6 @@ import cats.laws.discipline.eq.catsLawsEqForFn1

class CategorySuite extends CatsSuite {
val functionCategory = Category[Function1]
type Endo[A] = Function1[A, A]

checkAll("Category[Function1].algebraK", MonoidKTests[Endo](functionCategory.algebraK).monoidK[Int])
checkAll("Category[Function1].algebraK", SerializableTests.serializable(functionCategory.algebraK))
Expand Down
1 change: 0 additions & 1 deletion tests/src/test/scala/cats/tests/ComposeSuite.scala
Expand Up @@ -8,7 +8,6 @@ import cats.laws.discipline.eq.catsLawsEqForFn1

class ComposeSuite extends CatsSuite {
val functionCompose = Compose[Function1]
type Endo[A] = Function1[A, A]

checkAll("Compose[Function1].algebraK", SemigroupKTests[Endo](functionCompose.algebraK).semigroupK[Int])
checkAll("Compose[Function1].algebraK", SerializableTests.serializable(functionCompose.algebraK))
Expand Down
4 changes: 3 additions & 1 deletion tests/src/test/scala/cats/tests/FoldableSuite.scala
Expand Up @@ -9,7 +9,9 @@ import cats.instances.all._
import cats.data._
import cats.laws.discipline.arbitrary._

abstract class FoldableSuite[F[_]: Foldable](name: String)(implicit ArbFInt: Arbitrary[F[Int]], ArbFString: Arbitrary[F[String]]) extends CatsSuite with PropertyChecks {
abstract class FoldableSuite[F[_]: Foldable](name: String)(
implicit ArbFInt: Arbitrary[F[Int]],
ArbFString: Arbitrary[F[String]]) extends CatsSuite with PropertyChecks {

def iterator[T](fa: F[T]): Iterator[T]

Expand Down
6 changes: 4 additions & 2 deletions tests/src/test/scala/cats/tests/ReducibleSuite.scala
Expand Up @@ -2,7 +2,6 @@ package cats
package tests

import org.scalacheck.Arbitrary

import cats.data.NonEmptyList

class ReducibleSuiteAdditional extends CatsSuite {
Expand Down Expand Up @@ -71,7 +70,10 @@ class ReducibleSuiteAdditional extends CatsSuite {

}

abstract class ReducibleSuite[F[_]: Reducible](name: String)(implicit ArbFInt: Arbitrary[F[Int]], ArbFString: Arbitrary[F[String]]) extends FoldableSuite[F](name) {
abstract class ReducibleSuite[F[_]: Reducible](name: String)(
implicit ArbFInt: Arbitrary[F[Int]],
ArbFString: Arbitrary[F[String]]) extends FoldableSuite[F](name) {

def range(start: Long, endInclusive: Long): F[Long]

test(s"Reducible[$name].reduceLeftM stack safety") {
Expand Down