Documentation
¶
Overview ¶
Package types is Writ's type algebra and checker.
Check walks already-expanded forms. It does not evaluate or read files.
Index ¶
- func Encode(t Type) ([]byte, error)
- func MustEncode(t Type) []byte
- func PrintType(t Type) string
- type Alias
- type CheckResult
- type Config
- type Diagnostic
- type FnClause
- type FnKey
- type PayloadKey
- type Type
- func Any() Type
- func BoolType() Type
- func Decode(b []byte) (Type, error)
- func Dynamic(t Type) Type
- func EmptyList() Type
- func EmptyMapType() Type
- func ExactSymbol(s string) Type
- func FalseType() Type
- func FloatType() Type
- func FnType(clauses ...FnClause) Type
- func IntType() Type
- func ListOf(el Type) Type
- func MacroType() Type
- func MapType(keys []FnKey, rest *Type) Type
- func Native[T any]() Type
- func NilType() Type
- func None() Type
- func Opaque(pkg string, name ...string) Type
- func OpaqueType() Type
- func StringType() Type
- func SymbolType() Type
- func TrueType() Type
- func Tuple(items ...Type) Type
- func Union(ts ...Type) Type
- func UnknownSymbol() Type
- type TypeHint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CheckResult ¶
type CheckResult struct {
Diagnostics []Diagnostic
Hints []TypeHint
Export Type
}
CheckResult is the output of Check.
type Config ¶
type Config struct {
Events map[string][]PayloadKey
Aliases []Alias
Extra map[string][]FnClause
File string
Import func(spec, fromFile string) (Type, []Diagnostic, error)
}
Config is host type information for Check.
type Diagnostic ¶
Diagnostic is a parse or type error.
type FnClause ¶
FnClause is one function clause: (fn (Args) Return) or keyed args. Rest is host/checker-only (runtime rest params / print builtin); it is not part of the Writ type language, PrintType, or Encode.
type PayloadKey ¶
PayloadKey is one event payload field.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type is a static type. Use the constructors such as IntType and Union.
func EmptyMapType ¶
func EmptyMapType() Type
func ExactSymbol ¶
func Native ¶
Native maps a Go host type to (opaque from host named …) for in-process RegisterBuiltin / RegisterPackage. Encode uses package/name, not reflect IDs.
func Opaque ¶
Opaque is a nominal opaque. With only pkg: (opaque from P). With pkg and name: (opaque from P named T). Empty pkg and name is OpaqueType.
func StringType ¶
func StringType() Type
func SymbolType ¶
func SymbolType() Type
func UnknownSymbol ¶
func UnknownSymbol() Type