/** * This module contains basic methods for interacting with OCaml */ export { MlArray, MlPair, MlList, MlOption, MlBool, MlBytes, MlResult, MlUnit, MlString, MlTuple, MlArrayOptionalElements, }; type MlPair = [0, X, Y]; type MlArray = [0, ...T[]]; type MlList = [0, T, 0 | MlList]; type MlOption = 0 | [0, T]; type MlBool = 0 | 1; type MlResult = [0, T] | [1, E]; type MlUnit = 0; type MlArrayOptionalElements = { [K in keyof MlArray]: MlArray[K] extends 0 ? 0 : MlOption; }; /** * js_of_ocaml representation of a byte array, * see https://github.com/ocsigen/js_of_ocaml/blob/master/runtime/mlBytes.js */ type MlBytes = { t: number; c: string; l: number; }; type MlString = MlBytes; declare const MlArray: { to(arr: T[]): MlArray; from([, ...arr]: MlArray): T_1[]; map([, ...arr]: MlArray, map: (t: T_2) => S): MlArray; mapTo(arr: T_3[], map: (t: T_3) => S_1): MlArray; mapFrom([, ...arr]: MlArray, map: (t: T_4) => S_2): S_2[]; }; declare const MlPair: ((x: X, y: Y) => MlPair) & { from([, x, y]: MlPair): [X_1, Y_1]; first(t: MlPair): X_2; second(t: MlPair): Y_2; }; declare const MlBool: ((b: boolean) => MlBool) & { from(b: MlBool): boolean; }; declare const MlOption: ((x?: T) => MlOption) & { from(option: MlOption): T_1 | undefined; map(option: MlOption, map: (t: T_2) => S): MlOption; mapFrom(option: MlOption, map: (t: T_3) => S_1): S_1 | undefined; mapTo(option: T_4 | undefined, map: (t: T_4) => S_2): MlOption; isNone(option: MlOption): option is 0; isSome(option: MlOption): option is [0, T_5]; }; declare const MlResult: { ok(t: T): MlResult; unitError(): MlResult; }; /** * tuple type that has the length as generic parameter */ type MlTuple = N extends N ? number extends N ? [0, ...T[]] : [0, ...TupleRec] : never; type TupleRec = R['length'] extends N ? R : TupleRec; type Tuple = [T, ...T[]] | []; declare const MlTuple: { map, B>([, ...mlTuple]: [0, ...T], f: (a: T[number]) => B): [0, ...{ [i in keyof T]: B; }]; mapFrom([, ...mlTuple]: MlTuple, f: (a: T_1) => B_1): B_1[]; mapTo, B_2>(tuple: T_2, f: (a: T_2[number]) => B_2): [0, ...{ [i_1 in keyof T_2]: B_2; }]; };