Skip to content

Commit

Permalink
Make error messages more terse on Scala 2
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Feb 10, 2024
1 parent 874489b commit 6e55a7c
Show file tree
Hide file tree
Showing 25 changed files with 111 additions and 137 deletions.
12 changes: 5 additions & 7 deletions core/src/main/scala-2/cats/derived/applicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import shapeless.labelled._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Applicative[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Monoid
* it is a nested type λ[x => G[H[x]]] where G: Applicative and H: Applicative
* it is a generic case class where all fields have an Applicative instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Applicative for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Monoid
* nested type λ[x => G[H[x]]] where G: Applicative and H: Applicative
* generic case class where all fields form Applicative""")
trait MkApplicative[F[_]] extends Applicative[F]

object MkApplicative extends MkApplicativeDerivation {
Expand Down
12 changes: 5 additions & 7 deletions core/src/main/scala-2/cats/derived/apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import shapeless.labelled._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Apply[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Semigroup
* it is a nested type λ[x => G[H[x]]] where G: Apply and H: Apply
* it is a generic case class where all fields have an Apply instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Apply for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Semigroup
* nested type λ[x => G[H[x]]] where G: Apply and H: Apply
* generic case class where all fields form Apply""")
trait MkApply[F[_]] extends Apply[F]

object MkApply extends MkApplyDerivation {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2/cats/derived/commutativeMonoid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import util.VersionSpecific.{OrElse, Lazy}

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of CommutativeMonoid[A] where A = ${A}.
Make sure that A is a case class where all fields have a CommutativeMonoid instance.""")
@implicitNotFound("""Could not derive CommutativeMonoid for ${A}.
Make sure it is a case class where all fields form CommutativeMonoid.""")
trait MkCommutativeMonoid[A] extends CommutativeMonoid[A]

object MkCommutativeMonoid extends MkCommutativeMonoidDerivation {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2/cats/derived/commutativeSemigroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import util.VersionSpecific.{OrElse, Lazy}

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of CommutativeSemigroup[A] where A = ${A}.
Make sure that A is a case class where all fields have a CommutativeSemigroup instance.""")
@implicitNotFound("""Could not derive CommutativeSemigroup for ${A}.
Make sure it is a case class where all fields form CommutativeSemigroup.""")
trait MkCommutativeSemigroup[A] extends CommutativeSemigroup[A]

object MkCommutativeSemigroup extends MkCommutativeSemigroupDerivation {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala-2/cats/derived/consk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import shapeless._

import scala.annotation.implicitNotFound

@implicitNotFound("Could not derive an instance of ConsK[${F}]")
@implicitNotFound("Could not derive ConsK for ${F}")
trait MkConsK[F[_], G[_]] extends Serializable {
def cons[A](head: A, tail: G[A]): F[A]
}
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/contravariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Contravariant[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T]
* it is a nested type λ[x => G[H[x]]] where G: Functor and H: Contravariant
* it is a generic case class where all fields have a Contravariant instance
* it is a generic sealed trait where all subclasses have a Contravariant instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Contravariant for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T]
* nested type λ[x => G[H[x]]] where G: Functor and H: Contravariant
* generic case class where all fields form Contravariant
* generic sealed trait where all subclasses form Contravariant""")
trait MkContravariant[F[_]] extends Contravariant[F] {
def safeContramap[A, B](fa: F[A])(f: B => Eval[A]): Eval[F[B]]
def contramap[A, B](fa: F[A])(f: B => A): F[B] = safeContramap(fa)((b: B) => Eval.later(f(b))).value
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/empty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import util.VersionSpecific.{OrElse, Lazy}

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Empty[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have an Empty instance
* it is a sealed trait where exactly one subclass has an Empty instance""")
@implicitNotFound("""Could not derive Empty for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form Empty
* sealed trait where exactly one subclass form Empty""")
trait MkEmpty[A] extends Empty[A]

