IsType
zio.blocks.schema.comptime.Allows.IsType
sealed abstract class IsType[A] extends Structural
Nominal type predicate. IsType[A] is satisfied only when the Scala type being checked is exactly A (i.e. checked =:= A).
This is the building block for precise element-type constraints. The canonical use-case is constraining the element type of a polymorphic DSL method so that no separate type-alignment proof (e.g. a Containable type class) is needed:
import zio.blocks.schema.comptime.Allows
import Allows._
import zio.blocks.typeid.IsNominalType
trait ConditionExpression[From]
trait Column[From, To] {
// `To` must be a Set whose element type is exactly `A`.
// `IsNominalType[A]` ensures A is concrete at the call site.
def contains[A: IsNominalType](a: A)(implicit
ev: Allows[To, Sequence.Set[IsType[A]]]
): ConditionExpression[From]
}
IsType[A] can also replace specific primitive nodes as type aliases:
import zio.blocks.schema.comptime.Allows._
type MyInt = IsType[scala.Int] // equivalent to Primitive.Int semantically
Requires that A is a concrete nominal type. Combining with IsNominalType[A] (from zio-blocks-typeid) at the call site ensures the macro always sees a concrete A.
Type parameters
- A
-
The exact Scala type that must match.
Attributes
- Source
- Allows.scala
- Graph
-
- Supertypes
In this article