final case class OneOfSchema[P[_], F[_], I](alts: NonEmptyList[Alt[F, I, _]], discriminator: Option[String] = None) extends SchemaF[P, F, I] with Product with Serializable
Constructor that enables creation of schema for sum types.
Each constructor of the sum type I
is represented as a member of the list of alternatives. Each alternative defines
a prism between a single constructor of the sum type, and an underlying type describing the arguments demanded by
that constructor.
Consider the following sum type. The first constructor takes no arguments; the second takes two.
sealed trait Role case object User extends Role case class Administrator(department: String, subordinateCount: Int) extends Role
A schema value for this type looks like:
val roleSchema = oneOf( alt[Unit, Prim, Role, Unit]( "user", Schema.empty, (_: Unit) => User, { case User => Some(Unit) case _ => None } ) :: alt[Unit, Prim, Role, Administrator]( "administrator", rec[Prim, Administrator]( ( required("department", Prim.str, (_: Administrator).department), required("subordinateCount", Prim.int, (_: Administrator).subordinateCount) ).mapN(Administrator.apply) ), identity, { case a @ Administrator(_, _) => Some(a) case _ => None } ) :: Nil )
- P
The GADT type constructor for a sum type which defines the set of primitive types used in the schema.
- F
The functor through which the structure of the schema will be interpreted. This will almost always be a fixpoint type such as morphling.HFix.HCofree, which is used to introduce the ability to create recursive (tree-structured) schema.
- I
The type of the Scala value to be produced (or consumed) by an interpreter of the schema. Also known as the "index" type of the schema.
- Alphabetic
- By Inheritance
- OneOfSchema
- Serializable
- Product
- Equals
- SchemaF
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val alts: NonEmptyList[Alt[F, I, _]]
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- val discriminator: Option[String]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hfmap[G[_]](nt: ~>[F, G]): OneOfSchema[P, G, I]
HFunctor operation which allows transformation of the functor through which the structure of the schema will be interpreted.
HFunctor operation which allows transformation of the functor through which the structure of the schema will be interpreted.
Defining this operation directly on the SchemaF type rather than in morphling.SchemaF.schemaFHFunctor simplifies type inference.
- Definition Classes
- OneOfSchema → SchemaF
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def pmap[Q[_]](nt: ~>[P, Q]): OneOfSchema[Q, F, I]
HFunctor operation which allows transformation of the primitive algebra of the schema.
HFunctor operation which allows transformation of the primitive algebra of the schema.
Defining this operation directly on the SchemaF type rather than in morphling.SchemaF.schemaFHFunctor simplifies type inference.
- Definition Classes
- OneOfSchema → SchemaF
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
- Deprecated