object MkEmpty extends MkEmptyDerivation {
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/emptyk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of EmptyK[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Empty
* it is a nested type λ[x => G[H[x]]] where G: EmptyK
* it is a nested type λ[x => G[H[x]]] where G: Pure and H: EmptyK
* it is a generic case class where all fields have an EmptyK instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive EmptyK for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Empty
* nested type λ[x => G[H[x]]] where G: EmptyK
* nested type λ[x => G[H[x]]] where G: Pure and H: EmptyK
* generic case class where all fields form EmptyK""")
trait MkEmptyK[F[_]] extends EmptyK[F]

object MkEmptyK extends MkEmptyKDerivation {
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/eq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import shapeless._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Eq[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have an Eq instance
* it is a sealed trait where all subclasses have an Eq instance""")
@implicitNotFound("""Could not derive Eq for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form Eq
* sealed trait where all subclasses form Eq""")
trait MkEq[A] extends Eq[A]

object MkEq extends MkEqDerivation {
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Foldable[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T]
* it is a nested type λ[x => G[H[x]]] where G: Foldable and H: Foldable
* it is a generic case class where all fields have a Foldable instance
* it is a generic sealed trait where all subclasses have a Foldable instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Foldable for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T]
* nested type λ[x => G[H[x]]] where G: Foldable and H: Foldable
* generic case class where all fields form Foldable
* generic sealed trait where all subclasses form Foldable""")
trait MkFoldable[F[_]] extends Foldable[F] {
def foldRight[A, B](fa: F[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B]
def safeFoldLeft[A, B](fa: F[A], b: B)(f: (B, A) => Eval[B]): Eval[B]
Expand Down
16 changes: 7 additions & 9 deletions core/src/main/scala-2/cats/derived/functor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Functor[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T]
* it is a nested type λ[x => G[H[x]]] where G: Functor and H: Functor
* it is a nested type λ[x => G[H[x]]] where G: Contravariant and H: Contravariant
* it is a generic case class where all fields have a Functor instance
* it is a generic sealed trait where all subclasses have a Functor instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Functor for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T]
* nested type λ[x => G[H[x]]] where G: Functor and H: Functor
* nested type λ[x => G[H[x]]] where G: Contravariant and H: Contravariant
* generic case class where all fields form Functor
* generic sealed trait where all subclasses form Functor""")
trait MkFunctor[F[_]] extends Functor[F] {
def safeMap[A, B](fa: F[A])(f: A => Eval[B]): Eval[F[B]]

Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/hash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package derived
import scala.annotation._
import scala.util.hashing.MurmurHash3

@implicitNotFound("""Could not derive an instance of Hash[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have a Hash instance
* it is a sealed trait where all subclasses have a Hash instance""")
@implicitNotFound("""Could not derive Hash for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form Hash
* sealed trait where all subclasses form Hash""")
trait MkHash[A] extends Hash[A]

object MkHash extends MkHashDerivation {
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Invariant[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T]
* it is a nested type λ[x => G[H[x]]] where G: Invariant and H: Invariant
* it is a generic case class where all fields have an Invariant instance
* it is a generic sealed trait where all subclasses have an Invariant instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Invariant for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T]
* nested type λ[x => G[H[x]]] where G: Invariant and H: Invariant
* generic case class where all fields form Invariant
* generic sealed trait where all subclasses form Invariant""")
trait MkInvariant[F[_]] extends Invariant[F] {
def safeImap[A, B](fa: F[A])(g: A => Eval[B])(f: B => Eval[A]): Eval[F[B]]
def imap[A, B](fa: F[A])(g: A => B)(f: B => A): F[B] =
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2/cats/derived/monoid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import util.VersionSpecific.{OrElse, Lazy}

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Monoid[A] where A = ${A}.
Make sure that A is a case class where all fields have a Monoid instance.""")
@implicitNotFound("""Could not derive Monoid for ${A}.
Make sure it is a case class where all fields form Monoid.""")
trait MkMonoid[A] extends Monoid[A]

