PrimSchema

morphling.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

$FDefn

I

$IDefn

P

$PDefn

Value parameters

prim

value identifying a primitive type.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, I]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def hfmap[G[_]](nt: FunctionK[F, G]): PrimSchema[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.

Attributes

def pmap[Q[_]](nt: FunctionK[P, Q]): PrimSchema[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.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product