public async Task Handle <TValue>(EffStateMachine <TValue> stateMachine) { var result = await MaybeEffectHandler.Run(stateMachine); if (result.HasValue) { await ContinueStateMachine(); } }
public static async Task <Maybe <TResult> > Run <TResult>(Eff <TResult> eff) { var stateMachine = eff.GetStateMachine(); var handler = new MaybeEffectHandler <TResult>(); await handler.Handle(stateMachine); return(stateMachine.IsCompleted ? Maybe <TResult> .Just(stateMachine.GetResult()) : Maybe <TResult> .Nothing); }
/// <summary> /// Executes the state machine to completion using maybe semantics, /// appending any results to the handler state. /// </summary> private async Task ContinueStateMachine() { Result = await MaybeEffectHandler.Run(_stateMachine); }
static async Task Main() { await MaybeEffectHandler.Run(Test()); }