Skip to content

Commit

Permalink
Run Simulacrum Scalafix rules and format
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Dec 4, 2019
1 parent 749ffd9 commit a6a0eb3
Show file tree
Hide file tree
Showing 50 changed files with 2,206 additions and 17 deletions.
38 changes: 37 additions & 1 deletion alleycats-core/src/main/scala/alleycats/ConsK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package alleycats

import cats.SemigroupK
import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait ConsK[F[_]] {
@implicitNotFound("Could not find an instance of ConsK for ${F}")
@typeclass trait ConsK[F[_]] extends Serializable {
def cons[A](hd: A, tl: F[A]): F[A]
}

Expand All @@ -12,4 +14,38 @@ object ConsK {
new ConsK[F] {
def cons[A](hd: A, tl: F[A]): F[A] = s.combineK(p.pure(hd), tl)
}

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[ConsK]] for `F`.
*/
@inline def apply[F[_]](implicit instance: ConsK[F]): ConsK[F] = instance

trait Ops[F[_], A] {
type TypeClassType <: ConsK[F]
def self: F[A]
val typeClassInstance: TypeClassType
}
trait AllOps[F[_], A] extends Ops[F, A]
trait ToConsKOps {
implicit def toConsKOps[F[_], A](target: F[A])(implicit tc: ConsK[F]): Ops[F, A] {
type TypeClassType = ConsK[F]
} = new Ops[F, A] {
type TypeClassType = ConsK[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToConsKOps
object ops {
implicit def toAllConsKOps[F[_], A](target: F[A])(implicit tc: ConsK[F]): AllOps[F, A] {
type TypeClassType = ConsK[F]
} = new AllOps[F, A] {
type TypeClassType = ConsK[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
}
40 changes: 39 additions & 1 deletion alleycats-core/src/main/scala/alleycats/Empty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import cats.{Eq, Monoid}
import cats.syntax.eq._

import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait Empty[A] {
@implicitNotFound("Could not find an instance of Empty for ${A}")
@typeclass trait Empty[A] extends Serializable {
def empty: A

def isEmpty(a: A)(implicit ev: Eq[A]): Boolean =
Expand All @@ -20,6 +22,42 @@ object Empty extends EmptyInstances0 {
new Empty[A] { lazy val empty: A = a }

def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T]

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[Empty]] for `A`.
*/
@inline def apply[A](implicit instance: Empty[A]): Empty[A] = instance

trait Ops[A] {
type TypeClassType <: Empty[A]
def self: A
val typeClassInstance: TypeClassType
def isEmpty(implicit ev: Eq[A]): Boolean = typeClassInstance.isEmpty(self)(ev)
def nonEmpty(implicit ev: Eq[A]): Boolean = typeClassInstance.nonEmpty(self)(ev)
}
trait AllOps[A] extends Ops[A]
trait ToEmptyOps {
implicit def toEmptyOps[A](target: A)(implicit tc: Empty[A]): Ops[A] {
type TypeClassType = Empty[A]
} = new Ops[A] {
type TypeClassType = Empty[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToEmptyOps
object ops {
implicit def toAllEmptyOps[A](target: A)(implicit tc: Empty[A]): AllOps[A] {
type TypeClassType = Empty[A]
} = new AllOps[A] {
type TypeClassType = Empty[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
}

private[alleycats] trait EmptyInstances0 extends compat.IterableEmptyInstance with EmptyInstances1
Expand Down
41 changes: 40 additions & 1 deletion alleycats-core/src/main/scala/alleycats/EmptyK.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
package alleycats

import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait EmptyK[F[_]] { self =>
@implicitNotFound("Could not find an instance of EmptyK for ${F}")
@typeclass trait EmptyK[F[_]] extends Serializable { self =>
def empty[A]: F[A]

def synthesize[A]: Empty[F[A]] =
new Empty[F[A]] {
def empty: F[A] = self.empty[A]
}
}

object EmptyK {

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[EmptyK]] for `F`.
*/
@inline def apply[F[_]](implicit instance: EmptyK[F]): EmptyK[F] = instance

trait Ops[F[_], A] {
type TypeClassType <: EmptyK[F]
def self: F[A]
val typeClassInstance: TypeClassType
}
trait AllOps[F[_], A] extends Ops[F, A]
trait ToEmptyKOps {
implicit def toEmptyKOps[F[_], A](target: F[A])(implicit tc: EmptyK[F]): Ops[F, A] {
type TypeClassType = EmptyK[F]
} = new Ops[F, A] {
type TypeClassType = EmptyK[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToEmptyKOps
object ops {
implicit def toAllEmptyKOps[F[_], A](target: F[A])(implicit tc: EmptyK[F]): AllOps[F, A] {
type TypeClassType = EmptyK[F]
} = new AllOps[F, A] {
type TypeClassType = EmptyK[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
}
39 changes: 38 additions & 1 deletion alleycats-core/src/main/scala/alleycats/Extract.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package alleycats
import cats.{CoflatMap, Comonad}

import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait Extract[F[_]] {
@implicitNotFound("Could not find an instance of Extract for ${F}")
@typeclass trait Extract[F[_]] extends Serializable {
def extract[A](fa: F[A]): A
}

Expand All @@ -22,4 +24,39 @@ object Extract {
override def map[A, B](fa: F[A])(f: A => B): F[B] = cf.map(fa)(f)
def coflatMap[A, B](fa: F[A])(f: F[A] => B): F[B] = cf.coflatMap(fa)(f)
}

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[Extract]] for `F`.
*/
@inline def apply[F[_]](implicit instance: Extract[F]): Extract[F] = instance

trait Ops[F[_], A] {
type TypeClassType <: Extract[F]
def self: F[A]
val typeClassInstance: TypeClassType
def extract: A = typeClassInstance.extract[A](self)
}
trait AllOps[F[_], A] extends Ops[F, A]
trait ToExtractOps {
implicit def toExtractOps[F[_], A](target: F[A])(implicit tc: Extract[F]): Ops[F, A] {
type TypeClassType = Extract[F]
} = new Ops[F, A] {
type TypeClassType = Extract[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToExtractOps
object ops {
implicit def toAllExtractOps[F[_], A](target: F[A])(implicit tc: Extract[F]): AllOps[F, A] {
type TypeClassType = Extract[F]
} = new AllOps[F, A] {
type TypeClassType = Extract[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
}
40 changes: 39 additions & 1 deletion alleycats-core/src/main/scala/alleycats/One.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package alleycats
import cats.Eq
import cats.syntax.eq._
import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait One[A] {
@implicitNotFound("Could not find an instance of One for ${A}")
@typeclass trait One[A] extends Serializable {
def one: A

def isOne(a: A)(implicit ev: Eq[A]): Boolean =
Expand All @@ -17,4 +19,40 @@ import simulacrum.typeclass
object One {
def apply[A](a: => A): One[A] =
new One[A] { lazy val one: A = a }

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[One]] for `A`.
*/
@inline def apply[A](implicit instance: One[A]): One[A] = instance

trait Ops[A] {
type TypeClassType <: One[A]
def self: A
val typeClassInstance: TypeClassType
def isOne(implicit ev: Eq[A]): Boolean = typeClassInstance.isOne(self)(ev)
def nonOne(implicit ev: Eq[A]): Boolean = typeClassInstance.nonOne(self)(ev)
}
trait AllOps[A] extends Ops[A]
trait ToOneOps {
implicit def toOneOps[A](target: A)(implicit tc: One[A]): Ops[A] {
type TypeClassType = One[A]
} = new Ops[A] {
type TypeClassType = One[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToOneOps
object ops {
implicit def toAllOneOps[A](target: A)(implicit tc: One[A]): AllOps[A] {
type TypeClassType = One[A]
} = new AllOps[A] {
type TypeClassType = One[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
}
38 changes: 37 additions & 1 deletion alleycats-core/src/main/scala/alleycats/Pure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package alleycats

import cats.{Applicative, FlatMap, Monad}
import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait Pure[F[_]] {
@implicitNotFound("Could not find an instance of Pure for ${F}")
@typeclass trait Pure[F[_]] extends Serializable {
def pure[A](a: A): F[A]
}

Expand All @@ -22,4 +24,38 @@ object Pure {
def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B] = fm.flatMap(fa)(f)
def tailRecM[A, B](a: A)(f: (A) => F[Either[A, B]]): F[B] = fm.tailRecM(a)(f)
}

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[Pure]] for `F`.
*/
@inline def apply[F[_]](implicit instance: Pure[F]): Pure[F] = instance

trait Ops[F[_], A] {
type TypeClassType <: Pure[F]
def self: F[A]
val typeClassInstance: TypeClassType
}
trait AllOps[F[_], A] extends Ops[F, A]
trait ToPureOps {
implicit def toPureOps[F[_], A](target: F[A])(implicit tc: Pure[F]): Ops[F, A] {
type TypeClassType = Pure[F]
} = new Ops[F, A] {
type TypeClassType = Pure[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToPureOps
object ops {
implicit def toAllPureOps[F[_], A](target: F[A])(implicit tc: Pure[F]): AllOps[F, A] {
type TypeClassType = Pure[F]
} = new AllOps[F, A] {
type TypeClassType = Pure[F]
val self: F[A] = target
val typeClassInstance: TypeClassType = tc
}
}
}
40 changes: 39 additions & 1 deletion alleycats-core/src/main/scala/alleycats/Zero.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import cats.Eq
import cats.syntax.eq._

import simulacrum.typeclass
import scala.annotation.implicitNotFound

@typeclass trait Zero[A] {
@implicitNotFound("Could not find an instance of Zero for ${A}")
@typeclass trait Zero[A] extends Serializable {
def zero: A

def isZero(a: A)(implicit ev: Eq[A]): Boolean =
Expand All @@ -18,4 +20,40 @@ import simulacrum.typeclass
object Zero {
def apply[A](a: => A): Zero[A] =
new Zero[A] { lazy val zero: A = a }

/****************************************************************************
* THE REST OF THIS OBJECT IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! *
****************************************************************************/
/**
* Summon an instance of [[Zero]] for `A`.
*/
@inline def apply[A](implicit instance: Zero[A]): Zero[A] = instance

trait Ops[A] {
type TypeClassType <: Zero[A]
def self: A
val typeClassInstance: TypeClassType
def isZero(implicit ev: Eq[A]): Boolean = typeClassInstance.isZero(self)(ev)
def nonZero(implicit ev: Eq[A]): Boolean = typeClassInstance.nonZero(self)(ev)
}
trait AllOps[A] extends Ops[A]
trait ToZeroOps {
implicit def toZeroOps[A](target: A)(implicit tc: Zero[A]): Ops[A] {
type TypeClassType = Zero[A]
} = new Ops[A] {
type TypeClassType = Zero[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
object nonInheritedOps extends ToZeroOps
object ops {
implicit def toAllZeroOps[A](target: A)(implicit tc: Zero[A]): AllOps[A] {
type TypeClassType = Zero[A]
} = new AllOps[A] {
type TypeClassType = Zero[A]
val self: A = target
val typeClassInstance: TypeClassType = tc
}
}
}
Loading

0 comments on commit a6a0eb3

Please sign in to comment.