-
Notifications
You must be signed in to change notification settings - Fork 64
/
DerivedBand.scala
32 lines (24 loc) · 945 Bytes
/
DerivedBand.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cats.derived
import cats.kernel.Band
import shapeless3.deriving.K0.*
import scala.annotation.*
import scala.compiletime.*
@implicitNotFound("""Could not derive Band for ${A}.
Make sure it is a case class where all fields form Band.""")
type DerivedBand[A] = Derived[Band[A]]
object DerivedBand:
type Or[A] = Derived.Or[Band[A]]
@nowarn("msg=unused import")
inline def apply[A]: Band[A] =
import DerivedBand.given
summonInline[DerivedBand[A]].instance
@nowarn("msg=unused import")
inline def strict[A]: Band[A] =
import Strict.given
summonInline[DerivedBand[A]].instance
given product[A](using inst: => ProductInstances[Or, A]): DerivedBand[A] =
Strict.product(using inst.unify)
trait Product[F[x] <: Band[x], A: ProductInstancesOf[F]] extends DerivedSemigroup.Product[F, A], Band[A]
object Strict:
given product[A: ProductInstancesOf[Band]]: DerivedBand[A] =
new Product[Band, A] {}