PrimSchema

final case class PrimSchema[P[_], F[_], I](prim: P[I]) extends SchemaF[P, F, I]

Schema constructor that wraps a value of an underlying GADT of allowed primitive types.

The underlying GADT defines a set of types via GADT constructors; see morphling.protocol.SType for an example. This set of types defines what types may be treated as primitive (and have parsing/ serialization/etc deferred to an external handler) when interpreting a schema value. For example, one might want to construct a GADT for for the Scala primitive types as such:

sealed trait SType[I]

case object SNullT   extends SType[Unit]
case object SBoolT   extends SType[Boolean]

case object SByteT   extends SType[Byte]
case object SShortT  extends SType[Short]
case object SIntT    extends SType[Int]
case object SLongT   extends SType[Long]

case object SFloatT  extends SType[Float]
case object SDoubleT extends SType[Double]

case object SCharT   extends SType[Char]
case object SStrT    extends SType[String]

This example treats String values as primitive as well, even though strictly speaking they're reference types, just because virtually any interpreter for a schema algebra will not want to represent strings in terms of sum or product types. The same might hold true for, for example, scala.Array but for the purposes of this example issues related to ClassManifest instances would introduce excessive complexity.

Type parameters:
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.

P

The GADT type constructor for a sum type which defines the set of primitive types used in the schema.

Value parameters:
prim

value identifying a primitive type.

trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, I]
class Object
trait Matchable
class Any

Value members

Concrete methods

def hfmap[G[_]](nt: FunctionK[F, G]): PrimSchema[P, G, I]
def pmap[Q[_]](nt: FunctionK[P, Q]): PrimSchema[Q, F, I]

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product