/** * ChainRec * * 1. M.chainRec((next, done, v) => p(v) ? d(v).map(done) : n(v).map(next), i) is equivalent to * (function step(v) { return p(v) ? d(v) : n(v).chain(step); }(i)) (equivalence) * 2. Stack usage of M.chainRec(f, i) must be at most a constant multiple of the stack usage of f itself * * chainRec :: ChainRec m => ((a -> c, b -> c, a) -> m c, a) -> m b */ import { Either } from '../Either'; import { Chain, Chain1, Chain2 } from './Chain'; import { HKT, KindOf, URIS } from './HKT'; export interface ChainRec extends Chain { readonly chainRec: (fa: A, f: (a: A) => HKT>) => HKT; } export interface ChainRec1 extends Chain1 { readonly chainRec: (fa: A, f: (a: A) => KindOf]>) => KindOf; } export interface ChainRec2 extends Chain2 { readonly chainRec: (fa: A, f: (a: A) => KindOf]>) => KindOf; } /** * `ChainRec` helper. Returns until the next is `Right`. */ export declare const tailRec: (init: A, f: (a: A) => Either) => B;