garuma / Neteril.ComputationExpression

A generic re-implementation of F# computation expressions in C# by (ab)using async/await
Apache License 2.0
25 stars 2 forks source link

Wow! #1

Open desarrollo03TR opened 6 years ago

desarrollo03TR commented 6 years ago

I love it!, Im implementing your library with my own "monadic" types because linq has several limitations.

I have some questions:

is it possible to implement the "computation expressions" with types like Task or Nullable?

is it possible to implement the return! (like in F#)? Something like:

var result =
    option(() => {
        var val1 = await DoSomething(120);
        var val2 = await DoSomething(val1);
        var val3 = await DoSomething(val2);
        if (val3 > 0) 
            return val3;
        else
            return await Option.None<int>();
   });
desarrollo03TR commented 6 years ago

I did some changes to the MonadAsyncMethodBuilder class and now I can use Task, I guess that for Nullable I need to create a new class.

Also, I can use:

return await Option.None<int>();

inside the computation and it works;