Documentation
¶
Overview ¶
Package types provides Go-to-Simplicity type mapping, sum type parsing (Either/Option), and tuple type utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MatchArm ¶ added in v0.1.1
type MatchArm struct {
Pattern string // "Left(data)" or "Right(sig)" or "Some(val)" or "None"
VarName string // The bound variable name (data, sig, val, etc.)
VarType string // The type of the bound variable
Body string // The body of the match arm
}
MatchArm represents a single arm of a match expression
type MatchExpr ¶ added in v0.1.1
type MatchExpr struct {
Scrutinee string // The expression being matched (e.g., "witness::DATA")
Arms []MatchArm // The match arms
}
MatchExpr represents a complete match expression
func (*MatchExpr) ToSimplicityHL ¶ added in v0.1.1
ToSimplicityHL generates SimplicityHL code for the match expression
type SumType ¶ added in v0.1.1
type SumType struct {
Kind SumTypeKind
LeftType string // For Either: left type, For Option: the inner type
RightType string // For Either: right type, For Option: unused
}
SumType represents Either<L, R> or Option<T> types
func ParseSumType ¶ added in v0.1.1
ParseSumType parses a string like "Either<u256, [u8; 64]>" or "Option<[u8; 64]>"
func (*SumType) ToSimplicityHL ¶ added in v0.1.1
ToSimplicityHL returns the SimplicityHL representation of the sum type
type SumTypeKind ¶ added in v0.1.1
type SumTypeKind int
SumTypeKind identifies whether a SumType is Either or Option.
const ( // SumTypeEither represents an Either<L, R> type. SumTypeEither SumTypeKind = iota // SumTypeOption represents an Option<T> type. SumTypeOption )
type TupleType ¶ added in v0.1.1
type TupleType struct {
Elements []string
}
TupleType represents a tuple like (u256, [u8; 64])
func ParseTupleType ¶ added in v0.1.1
ParseTupleType parses a string like "(u256, [u8; 64])"
func (*TupleType) ToSimplicityHL ¶ added in v0.1.1
ToSimplicityHL returns the SimplicityHL representation
type TypeMapper ¶
type TypeMapper struct {
// contains filtered or unexported fields
}
TypeMapper maps Go types to Simplicity types
func (*TypeMapper) GetBitSize ¶
func (tm *TypeMapper) GetBitSize(simplicityType string) int
GetBitSize returns the bit size for a Simplicity type
func (*TypeMapper) InferHexType ¶ added in v0.1.1
func (tm *TypeMapper) InferHexType(hexValue string) string
InferHexType infers the Simplicity type from a hex literal value
func (*TypeMapper) MapGoType ¶
func (tm *TypeMapper) MapGoType(goType ast.Expr) (string, error)
MapGoType converts a Go type to its Simplicity equivalent
func (*TypeMapper) SupportedTypes ¶
func (tm *TypeMapper) SupportedTypes() []string
SupportedTypes returns a list of all supported Go types