Enum

org.finos.morphir.datamodel.Concept$.Enum
See theEnum companion object
case class Enum(name: QualifiedName, cases: List[Case]) extends Concept

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

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

Members list

Value members

Inherited methods

def collect[T](p: PartialFunction[Concept, T]): Chunk[T]

Attributes

Inherited from:
Concept
def collectAll: Chunk[Concept]

Attributes

Inherited from:
Concept
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product