Esempio n. 1
0
            public async Task Handle <TValue>(EffStateMachine <TValue> stateMachine)
            {
                var result = await MaybeEffectHandler.Run(stateMachine);

                if (result.HasValue)
                {
                    await ContinueStateMachine();
                }
            }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 /// <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);
 }
Esempio n. 4
0
 static async Task Main()
 {
     await MaybeEffectHandler.Run(Test());
 }