/**
* A type used to express actions in the loop.
* Each action can have a value with it.
* @typeparam A - Type of step results.
* @typeparam B - Type of finish results.
* @typeparam E - Type of errors.
*/
export declare type LoopAction = Step | Finish | Fail;
/**
* Tag for the loop action variants.
*/
export declare enum LoopTag {
STEP = "step",
FINISH = "finish",
FAIL = "fail"
}
/**
* The loop should continue being stepped through.
* @typeparam A - Type of step results.
*/
export interface Step {
/**
* If this is a Step, this is 'step'.
*/
readonly action: LoopTag.STEP;
/**
* The item to step with.
*/
readonly item: A;
readonly value?: undefined;
readonly error?: undefined;
}
/**
* The loop should finish successfully.
* @typeparam B - Type of finish results.
*/
export interface Finish {
/**
* If this is a Finish, this is 'finish'.
*/
readonly action: LoopTag.FINISH;
readonly item?: undefined;
/**
* The resulting value.
*/
readonly value: B;
readonly error?: undefined;
}
/**
* The loop should fail due to an error.
* @typeparam E - Type of errors.
*/
export interface Fail {
/**
* If this is a Fail, this is 'fail'.
*/
readonly action: LoopTag.FAIL;
readonly item?: undefined;
readonly value?: undefined;
/**
* The resulting error.
*/
readonly error: E;
}
/**
* Creates a Step.
* @typeparam A - Type of step results.
* @param x - Value to use.
* @returns A LoopAction.
*/
export declare function step(x: A): Step;
/**
* Creates a Step with null value.
* @returns A LoopAction.
*/
export declare function step_(): Step;
/**
* Creates a Finish.
* @typeparam B - Type of finish results.
* @param x - Value to use.
* @returns A LoopAction.
*/
export declare function finish(x: B): Finish;
/**
* Creates a Fail.
* @typeparam E - Type of errors.
* @param x - Value to use.
* @returns A LoopAction.
*/
export declare function fail(x: E): Fail;
/**
* Creates a Fail with null value.
* @returns A LoopAction.
*/
export declare function fail_(): Fail;