import type { satisfy, Stringifiable } from "@ark/util"; import type { Comparator } from "../reduce/shared.ts"; import type { OperatorToken } from "../shift/tokens.ts"; import type { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts"; export type astToString = ast extends InferredAst | DefAst ? ast[2] : ast extends PostfixExpression ? operator extends "[]" ? `${astToString}[]` : never : ast extends InfixExpression ? operator extends "&" | "|" | "%" | Comparator ? `${astToString} ${operator} ${astToString}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "..."; export type ConstraintOperator = satisfy; export type writeConstrainedMorphMessage = `To constrain the output of ${astToString}, pipe like myMorph.to('number > 0'). To constrain the input, intersect like myMorph.and('number > 0').`;