FromData

scalus.builtin.FromData
object FromData

FromData[A] derivation

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
FromData.type

Members list

Value members

Concrete methods

inline def deriveCaseClass[T]: () => T
inline def deriveConstructor[T]: (List[Data]) => T
inline def deriveEnum[T](inline conf: PartialFunction[Int, (List[Data]) => T]): () => T

Derive FromData for an enum type

Derive FromData for an enum type

Value parameters

conf

a partial function mapping tag to constructor function, like

Attributes

Returns

a FromData instance

Example
 enum Adt:
   case A
   case B(b: Boolean)
   case C(a: Adt, b: Adt)
 given FromData[Adt] = FromData.deriveEnum[Adt] {
   case 0 => _ => Adt.A
   case 1 => FromData.deriveConstructor[Adt.B]
   case 2 => FromData.deriveConstructor[Adt.C]
   }
inline def deriveEnum[T]: () => T

Derive FromData for an enum type

Derive FromData for an enum type

Attributes

Returns

a FromData instance

Example
 enum Adt:
   case A
   case B(b: Boolean)
   case C(a: Adt, b: Adt)
 given FromData[Adt] = FromData.deriveEnum[Adt]