public static async Task LinqIoTest() { var init = 5; var console = new List <string>(); var computation = from x in MaybeT.Lift(new Io <int>(() => Task.FromResult(1))) from y in MaybeT.Lift(Io.AsIo(() => Task.FromResult(2))) from _ in MaybeT.HoistIo(Maybe.JustIf(init > 0, () => new Unit())) from z in MaybeT.Lift(Io.AsIo(() => { console.Add("func run"); return(Task.FromResult(init)); })) select x + y + z; var value = await computation.Run.Run(); Assert.True(value.HasValue); Assert.Equal(1 + 2 + init, value.Value()); Assert.Single(console); init = 0; console = new List <string>(); value = await computation.Run.Run(); Assert.False(value.HasValue); Assert.Empty(console); }