/// <summary> /// Fold over the effect repeatedly until the effect fails or the predicate returns false /// </summary> /// <param name="ma">Effect to fold over</param> /// <param name="state">Initial state</param> /// <param name="fold">Folder function</param> /// <param name="pred">Predicate function - when this returns false, the fold ends</param> /// <typeparam name="S">State type</typeparam> /// <typeparam name="A">Bound value type</typeparam> /// <returns>The result of the fold operation</returns> public static Aff <S> foldWhile <S, A>(Aff <A> ma, S state, Func <S, A, S> fold, Func <A, bool> pred) => ScheduleAff <A> .FoldWhile(ma, Schedule.Forever, state, fold, pred);
/// <summary> /// Fold over the effect repeatedly until the effect fails or the predicate returns false /// </summary> /// <param name="ma">Effect to fold over</param> /// <param name="state">Initial state</param> /// <param name="fold">Folder function</param> /// <param name="pred">Predicate function - when this returns false, the fold ends</param> /// <typeparam name="RT">Runtime</typeparam> /// <typeparam name="S">State type</typeparam> /// <typeparam name="A">Bound value type</typeparam> /// <returns>The result of the fold operation</returns> public static Aff <RT, S> foldWhile <RT, S, A>(Aff <RT, A> ma, S state, Func <S, A, S> fold, Func <A, bool> pred) where RT : struct, HasCancel <RT> => ScheduleAff <RT, A> .FoldWhile(ma, Schedule.Forever, state, fold, pred);
/// <summary> /// Fold over the effect repeatedly until the schedule expires, the effect fails, or the predicate returns false /// </summary> /// <param name="ma">Effect to fold over</param> /// <param name="schedule">Scheduler that controls the number of folds and the delay between each fold iteration</param> /// <param name="state">Initial state</param> /// <param name="fold">Folder function</param> /// <param name="pred">Predicate function - when this returns false, the fold ends</param> /// <typeparam name="S">State type</typeparam> /// <typeparam name="A">Bound value type</typeparam> /// <returns>The result of the fold operation</returns> public static Aff <S> foldWhile <S, A>(Schedule schedule, Aff <A> ma, S state, Func <S, A, S> fold, Func <A, bool> pred) => ScheduleAff <A> .FoldWhile(ma, schedule, state, fold, pred);