morphling

package morphling

Members list

Packages

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.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PropSchema[O, F, Option[I]]
class Object
trait Matchable
class Any
Show all
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.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
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.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PropSchema[O, F, I]
class Object
trait Matchable
class Any
Show all
final case class HEnvT[E[_], F[_[_], _], G[_], I](ask: E[I], fa: F[G, I])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
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.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object HFix

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
HFix.type
trait HFunctor[F[_[_], _]]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object HFunctor

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
HFunctor.type
final case class HMutu[F[_[_], _], G[_[_], _], I](unmutu: F[[_] =>> G[[_] =>> HMutu[F, G, _$104], _$105], I])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class IsoSchema[P[_], F[_], I, J](base: F[I], eqv: Equivalent[I, J]) extends SchemaF[P, F, J]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, J]
class Object
trait Matchable
class Any
Show all
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

$FDefn

I

$IDefn

P

$PDefn

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, I]
class Object
trait Matchable
class Any
Show all
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.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PropSchema[O, F, Option[I]]
class Object
trait Matchable
class Any
Show all
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

$FDefn

I

$IDefn

P

$PDefn

Value parameters

prim

value identifying a primitive type.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, I]
class Object
trait Matchable
class Any
Show all
sealed trait PropSchema[O, F[_], I]

Base trait for values which describe record properties.

Base trait for values which describe record properties.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Absent[O, F, I]
class Constant[O, F, I]
class Optional[O, F, I]
class Required[O, F, I]
object PropSchema

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
PropSchema.type
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

$FDefn

I

$IDefn

P

$PDefn

Value parameters

props

the free applicative value composed of zero or more PropSchema instances

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait SchemaF[P, F, I]
class Object
trait Matchable
class Any
Show all
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.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PropSchema[O, F, I]
class Object
trait Matchable
class Any
Show all
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.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Schema.type
sealed trait SchemaF[P[_], F[_], I]

The base trait for the schema GADT.

The base trait for the schema GADT.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class IsoSchema[P, F, I, J]
class OneOfSchema[P, F, I]
class PrimSchema[P, F, I]
class RecordSchema[P, F, I]
object SchemaF

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
SchemaF.type

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$1: HFunctor[F]): given_HFunctor_HEnvT[E, F]