// ets_tracing: off import { chain_, succeed } from "./core.js" import type { Effect } from "./effect.js" /** * Repeats this effect while its error satisfies the specified effectful predicate. * * @ets_data_first repeatWhileM_ */ export function repeatWhileM( f: (a: A) => Effect, __trace?: string ) { return (self: Effect): Effect => repeatWhileM_(self, f, __trace) } /** * Repeats this effect while its error satisfies the specified effectful predicate. */ export function repeatWhileM_( self: Effect, f: (a: A) => Effect, __trace?: string ): Effect { return chain_( self, (a) => chain_(f(a), (b) => (b ? repeatWhileM_(self, f) : succeed(a))), __trace ) } /** * Repeats this effect while its error satisfies the specified predicate. * * @ets_data_first repeatWhile_ */ export function repeatWhile(f: (a: A) => boolean, __trace?: string) { return (self: Effect) => repeatWhile_(self, f, __trace) } /** * Repeats this effect while its error satisfies the specified predicate. */ export function repeatWhile_( self: Effect, f: (a: A) => boolean, __trace?: string ) { return repeatWhileM_(self, (a) => succeed(f(a)), __trace) }