import { Callable, type array, type Hkt, type JsonStructure } from "@ark/util"; import type { RootSchema } from "./kinds.ts"; import type { BaseNode } from "./node.ts"; import type { BaseRoot } from "./roots/root.ts"; import type { BaseScope } from "./scope.ts"; import { arkKind } from "./shared/utils.ts"; export type GenericParamAst = [name: name, constraint: constraint]; export type GenericParamDef = name | readonly [name, unknown]; export declare const parseGeneric: (paramDefs: array, bodyDef: unknown, $: BaseScope) => GenericRoot; export type genericParamNames> = { [i in keyof params]: params[i][0]; }; export type genericParamConstraints> = { [i in keyof params]: params[i][1]; }; export type GenericArgResolutions = array> = { [i in keyof params as params[i & `${number}`][0]]: BaseRoot; }; export declare class LazyGenericBody extends Callable<(args: argResolutions) => returns> { } export interface GenericAst = array, bodyDef = unknown, $ = unknown, arg$ = $> { [arkKind]: "generic"; paramsAst: params; bodyDef: bodyDef; $: $; arg$: arg$; names: genericParamNames; t: this; } export declare class GenericRoot = array, bodyDef = unknown> extends Callable<(...args: { [i in keyof params]: BaseRoot; }) => BaseRoot> { readonly [arkKind] = "generic"; readonly paramsAst: params; readonly t: GenericAst; paramDefs: array; bodyDef: bodyDef; $: BaseScope; arg$: BaseScope; baseInstantiation: BaseRoot; hkt: Hkt.constructor | null; description: string; constructor(paramDefs: array, bodyDef: bodyDef, $: BaseScope, arg$: BaseScope, hkt: Hkt.constructor | null); defIsLazy(): this is GenericRoot; protected cacheGetter(name: name, value: this[name]): this[name]; get json(): JsonStructure; get params(): { [i in keyof params]: [params[i][0], BaseRoot]; }; get names(): genericParamNames; get constraints(): { [i in keyof params]: BaseRoot; }; get internal(): this; get referencesById(): Record; get references(): BaseNode[]; } export type genericParamSchemasToAst = { [i in keyof schemas]: schemas[i] extends GenericParamDef ? [ name, unknown ] : never; }; export type genericHktToConstraints Hkt> = InstanceType["constraints"]; export type GenericRootParser = (...params: paramsDef) => GenericRootBodyParser>; export type GenericRootBodyParser> = { (body: RootSchema): GenericRoot; (instantiateDef: LazyGenericBody>, hkt: hkt): GenericRoot<{ [i in keyof params]: [params[i][0], genericHktToConstraints[i]]; }, InstanceType>; }; export declare const writeUnsatisfiedParameterConstraintMessage: (name: name, constraint: constraint, arg: arg) => writeUnsatisfiedParameterConstraintMessage; export type writeUnsatisfiedParameterConstraintMessage = `${name} must be assignable to ${constraint} (was ${arg})`;