/// <summary> /// Fold over the effect repeatedly until the effect fails /// </summary> /// <param name="ma">Effect to fold over</param> /// <param name="state">Initial state</param> /// <param name="fold">Folder function</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> fold <RT, S, A>(Aff <RT, A> ma, S state, Func <S, A, S> fold) where RT : struct, HasCancel <RT> => ScheduleAff <RT, A> .Fold(ma, Schedule.Forever, state, fold);
/// <summary> /// Fold over the effect repeatedly until the schedule expires or the effect fails /// </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> /// <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> fold <S, A>(Schedule schedule, Aff <A> ma, S state, Func <S, A, S> fold) => ScheduleAff <A> .Fold(ma, schedule, state, fold);
/// <summary> /// Fold over the effect repeatedly until the effect fails /// </summary> /// <param name="ma">Effect to fold over</param> /// <param name="state">Initial state</param> /// <param name="fold">Folder function</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> fold <S, A>(Aff <A> ma, S state, Func <S, A, S> fold) => ScheduleAff <A> .Fold(ma, Schedule.Forever, state, fold);
/// <summary> /// Fold over the effect repeatedly until the schedule expires or the effect fails /// </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> /// <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> Fold <RT, S, A>(this Aff <RT, A> ma, Schedule schedule, S state, Func <S, A, S> fold) where RT : struct, HasCancel <RT> => ScheduleAff <RT, A> .Fold(ma, schedule, state, fold);