Type Inference Engine Types
Since 1.8.0
Advanced type inference and deduction utilities.
Inference Engine Core
InferEngine
Inference engine type that combines input, context, and result.
import type { InferEngine } from 'uni-types'
type Engine = InferEngine<string>
// { input: string; context: InferContext<string>; result: InferResult<string> }InferContext
Inference context containing type variables, constraints, and substitutions.
import type { InferContext } from 'uni-types'
type Context = InferContext<number>InferResult
Result of type inference - either success with inferred type or failure with error.
import type { InferResult } from 'uni-types'
type Result = InferResult<string>
// Success: { success: true; type: string; context: InferContext<string> }
// Failure: { success: false; error: InferError<string> }Type Deduction
Deduce
Deduce type from a value.
import type { Deduce } from 'uni-types'
type T = Deduce<string> // stringDeduceArray
Deduce array element type.
import type { DeduceArray } from 'uni-types'
type Element = DeduceArray<number[]> // numberDeducePromise
Deduce promise value type.
import type { DeducePromise } from 'uni-types'
type Value = DeducePromise<Promise<string>> // stringDeduceReturn
Deduce function return type.
import type { DeduceReturn } from 'uni-types'
type Return = DeduceReturn<() => string> // stringDeduceParams
Deduce function parameters type.
import type { DeduceParams } from 'uni-types'
type Params = DeduceParams<(a: string, b: number) => void> // [string, number]DeduceKey
Deduce object key by value type.
import type { DeduceKey } from 'uni-types'
type Key = DeduceKey<{ a: string; b: number }, string> // 'a'Constraint Solving
Constraint
Type constraint definition.
import type { Constraint } from 'uni-types'
type EqConstraint = Constraint<string>Unify
Unify two types to find common type.
import type { Unify } from 'uni-types'
type Common = Unify<string | number, number | boolean> // numberSolve
Solve constraints to produce a type.
import type { Solve } from 'uni-types'
type Result = Solve<string>Type Variables
TypeVar
Type variable for generic programming.
import type { TypeVar } from 'uni-types'
type V = TypeVar<'T'> // { __typeVar: 'T' }FreeVars
Get free variables in a type.
import type { FreeVars } from 'uni-types'
type Free = FreeVars<TypeVar<'T'>> // 'T'Polymorphism
Polymorphic
Polymorphic type wrapper.
import type { Polymorphic } from 'uni-types'
type Poly = Polymorphic<string>Monomorphize
Convert polymorphic type to monomorphic.
import type { Monomorphize } from 'uni-types'
type Mono = Monomorphize<Polymorphic<string>> // stringKind System
Kind
Get the kind of a type.
import type { Kind } from 'uni-types'
type FnKind = Kind<() => void> // 'function'
type ObjKind = Kind<{ a: 1 }> // 'object'
type StrKind = Kind<string> // 'string'KindCheck
Check if a type has expected kind.
import type { KindCheck } from 'uni-types'
type Check = KindCheck<string, 'string'>
// { success: true; kind: 'string' }HigherKind
Higher-kinded type operations.
import type { HigherKind } from 'uni-types'
type Result = HigherKind<Array, string> // string[]Effect System
Effect
Effect type for tracking side effects.
import type { Effect } from 'uni-types'
type Eff = Effect<string>
// { value: string; effects: EffectRow }Pure
Pure computation type (no side effects).
import type { Pure } from 'uni-types'
type PureValue = Pure<string>Effectful
Computation with specific effect.
import type { Effectful } from 'uni-types'
type AsyncOp = Effectful<string, 'async'>Handle
Handle/remove an effect from a type.
import type { Handle } from 'uni-types'
type Handled = Handle<Effectful<string, 'async'>, 'async'> // string