morphling
Type members
Classlikes
Class describing an optional property of a record that is always absent.
Class describing an optional property of a record that is always absent.
- Value parameters:
- extract
Extract lens from the record type to the property.
- fieldName
The name of the property.
A prism between a base type containing the arguments required by a single constructor of a sum type, and that sum type, along with the schema for the base type is used to describe those constructor arguments. The identifier is used to distinguish which constructor is being represented in the serialized form.
A prism between a base type containing the arguments required by a single constructor of a sum type, and that sum type, along with the schema for the base type is used to describe those constructor arguments. The identifier is used to distinguish which constructor is being represented in the serialized form.
Class describing a constant (non-serializable) property of a record.
Class describing a constant (non-serializable) property of a record.
- Value parameters:
- extract
Extract lens from the record type to the property.
- fieldName
The name of the property.
- value
The value of the property.
Fixpoint data type that can preserve a type index through its recursive step.
Fixpoint data type that can preserve a type index through its recursive step.
- Companion:
- object
Constructor that enables creation of schema for sum types.
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
)
- 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.
Class describing an optional property of a record. Since in many serialized forms optional properties may be omitted entirely from the serialized form, a distinct type is needed in order to be able to correctly interpret the absence of a field.
Class describing an optional property of a record. Since in many serialized forms optional properties may be omitted entirely from the serialized form, a distinct type is needed in order to be able to correctly interpret the absence of a field.
- Value parameters:
- base
Schema for the property's value type.
- extract
Extract lens from the record type to the property.
- fieldName
The name of the property.
Schema constructor that wraps a value of an underlying GADT of allowed primitive types.
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.
Base trait for values which describe record properties.
Base trait for values which describe record properties.
- Companion:
- object
Wrapper for the free applicative structure which is used to construct and disassemble values of product types.
Wrapper for the free applicative structure which is used to construct and disassemble values of product types.
- 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:
- props
the free applicative value composed of zero or more PropSchema instances
Class describing a required property of a record.
Class describing a required property of a record.
- Value parameters:
- base
Schema for the property's value type.
- default
Optional default value, for use in the case that a serialized form is missing the property.
- extract
Extract lens from the record type to the property.
- fieldName
The name of the property.
Data types and smart constructors which simplify the creation of schema values.
Data types and smart constructors which simplify the creation of schema values.