zio.blocks.codegen.ir

Members list

Type members

Classlikes

final case class AbstractClass(name: String, fields: List[Field] = ..., typeParams: List[TypeParam] = ..., extendsTypes: List[TypeRef] = ..., members: List[ObjectMember] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ..., isSealed: Boolean = ...) extends TypeDefinition

Represents a Scala abstract class in the IR.

Represents a Scala abstract class in the IR.

Value parameters

annotations

Annotations on the abstract class (defaults to empty list)

companion

Optional companion object (defaults to None)

doc

Optional documentation (defaults to None)

extendsTypes

Types that this abstract class extends (defaults to empty list)

fields

The fields (constructor parameters) of the abstract class

members

Members defined within the class body (defaults to empty list)

name

The name of the abstract class

typeParams

Type parameters for generic abstract classes (defaults to empty list)

Attributes

Example
val entity = AbstractClass(
 "Entity",
 fields = List(Field("id", TypeRef.Long))
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Annotation(name: String, args: List[(String, String)] = ...)

Represents a Scala annotation in the IR.

Represents a Scala annotation in the IR.

Value parameters

args

List of annotation arguments as (name, value) pairs (defaults to empty list)

name

The name of the annotation (e.g., "deprecated", "required")

Attributes

Example
// Annotation without arguments
val required = Annotation("required")
// Annotation with arguments
val deprecated = Annotation("deprecated", List(("message", "\"use v2\"")))
Source
Annotation.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class CaseClass(name: String, fields: List[Field], typeParams: List[TypeParam] = ..., extendsTypes: List[TypeRef] = ..., derives: List[String] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ..., isValueClass: Boolean = ...) extends TypeDefinition

Represents a Scala case class in the IR.

Represents a Scala case class in the IR.

Value parameters

annotations

Annotations on the case class (defaults to empty list)

companion

Optional companion object (defaults to None)

derives

Type class derivations (defaults to empty list)

doc

Optional documentation (defaults to None)

extendsTypes

Types that this case class extends (defaults to empty list)

fields

The fields (constructor parameters) of the case class

name

The name of the case class

typeParams

Type parameters for generic case classes (defaults to empty list)

Attributes

Example
val person = CaseClass(
 "Person",
 fields = List(
   Field("name", TypeRef.String),
   Field("age", TypeRef.Int)
 ),
 derives = List("Schema")
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class CompanionObject(members: List[ObjectMember] = ...)

Represents a companion object in the IR.

Represents a companion object in the IR.

Value parameters

members

The members of the companion object (defaults to empty list)

Attributes

Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Enum(name: String, cases: List[EnumCase], typeParams: List[TypeParam] = ..., extendsTypes: List[TypeRef] = ..., derives: List[String] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ...) extends TypeDefinition

Represents a Scala 3 enum in the IR.

Represents a Scala 3 enum in the IR.

Value parameters

annotations

Annotations on the enum (defaults to empty list)

cases

The enum cases

doc

Optional documentation (defaults to None)

extendsTypes

Types that this enum extends (defaults to empty list)

name

The name of the enum

Attributes

Example
val color = Enum(
 "Color",
 cases = List(
   EnumCase.SimpleCase("Red"),
   EnumCase.SimpleCase("Green"),
   EnumCase.SimpleCase("Blue")
 )
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait EnumCase

Represents a case within a Scala 3 enum.

Represents a case within a Scala 3 enum.

Attributes

Companion
object
Source
TypeDefinition.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object EnumCase

Attributes

Companion
trait
Source
TypeDefinition.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
EnumCase.type
final case class Field(name: String, typeRef: TypeRef, defaultValue: Option[String] = ..., annotations: List[Annotation] = ..., doc: Option[String] = ...)

Represents a field/property in the IR, with type, default value, annotations, and documentation.

Represents a field/property in the IR, with type, default value, annotations, and documentation.

Value parameters

annotations

List of annotations on the field (defaults to empty list)

defaultValue

Optional default value for the field as a string (defaults to None)

doc

Optional documentation/description of the field (defaults to None)

name

The name of the field

typeRef

The type of the field

Attributes

Example
// Simple field
val nameField = Field("name", TypeRef.String)
// Field with default value
val ageField = Field("age", TypeRef.Int, Some("0"))
// Field with annotations and documentation
val emailField = Field(
 "email",
 TypeRef.String,
 annotations = List(Annotation("required")),
 doc = Some("User email address")
)
// Field with complex type
val itemsField = Field("items", TypeRef.list(TypeRef.String))
Source
Field.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Import

Attributes

Companion
trait
Source
Import.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Import.type
sealed trait Import

Represents a Scala import statement in the IR.

Represents a Scala import statement in the IR.

Attributes

Companion
object
Source
Import.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class Method(name: String, typeParams: List[TypeParam] = ..., params: List[ParamList] = ..., returnType: TypeRef, body: Option[String] = ..., annotations: List[Annotation] = ..., isOverride: Boolean = ..., isImplicit: Boolean = ..., doc: Option[String] = ...)

Represents a method definition in the IR.

Represents a method definition in the IR.

Value parameters

annotations

List of annotations on the method (defaults to empty list)

body

Optional method body as a string (defaults to None)

doc

Optional documentation for the method (defaults to None)

isImplicit

Whether this method is implicit (Scala 2) or given (Scala 3) (defaults to false)

isOverride

Whether this method overrides a parent method (defaults to false)

name

The method name

params

Parameter lists (supports curried methods, defaults to empty list)

returnType

The return type of the method

typeParams

Type parameters for generic methods (defaults to empty list)

Attributes

Source
Method.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class MethodParam(name: String, typeRef: TypeRef, defaultValue: Option[String] = ..., isByName: Boolean = ..., isVarargs: Boolean = ...)

Represents a method parameter in the IR.

Represents a method parameter in the IR.

Value parameters

defaultValue

Optional default value as a string (defaults to None)

isByName

Whether this is a by-name parameter (=> T) (defaults to false)

isVarargs

Whether this is a varargs parameter (T*) (defaults to false)

name

The parameter name

typeRef

The parameter type

Attributes

Source
Method.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Newtype(name: String, wrappedType: TypeRef, annotations: List[Annotation] = ..., doc: Option[String] = ...) extends TypeDefinition

Represents a newtype wrapper in the IR.

Represents a newtype wrapper in the IR.

Value parameters

annotations

Annotations on the newtype (defaults to empty list)

doc

Optional documentation (defaults to None)

name

The name of the newtype

wrappedType

The underlying type being wrapped

Attributes

Example
val userId = Newtype("UserId", wrappedType = TypeRef.Long)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ObjectDef(name: String, members: List[ObjectMember] = ..., extendsTypes: List[TypeRef] = ..., isCaseObject: Boolean = ..., annotations: List[Annotation] = ..., doc: Option[String] = ...) extends TypeDefinition

Represents a Scala object definition in the IR.

Represents a Scala object definition in the IR.

Value parameters

annotations

Annotations on the object (defaults to empty list)

doc

Optional documentation (defaults to None)

extendsTypes

Types that this object extends (defaults to empty list)

isCaseObject

Whether this is a case object (defaults to false)

members

The members of the object (defaults to empty list)

name

The name of the object

Attributes

Example
val utils = ObjectDef(
 "Utils",
 members = List(
   ObjectMember.ValMember("MaxRetries", TypeRef.Int, "3")
 )
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ObjectMember

Attributes

Companion
trait
Source
TypeDefinition.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ObjectMember

Represents a member within an object definition.

Represents a member within an object definition.

Attributes

Companion
object
Source
TypeDefinition.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class DefMember
class NestedType
class TypeAlias
class ValMember
final case class OpaqueType(name: String, underlyingType: TypeRef, upperBound: Option[TypeRef] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ...) extends TypeDefinition

Represents a Scala 3 opaque type alias in the IR.

Represents a Scala 3 opaque type alias in the IR.

In Scala 3, emitted as opaque type Name = UnderlyingType. In Scala 2, falls back to a plain type alias type Name = UnderlyingType.

Value parameters

annotations

Annotations on the opaque type (defaults to empty list)

companion

Optional companion object (defaults to None)

doc

Optional documentation (defaults to None)

name

The name of the opaque type

underlyingType

The underlying type being aliased

upperBound

Optional upper bound constraint (defaults to None)

Attributes

Example
val userId = OpaqueType("UserId", underlyingType = TypeRef.String)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class PackageDecl(path: String)

Represents a Scala package declaration in the IR.

Represents a Scala package declaration in the IR.

Value parameters

path

The fully qualified package path (e.g., "com.example")

Attributes

Example
val pkg = PackageDecl("com.example")
// Represents: package com.example
Source
PackageDecl.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ParamList(params: List[MethodParam], modifier: ParamListModifier = ...)

Wraps a list of method parameters with an optional modifier (implicit/using).

Wraps a list of method parameters with an optional modifier (implicit/using).

Value parameters

modifier

The modifier for this parameter list (defaults to Normal)

params

The parameters in this parameter list

Attributes

Source
ParamList.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Source
ParamList.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ParamListModifier

Modifier for a parameter list, indicating whether it is normal, implicit, or using.

Modifier for a parameter list, indicating whether it is normal, implicit, or using.

Attributes

Companion
object
Source
ParamList.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Implicit
object Normal
object Using
final case class ScalaFile(packageDecl: PackageDecl, imports: List[Import] = ..., types: List[TypeDefinition] = ...)

Represents a complete Scala source file in the IR.

Represents a complete Scala source file in the IR.

A Scala file consists of a package declaration, optional imports, and type definitions. This is the top-level IR node for code generation.

Value parameters

imports

The import statements (defaults to empty list)

packageDecl

The package declaration for this file

types

The type definitions in this file (defaults to empty list)

Attributes

Example
val file = ScalaFile(
 PackageDecl("com.example"),
 imports = List(
   Import.SingleImport("scala.collection", "List"),
   Import.WildcardImport("zio")
 ),
 types = List(
   CaseClass("Person", List(Field("name", TypeRef.String)))
 )
)
Source
ScalaFile.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class SealedTrait(name: String, typeParams: List[TypeParam] = ..., extendsTypes: List[TypeRef] = ..., cases: List[SealedTraitCase] = ..., derives: List[String] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ..., selfType: Option[TypeRef] = ...) extends TypeDefinition

Represents a Scala sealed trait in the IR.

Represents a Scala sealed trait in the IR.

Value parameters

annotations

Annotations on the sealed trait (defaults to empty list)

cases

The cases (subtypes) of the sealed trait (defaults to empty list)

companion

Optional companion object (defaults to None)

doc

Optional documentation (defaults to None)

extendsTypes

Types that this sealed trait extends (defaults to empty list)

name

The name of the sealed trait

typeParams

Type parameters for generic sealed traits (defaults to empty list)

Attributes

Example
val shape = SealedTrait(
 "Shape",
 cases = List(
   SealedTraitCase.CaseClassCase(CaseClass("Circle", List(Field("radius", TypeRef.Double)))),
   SealedTraitCase.CaseObjectCase("Unknown")
 )
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Source
TypeDefinition.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait SealedTraitCase

Represents a case within a sealed trait hierarchy.

Represents a case within a sealed trait hierarchy.

Attributes

Companion
object
Source
TypeDefinition.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class Trait(name: String, typeParams: List[TypeParam] = ..., extendsTypes: List[TypeRef] = ..., members: List[ObjectMember] = ..., annotations: List[Annotation] = ..., companion: Option[CompanionObject] = ..., doc: Option[String] = ..., selfType: Option[TypeRef] = ...) extends TypeDefinition

Represents a non-sealed Scala trait in the IR.

Represents a non-sealed Scala trait in the IR.

Value parameters

annotations

Annotations on the trait (defaults to empty list)

companion

Optional companion object (defaults to None)

doc

Optional documentation (defaults to None)

extendsTypes

Types that this trait extends (defaults to empty list)

members

Members defined within the trait body (defaults to empty list)

name

The name of the trait

typeParams

Type parameters for generic traits (defaults to empty list)

Attributes

Example
val hasId = Trait(
 "HasId",
 members = List(
   ObjectMember.DefMember(Method("id", TypeRef.Long))
 )
)
Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class TypeAlias(name: String, typeParams: List[TypeParam] = ..., typeRef: TypeRef, annotations: List[Annotation] = ..., doc: Option[String] = ...) extends TypeDefinition

Attributes

Source
TypeDefinition.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait TypeDefinition

Represents a Scala type definition in the IR.

Represents a Scala type definition in the IR.

All compound types (case classes, sealed traits, enums, objects, newtypes) extend this trait, providing a uniform interface for code generation.

Attributes

Source
TypeDefinition.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CaseClass
class Enum
class Newtype
class ObjectDef
class OpaqueType
class SealedTrait
class Trait
class TypeAlias
Show all
final case class TypeParam(name: String, variance: Variance = ..., upperBound: Option[TypeRef] = ..., lowerBound: Option[TypeRef] = ..., typeParams: List[TypeParam] = ..., contextBounds: List[TypeRef] = ...)

Represents a type parameter in the IR, with optional variance and bounds.

Represents a type parameter in the IR, with optional variance and bounds.

Value parameters

name

The name of the type parameter (e.g., "A", "B")

upperBound

An optional upper bound type (e.g., Some(TypeRef("Serializable")) for A : Nothing)

variance

The variance of the type parameter (defaults to Invariant)

Attributes

Example
// Simple invariant type param
val a = TypeParam("A")
// Covariant type param
val covariant = TypeParam("A", Variance.Covariant)
// With upper bound
val bounded = TypeParam("A", upperBound = Some(TypeRef("Serializable")))
Source
TypeParam.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class TypeRef(name: String, typeArgs: List[TypeRef] = ...)

Represents a Scala type reference in the IR, supporting generic types.

Represents a Scala type reference in the IR, supporting generic types.

Value parameters

name

The name of the type (e.g., "String", "List", "Option")

typeArgs

Type arguments for generic types (defaults to empty list)

Attributes

Example
// Simple type
val stringType = TypeRef("String")
// Generic type with arguments
val listOfInt = TypeRef("List", List(TypeRef("Int")))
// Using factory methods
val optionalString = TypeRef.optional(TypeRef.String)
val mapStringInt = TypeRef.map(TypeRef.String, TypeRef.Int)
Companion
object
Source
TypeRef.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object TypeRef

Attributes

Companion
class
Source
TypeRef.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TypeRef.type
sealed trait Variance

Represents type parameter variance.

Represents type parameter variance.

Attributes

Companion
object
Source
TypeParam.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Contravariant
object Covariant
object Invariant
object Variance

Attributes

Companion
trait
Source
TypeParam.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Variance.type