Documentation
¶
Overview ¶
Package iface provides the frozen $builtin interface
Index ¶
- func DumpBuiltinInterface() ([]byte, error)
- func GetBuiltinArity(name string) (int, error)
- func GetBuiltinType(name string) (string, error)
- func ValidateBuiltin(name string) error
- type Builder
- type BuiltinExport
- type BuiltinInterface
- type ConstructorInfo
- type ConstructorScheme
- type FuncJSON
- type Iface
- func BuildInterface(module string, prog *core.Program, typeEnv *types.TypeEnv) (*Iface, error)
- func BuildInterfaceWithConstructors(module string, prog *core.Program, typeEnv *types.TypeEnv, ...) (*Iface, error)
- func BuildInterfaceWithTypesAndConstructors(module string, prog *core.Program, typeEnv *types.TypeEnv, astFile interface{}, ...) (*Iface, error)
- func NewIface(module string) *Iface
- func (i *Iface) AddConstructor(typeName, ctorName string, fieldTypes []types.Type, resultType types.Type)
- func (i *Iface) AddExport(name string, typ *types.Scheme, purity bool)
- func (i *Iface) AddType(name string, arity int)
- func (i *Iface) AddTypeAlias(name string, target types.Type)
- func (i *Iface) GetConstructor(name string) (*ConstructorScheme, bool)
- func (i *Iface) GetExport(name string) (*IfaceItem, bool)
- func (i *Iface) GetType(name string) (*TypeExport, bool)
- func (i *Iface) GetTypeAlias(name string) (types.Type, bool)
- func (i *Iface) ToNormalizedJSON() ([]byte, error)
- type IfaceItem
- type InterfaceJSON
- type TypeExport
- type TypeJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpBuiltinInterface ¶
DumpBuiltinInterface exports the builtin interface as JSON
func GetBuiltinArity ¶
GetBuiltinArity returns the arity of a builtin
func GetBuiltinType ¶
GetBuiltinType returns the type signature of a builtin
func ValidateBuiltin ¶
ValidateBuiltin checks if a builtin reference is valid
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs module interfaces from typed Core programs
func NewBuilder ¶
NewBuilder creates a new interface builder
type BuiltinExport ¶
type BuiltinExport struct {
Name string `json:"name"`
Type string `json:"type"`
Arity int `json:"arity"`
Category string `json:"category"` // "arithmetic", "comparison", "string", "io", etc.
}
BuiltinExport represents a single builtin export
type BuiltinInterface ¶
type BuiltinInterface struct {
Module string `json:"module"`
Exports map[string]BuiltinExport `json:"exports"`
Digest string `json:"digest"`
}
BuiltinInterface represents the $builtin module interface
func FrozenBuiltinInterface ¶
func FrozenBuiltinInterface() *BuiltinInterface
FrozenBuiltinInterface returns the deterministic $builtin interface This is the canonical source of truth for all builtins
type ConstructorInfo ¶
type ConstructorInfo struct {
TypeName string
CtorName string
Arity int
TypeParamCount int // M-TAPP-FIX: Number of type parameters (e.g., Option[a] = 1)
}
ConstructorInfo represents constructor information for interface building
type ConstructorScheme ¶
type ConstructorScheme struct {
TypeName string // The ADT name (e.g., "Option")
CtorName string // Constructor name (e.g., "Some", "None")
FieldTypes []types.Type // Field types (empty for nullary constructors)
ResultType types.Type // Result type after application
Arity int // Number of fields
}
ConstructorScheme represents the type scheme of an ADT constructor
type FuncJSON ¶
type FuncJSON struct {
Name string `json:"name"`
Type string `json:"type"`
Effects []string `json:"effects"`
Pure bool `json:"pure"`
}
FuncJSON represents an exported function in normalized form
type Iface ¶
type Iface struct {
Module string // Module path, e.g., "math/gcd"
Exports map[string]*IfaceItem // Exported symbols
Constructors map[string]*ConstructorScheme // Exported ADT constructors
Types map[string]*TypeExport // Exported type names
TypeAliases map[string]types.Type // M-FIX-RECORD-UPDATE: Type alias expansions for record types
Schema string // Schema version, e.g., "ailang.iface/v1"
Digest string // Deterministic digest of interface
}
Iface represents a module's interface (its typed exports)
func BuildInterface ¶
BuildInterface extracts the typed interface from a Core program
func BuildInterfaceWithConstructors ¶
func BuildInterfaceWithConstructors(module string, prog *core.Program, typeEnv *types.TypeEnv, constructors map[string]*ConstructorInfo) (*Iface, error)
BuildInterfaceWithConstructors builds an interface with constructor information
func BuildInterfaceWithTypesAndConstructors ¶
func BuildInterfaceWithTypesAndConstructors(module string, prog *core.Program, typeEnv *types.TypeEnv, astFile interface{}, constructors map[string]*ConstructorInfo) (*Iface, error)
BuildInterfaceWithTypesAndConstructors builds an interface with type declarations and constructor information
func (*Iface) AddConstructor ¶
func (i *Iface) AddConstructor(typeName, ctorName string, fieldTypes []types.Type, resultType types.Type)
AddConstructor adds an ADT constructor to the interface
func (*Iface) AddTypeAlias ¶
AddTypeAlias adds a type alias expansion to the interface (M-FIX-RECORD-UPDATE) This is used for record type aliases like `type NPC = { pos: Pos, name: string }`
func (*Iface) GetConstructor ¶
func (i *Iface) GetConstructor(name string) (*ConstructorScheme, bool)
GetConstructor retrieves a constructor scheme
func (*Iface) GetType ¶
func (i *Iface) GetType(name string) (*TypeExport, bool)
GetType retrieves an exported type
func (*Iface) GetTypeAlias ¶
GetTypeAlias retrieves a type alias expansion (M-FIX-RECORD-UPDATE)
func (*Iface) ToNormalizedJSON ¶
ToNormalizedJSON converts an Iface to normalized JSON Normalization rules: - Sort all arrays alphabetically - Canonicalize type variables to a, b, c, ... - Sort effect rows alphabetically - Deterministic field ordering (via struct tags)
type IfaceItem ¶
type IfaceItem struct {
Name string // Symbol name
Type *types.Scheme // Generalized type scheme
Purity bool // Whether the function is pure
Ref core.GlobalRef // Global reference to this item
}
IfaceItem represents a single exported symbol
type InterfaceJSON ¶
type InterfaceJSON struct {
Module string `json:"module"`
Types []TypeJSON `json:"types"`
Funcs []FuncJSON `json:"funcs"`
Schema string `json:"schema"`
}
InterfaceJSON represents the normalized JSON format for module interfaces
type TypeExport ¶
type TypeExport struct {
Name string // Type name (e.g., "Option", "Result")
Arity int // Number of type parameters
}
TypeExport represents an exported type name