@informalsystems/quint
Version:
Core tool for the Quint specification language
115 lines (114 loc) • 3.04 kB
TypeScript
/**
* Quint Types, representing annotated or inferred types.
*
* @author Igor Konnov, Gabriela Moreira
*/
/**
* Quint expressions, declarations and types carry a unique identifier, which can be used
* to recover expression metadata such as source information, annotations, etc.
*/
interface WithOptionalId {
id?: bigint;
}
export interface QuintBoolType extends WithOptionalId {
kind: 'bool';
}
export interface QuintIntType extends WithOptionalId {
kind: 'int';
}
export interface QuintStrType extends WithOptionalId {
kind: 'str';
}
export interface QuintConstType extends WithOptionalId {
kind: 'const';
name: string;
}
export interface QuintVarType extends WithOptionalId {
kind: 'var';
name: string;
}
export interface QuintSetType extends WithOptionalId {
kind: 'set';
elem: QuintType;
}
export interface QuintSeqType extends WithOptionalId {
kind: 'list';
elem: QuintType;
}
export interface QuintFunType extends WithOptionalId {
kind: 'fun';
arg: QuintType;
res: QuintType;
}
export interface QuintOperType extends WithOptionalId {
kind: 'oper';
args: QuintType[];
res: QuintType;
}
export interface QuintTupleType extends WithOptionalId {
kind: 'tup';
fields: Row;
}
export declare function unitType(id: bigint): QuintTupleType;
export declare function isUnitType(r: QuintType): Boolean;
export interface QuintRecordType extends WithOptionalId {
kind: 'rec';
fields: Row;
}
export interface QuintSumType extends WithOptionalId {
kind: 'sum';
fields: ConcreteRow;
}
export declare function sumType(labelTypePairs: [string, QuintType][], rowVar?: string, id?: bigint): QuintSumType;
/**
* Type application
*
* E.g.,
*
* ```
* T[int, str]
* ```
*
* for a type constant `T`.
*/
export interface QuintAppType extends WithOptionalId {
kind: 'app';
ctor: QuintConstType; /** The type constructor applied */
args: QuintType[]; /** The arguments to which the constructor is applied */
}
/**
* A type in Type System 1.2.
*/
export type QuintType = QuintBoolType | QuintIntType | QuintStrType | QuintConstType | QuintVarType | QuintSetType | QuintSeqType | QuintFunType | QuintOperType | QuintTupleType | QuintRecordType | QuintSumType | QuintAppType;
/**
* Row types, used to express tuples and records.
*/
export type RowField = {
fieldName: string;
fieldType: QuintType;
};
export interface ConcreteRow {
kind: 'row';
fields: RowField[];
other: Row;
}
export interface ConcreteFixedRow extends ConcreteRow {
kind: 'row';
fields: RowField[];
other: EmptyRow;
}
export type VarRow = {
kind: 'var';
name: string;
};
export type EmptyRow = {
kind: 'empty';
};
export type Row = ConcreteFixedRow | ConcreteRow | VarRow | EmptyRow;
export declare function rowFieldNames(r: Row): string[];
export declare function typeNames(t: QuintType): {
typeVariables: Set<string>;
rowVariables: Set<string>;
};
export declare function rowNames(r: Row): Set<string>;
export {};