|

zio.blocks.schema.comptime.Allows.|
sealed abstract class |[A <: Structural, B <: Structural] extends Structural

Union of two grammar nodes. Write in infix position: A | B.

In Scala 3 the native union type syntax A | B is also accepted and produces identical semantics with a more concise spelling. In Scala 2, write A `|` B in infix position.

For three-or-more alternatives, chain: A `|` B `|` C.

Type parameters

A

The left-hand grammar node alternative.

B

The right-hand grammar node alternative. Example (both Scala 2 infix and Scala 3 native produce the same grammar):

import zio.blocks.schema.comptime.Allows
import Allows._
// `Allows._` brings the `Map` grammar node into scope, so name Scala's `Map` as `Predef.Map`
case class Person(name: String, emails: List[String], phones: Predef.Map[String, String])
implicitly[Allows[Person, Record[Primitive | Sequence[Primitive] | Map[Primitive, Primitive]]]]

Attributes

Source
Allows.scala
Graph
Supertypes
class Structural
class Object
trait Matchable
class Any
In this article