/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { CalcObj, CalcValue, Pending, Resolver, Runtime, TypedBinOp, TypedUnaryOp } from "./types"; import { SyntaxKind } from "./parser"; export declare function makeError(message: string): CalcObj; export declare const errors: { readonly appOnNonFunction: CalcObj; readonly div0: CalcObj; readonly functionArity: CalcObj; readonly functionAsOpArgument: CalcObj; readonly nonStringField: CalcObj; readonly readOnNonObject: CalcObj; readonly resolveError: CalcObj; readonly typeError: CalcObj; }; /** * We use the following to fake an existential type. We really want to * have something like: exists U. TypedBinOp, where the `check` * function of the typed op is used produces values of sealed type. * Once a value is checked, it can then be passed to the op. * * We can't do this so we just forge some unique type that at least * lets us store all binary operations in a single map. */ declare const $skolem: unique symbol; export declare type Skolem = { [$skolem]: unknown; }; export declare const binOps: { readonly 9: TypedBinOp; readonly 10: TypedBinOp; readonly 7: TypedBinOp; readonly 21: TypedBinOp; readonly 8: TypedBinOp; readonly 16: TypedBinOp; readonly 12: TypedBinOp; readonly 13: TypedBinOp; readonly 14: TypedBinOp; readonly 15: TypedBinOp; readonly 17: TypedBinOp; }; export declare const unaryOps: { readonly 9: TypedUnaryOp; readonly 10: TypedUnaryOp; }; /** * Default runtime implementation. This supports applicative tracing * of pending values and will attempt to find all pending * computations before exiting. */ declare const $effect: unique symbol; export declare type Delay = { [$effect]: unknown; }; /** * A expression of type `Delayed` represents a computation that * either delivers a value of type `T`, or is blocked on multiple * requests. A tracer is used to lift a single blocked request * (`Pending`) into the `Delayed` effect. */ export declare type Delayed = T | Delay; export declare function isDelayed(x: T | Delay): x is Delay; /** * A `Trace` function lifts possibly pending values into `Delayed` and * records any pending value. This allows us to gather multiple * pending values in a single computation */ export declare type Trace = (value: T | Pending) => Delayed; export declare function makeTracer(): [Pending[], Trace]; /** * Core Tracing Runtime * * Returns evaluated calc values or the sentinel `Delay` value. * To find the actual `Pending` values see the results of `trace`. */ export declare class CoreRuntime implements Runtime { readonly trace: Trace; constructor(trace: Trace); isDelayed: typeof isDelayed; read(context: C, receiver: Delayed>, prop: string, fallback: F): Delayed | F>; ifS(cond: Delayed, cont: (cond: boolean) => Delayed): Delayed; app1(context: C, op: TypedUnaryOp, expr: Delayed>): Delayed>; app2(context: C, op: TypedBinOp, l: Delayed>, r: Delayed>): Delayed>; appN(context: C, fn: Delayed>, args: Delayed>[], fallback: F): Delayed | F>; } export declare function createObjectResolver(root: CalcObj, trace: Trace): Resolver; /** * Exports the basic building blocks of a formula runtime. * - Error values * - Operator implementations. * - An effect-handling runtime. */ export declare type Errors = typeof errors; export declare type BinaryOps = typeof binOps; export declare type UnaryOps = typeof unaryOps; export {}; //# sourceMappingURL=core.d.ts.map