helpers.d.ts (3916B)
1 import { BaseDist } from "../../dist/BaseDist.js"; 2 import { DistError } from "../../dist/DistError.js"; 3 import { Env } from "../../dist/env.js"; 4 import { ReducerContext } from "../../reducer/context.js"; 5 import { Lambda } from "../../reducer/lambda.js"; 6 import * as Result from "../../utility/result.js"; 7 import { Value } from "../../value/index.js"; 8 import { FRFunction } from "./core.js"; 9 import { FnDefinition } from "./fnDefinition.js"; 10 import * as SampleSetDist from "../../dist/SampleSetDist/index.js"; 11 import * as SymbolicDist from "../../dist/SymbolicDist.js"; 12 type SimplifiedArgs = Omit<FRFunction, "nameSpace" | "requiresNamespace"> & Partial<Pick<FRFunction, "nameSpace" | "requiresNamespace">>; 13 type ArgsWithoutDefinitions = Omit<SimplifiedArgs, "definitions">; 14 export declare class FnFactory { 15 nameSpace: string; 16 requiresNamespace: boolean; 17 constructor(opts: { 18 nameSpace: string; 19 requiresNamespace: boolean; 20 }); 21 make(args: SimplifiedArgs): FRFunction; 22 n2n({ fn, ...args }: ArgsWithoutDefinitions & { 23 fn: (x: number) => number; 24 }): FRFunction; 25 nn2n({ fn, ...args }: ArgsWithoutDefinitions & { 26 fn: (x: number, y: number) => number; 27 }): FRFunction; 28 nn2b({ fn, ...args }: ArgsWithoutDefinitions & { 29 fn: (x: number, y: number) => boolean; 30 }): FRFunction; 31 bb2b({ fn, ...args }: ArgsWithoutDefinitions & { 32 fn: (x: boolean, y: boolean) => boolean; 33 }): FRFunction; 34 ss2b({ fn, ...args }: ArgsWithoutDefinitions & { 35 fn: (x: string, y: string) => boolean; 36 }): FRFunction; 37 ss2s({ fn, ...args }: ArgsWithoutDefinitions & { 38 fn: (x: string, y: string) => string; 39 }): FRFunction; 40 d2s({ fn, ...args }: ArgsWithoutDefinitions & { 41 fn: (dist: BaseDist, env: Env) => string; 42 }): FRFunction; 43 dn2s({ fn, ...args }: ArgsWithoutDefinitions & { 44 fn: (dist: BaseDist, n: number, env: Env) => string; 45 }): FRFunction; 46 d2n({ fn, ...args }: ArgsWithoutDefinitions & { 47 fn: (x: BaseDist, env: Env) => number; 48 }): FRFunction; 49 d2b({ fn, ...args }: ArgsWithoutDefinitions & { 50 fn: (x: BaseDist, env: Env) => boolean; 51 }): FRFunction; 52 d2d({ fn, ...args }: ArgsWithoutDefinitions & { 53 fn: (dist: BaseDist, env: Env) => BaseDist; 54 }): FRFunction; 55 dn2d({ fn, ...args }: ArgsWithoutDefinitions & { 56 fn: (dist: BaseDist, n: number, env: Env) => BaseDist; 57 }): FRFunction; 58 dn2n({ fn, ...args }: ArgsWithoutDefinitions & { 59 fn: (dist: BaseDist, n: number, env: Env) => number; 60 }): FRFunction; 61 fromDefinition(name: string, def: FnDefinition): FRFunction; 62 } 63 export declare function unpackDistResult<T>(result: Result.result<T, DistError>): T; 64 export declare function repackDistResult(result: Result.result<BaseDist, DistError>): Value; 65 export declare function doNumberLambdaCall(lambda: Lambda, args: Value[], context: ReducerContext): number; 66 export declare function doBinaryLambdaCall(args: Value[], lambda: Lambda, context: ReducerContext): boolean; 67 export declare const parseDistFromDistOrNumber: (d: number | BaseDist) => BaseDist; 68 export declare function distResultToValue(result: Result.result<BaseDist, DistError>): Value; 69 export declare function distsResultToValue(result: Result.result<BaseDist[], DistError>): Value; 70 export declare function makeSampleSet(d: BaseDist, env: Env): SampleSetDist.SampleSetDist; 71 export declare function twoVarSample(v1: BaseDist | number, v2: BaseDist | number, env: Env, fn: (v1: number, v2: number) => Result.result<SymbolicDist.SymbolicDist, string>): Value; 72 export declare function makeTwoArgsDist(fn: (v1: number, v2: number) => Result.result<SymbolicDist.SymbolicDist, string>): FnDefinition; 73 export declare function makeOneArgDist(fn: (v: number) => Result.result<SymbolicDist.SymbolicDist, string>): FnDefinition; 74 export {}; 75 //# sourceMappingURL=helpers.d.ts.map