Constr

scalus.uplc.builtin.Data.Constr
case class Constr(constr: BigInt, args: List[Data]) extends Data

Constructor application - represents sum types and product types.

This is the primary way to encode algebraic data types in Plutus:

  • For sum types, constr is the constructor index (0, 1, 2, ...)
  • For product types (case classes), constr is typically 0
  • args contains the constructor's field values

Corresponds to UPLC builtins constrData and unConstrData.

Value parameters

args

the constructor arguments as a list of Data values

constr

the constructor index (must be non-negative)

Attributes

Example
 // A pair (Int, String)
 Constr(0, List(I(42), B(ByteString.fromString("hello"))))
 // Either.Left(10)
 Constr(0, List(I(10)))
 // Either.Right("x")
 Constr(1, List(B(ByteString.fromString("x"))))
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Data
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
override def toString: String

Debug string representation matching the Pretty instance format. It does not recurse, so the nesting depth is not limited by the stack.

Debug string representation matching the Pretty instance format. It does not recurse, so the nesting depth is not limited by the stack.

Attributes

Definition Classes
Data -> Any
Inherited from:
Data