object MkMonoid extends MkMonoidDerivation {
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/monoidk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of MonoidK[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Monoid
* it is a nested type λ[x => G[H[x]]] where G: MonoidK
* it is a nested type λ[x => G[H[x]]] where G: Applicative and H: MonoidK
* it is a generic case class where all fields have a MonoidK instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive MonoidK for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Monoid
* nested type λ[x => G[H[x]]] where G: MonoidK
* nested type λ[x => G[H[x]]] where G: Applicative and H: MonoidK
* generic case class where all fields form MonoidK""")
trait MkMonoidK[F[_]] extends MonoidK[F]

object MkMonoidK extends MkMonoidKDerivation {
Expand Down
12 changes: 5 additions & 7 deletions core/src/main/scala-2/cats/derived/nonEmptyTraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of NonEmptyTraverse[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a nested type λ[x => G[H[x]]] where G: NonEmptyTraverse and H: NonEmptyTraverse
* it is a generic case class where at least one field has a NonEmptyTraverse and the rest Traverse instances
* it is a generic sealed trait where all subclasses have a NonEmptyTraverse instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive NonEmptyTraverse for ${F}.
Make sure it satisfies one of the following conditions:
* nested type λ[x => G[H[x]]] where G: NonEmptyTraverse and H: NonEmptyTraverse
* generic case class where at least one field forms NonEmptyTraverse and the rest form Traverse
* generic sealed trait where all subclasses form NonEmptyTraverse""")
trait MkNonEmptyTraverse[F[_]] extends NonEmptyTraverse[F] with MkTraverse[F] with MkReducible[F] {
def safeNonEmptyTraverse[G[_]: Apply, A, B](fa: F[A])(f: A => Eval[G[B]]): Eval[G[F[B]]]

Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/order.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import shapeless._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Order[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have an Order instance
* it is a sealed trait with exactly one subclass that has an Order instance""")
@implicitNotFound("""Could not derive Order for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form Order
* sealed trait with exactly one subclass that forms Order""")
trait MkOrder[A] extends Order[A]

object MkOrder extends MkOrderDerivation {
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/partialOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import shapeless._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of PartialOrder[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have a PartialOrder instance
* it is a sealed trait where all subclasses have a PartialOrder instance""")
@implicitNotFound("""Could not derive PartialOrder for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form PartialOrder
* sealed trait where all subclasses form PartialOrder""")
trait MkPartialOrder[A] extends PartialOrder[A]

object MkPartialOrder extends MkPartialOrderDerivation {
Expand Down
12 changes: 5 additions & 7 deletions core/src/main/scala-2/cats/derived/pure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import shapeless._

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Pure[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Empty
* it is a nested type λ[x => G[H[x]]] where G: Pure and H: Pure
* it is a generic case class where all fields have a Pure instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Pure for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Empty
* nested type λ[x => G[H[x]]] where G: Pure and H: Pure
* generic case class where all fields form Pure""")
trait MkPure[F[_]] extends Pure[F]

object MkPure extends MkPureDerivation {
Expand Down
12 changes: 5 additions & 7 deletions core/src/main/scala-2/cats/derived/reducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Reducible[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a nested type λ[x => G[H[x]]] where G: Reducible and H: Reducible
* it is a generic case class where at least one field has a Reducible and the rest Foldable instances
* it is a generic sealed trait where all subclasses have a Reducible instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive Reducible for ${F}.
Make sure it satisfies one of the following conditions:
* nested type λ[x => G[H[x]]] where G: Reducible and H: Reducible
* generic case class where at least one field forms Reducible and the rest form Foldable
* generic sealed trait where all subclasses form Reducible""")
trait MkReducible[F[_]] extends Reducible[F] with MkFoldable[F] {
def safeReduceLeftTo[A, B](fa: F[A])(f: A => B)(g: (B, A) => Eval[B]): Eval[B]

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2/cats/derived/semigroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import util.VersionSpecific.{OrElse, Lazy}

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of Semigroup[A] where A = ${A}.
Make sure that A is a case class where all fields have a Semigroup instance.""")
@implicitNotFound("""Could not derive Semigroup for ${A}.
Make sure it is a case class where all fields form Semigroup.""")
trait MkSemigroup[A] extends Semigroup[A]

object MkSemigroup extends MkSemigroupDerivation {
Expand Down
14 changes: 6 additions & 8 deletions core/src/main/scala-2/cats/derived/semigroupk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import util.VersionSpecific.OrElse

import scala.annotation.implicitNotFound

@implicitNotFound("""Could not derive an instance of SemigroupK[F] where F = ${F}.
Make sure that F[_] satisfies one of the following conditions:
* it is a constant type λ[x => T] where T: Semigroup
* it is a nested type λ[x => G[H[x]]] where G: SemigroupK
* it is a nested type λ[x => G[H[x]]] where G: Apply and H: SemigroupK
* it is a generic case class where all fields have a SemigroupK instance
Note: using kind-projector notation - https://github.com/typelevel/kind-projector""")
@implicitNotFound("""Could not derive SemigroupK for ${F}.
Make sure it satisfies one of the following conditions:
* constant type λ[x => T] where T: Semigroup
* nested type λ[x => G[H[x]]] where G: SemigroupK
* nested type λ[x => G[H[x]]] where G: Apply and H: SemigroupK
* generic case class where all fields form SemigroupK""")
trait MkSemigroupK[F[_]] extends SemigroupK[F]

object MkSemigroupK extends MkSemigroupKDerivation {
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/cats/derived/show.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import scala.reflect.ClassTag
*
* See the test suite for more precise examples of what can and cannot be derived.
*/
@implicitNotFound("""Could not derive an instance of Show[A] where A = ${A}.
Make sure that A satisfies one of the following conditions:
* it is a case class where all fields have a Show instance
* it is a sealed trait where all subclasses have a Show instance""")
@implicitNotFound("""Could not derive Show for ${A}.
Make sure it satisfies one of the following conditions:
* case class where all fields form Show
* sealed trait where all subclasses form Show""")
trait MkShow[A] extends Show[A]

object MkShow extends MkShowDerivation {
Expand Down
Loading

0 comments on commit 6e55a7c

Please sign in to comment.