Attributes
Members list
Type members
Classlikes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- object
- Supertypes
- Known subtypes
Collector to help with Traversal
Collector to help with Traversal
Attributes
- Supertypes
A discrimiated union type such as an ELM union (either with labels or not)
A discrimiated union type such as an ELM union (either with labels or not)
Given an Elm Datatype that looks like this:
type MyUnion =
= NoValue
| IntValue x:Int
| MultiValue x:Int y:String
| MultiValueAnon Int String // no labels for the types
Or a Scala 3 enum that looks like this:
enum MyUnion:
case NoValue
case IntValue(x:Int)
case MultiValue(x:Int, y:String)
// case MultiValueAnon(Int, String) // cannot have un-labeled unions in Scala3
The corresponding type-representation should look like this:
Enum(
Case("NoValue", List()),
Case("IntValue", List(Case.Field.Named("x", Schema.Int))),
Case("MultiValue", List(Case.Field.Named("x", Schema.Int), Case.Field.Named("y", Schema.String)))
Case("MultiValueAnon", List(Case.Field.Anon(Schema.Int), Case.Field.Anon(Schema.String)))
)
On the value level this should look as follows
// Given a type definition that looks like this (In Scala)
val x: MyUnion = MyUnion.IntValue(123)
// It's data-level encoding should look like this
Data.Case(
value: Data.Int(123)
case: Case("IntValue", List(Case.Field.Named("x", Schema.Int)))
schema: Schema.Enum
)
Attributes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
We can only know if an optional-value is Some or None on the value-level, not the type-level because the parent-derivation stage does not know this information. This is generally understood to be a standard practice. For example, using Scala 3 enums, the specific type of an enum element is not known, only the general coproduct type. For example:
We can only know if an optional-value is Some or None on the value-level, not the type-level because the parent-derivation stage does not know this information. This is generally understood to be a standard practice. For example, using Scala 3 enums, the specific type of an enum element is not known, only the general coproduct type. For example:
enum Customer:
case Person
case Robot
// this will be implicitly typed as Customer
val c = Customer.Person
Coproduct types in other languages (e.g. Haskell) work similarly.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
A non-discrimiated union-type such as a Scala 3
A non-discrimiated union-type such as a Scala 3
type MyUnion = Int | String
Would be defined as
Union(Schema.Int, Schema.String)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Conceptclass Objecttrait Matchableclass AnyShow all
Inherited types
The names of the product elements
The names of the product elements
Attributes
- Inherited from:
- Mirror
The name of the type
The name of the type
Attributes
- Inherited from:
- Mirror