morphling

package morphling

Type members

Classlikes

final case class Absent[O, F[_], I](fieldName: String, extract: Extract[O, Option[I]]) extends PropSchema[O, F, Option[I]]

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.

final case class Alt[F[_], I, I0](id: String, base: F[I0], subset: Subset[I, I0])

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.

final case class Constant[O, F[_], I](fieldName: String, value: I, extract: Extract[O, I]) extends PropSchema[O, F, I]

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.

final case class HEnvT[E[_], F[_[_], _], G[_], I](ask: E[I], fa: F[G, I])
final case class HFix[F[_[_], _], I](unfix: Eval[F[[_] =>> HFix[F, _$31], I]])

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
object HFix
Companion:
class
trait HFunctor[F[_[_], _]]
Companion:
object
object HFunctor
Companion:
class
final case class HMutu[F[_[_], _], G[_[_], _], I](unmutu: F[[_] =>> G[[_] =>> HMutu[F, G, _$104], _$105], I])
case class IsoSchema[P[_], F[_], I, J](base: F[I], eqv: Equivalent[I, J]) extends SchemaF[P, F, J]
final case class OneOfSchema[P[_], F[_], I](alts: NonEmptyList[Alt[F, I, _]], discriminator: Option[String]) extends SchemaF[P, F, I]

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.

final case class Optional[O, F[_], I](fieldName: String, base: F[I], extract: Extract[O, Option[I]]) extends PropSchema[O, F, Option[I]]

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.

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.

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.

sealed trait PropSchema[O, F[_], I]

Base trait for values which describe record properties.

Base trait for values which describe record properties.

Companion:
object
object PropSchema
Companion:
class
final case class RecordSchema[P[_], F[_], I](props: FreeApplicative[[_] =>> PropSchema[I, F, _$27], I]) extends SchemaF[P, F, I]

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

final case class Required[O, F[_], I](fieldName: String, base: F[I], extract: Extract[O, I], default: Option[I]) extends PropSchema[O, F, I]

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.

object Schema

Data types and smart constructors which simplify the creation of schema values.

Data types and smart constructors which simplify the creation of schema values.

sealed trait SchemaF[P[_], F[_], I]

The base trait for the schema GADT.

The base trait for the schema GADT.

Companion:
object
object SchemaF
Companion:
class

Types

type HAlgebra[F[_[_], _], G[_]] = FunctionK[[_] =>> F[G, _$5], G]
type HCoAlgebra[F[_[_], _], G[_]] = FunctionK[G, [_] =>> F[G, _$10]]
type HCofree[F[_[_], _], A[_], I] = HFix[[Y[_], Z] =>> HEnvT[A, F, Y, Z], I]

Givens

Givens

given given_HFunctor_HCofree[F[_[_], _]](using evidence$1: HFunctor[F]): given_HFunctor_HCofree[F]
given given_HFunctor_HEnvT[E[_], F[_[_], _]](using evidence$2: HFunctor[F]): given_HFunctor_HEnvT[E, F]