enough-garden-22763
05/25/2021, 4:11 PMTask
and Task<T>
, and correspondingly do we want to model something similar to value-less Task
in the Output<T>
layer? I am going for Output<Object>
carrying a null
to correspond to “value-less” task. I really like how F# does it with unit
type but that seems to not to be in .NET stdlib.bored-oyster-3147
05/25/2021, 4:15 PMTask<T>
can implicitly be cast to Task
but if you want to go the other direction you need to know what TResult
is. Because you'd need to do something like if (nonGenericTask is Task<T> genericTask)
Curious what use-case is for a value-less Output<T>
enough-garden-22763
05/25/2021, 4:16 PMTask
so caller can wait on it). And my lifted version is trying to lift that Task to Output.bored-oyster-3147
05/25/2021, 4:19 PMenough-garden-22763
05/25/2021, 4:21 PMApply
version of the same function https://gist.github.com/t0yv0/a9139fd04f28a5d4e8f1cf20909023ae#file-codegen-cs-L22 - let me use Apply
version instead of “lifted” sorry for misplaced jargon 🙂bored-oyster-3147
05/25/2021, 4:22 PMenough-garden-22763
05/25/2021, 4:22 PMbored-oyster-3147
05/25/2021, 4:26 PMTask
? Are consumers still passing something along from that such that it needs to be Output
?enough-garden-22763
05/25/2021, 4:27 PMInput<T>
.Task<T> AwaitInput<T>(Input<T> input)
bored-oyster-3147
05/25/2021, 4:27 PMInput<T>
but returns Task
?enough-garden-22763
05/25/2021, 4:27 PMbored-oyster-3147
05/25/2021, 4:28 PMawait
the functions that have no results but not the ones that doenough-garden-22763
05/25/2021, 4:31 PMpublic static Task Apply(FuncWithConstInputApplyArgs? args = null, InvokeOptions? options = null)
{
var promise = new TaskCompletionSource();
args.PlainInput.Apply(t => {
var plainArgs = new FuncWithConstInputArgs
{
PlainInput = t
};
InvokeAsync(plainArgs, options).ContinueWith(t => CopyTaskStateTo(t, promise));
return t;
});
return promise.Task;
}
public static void CopyTaskStateTo(Task t, TaskCompletionSource promise) {
if (t.IsCompletedSuccessfully)
{
promise.SetResult();
}
else if (t.IsFaulted)
{
promise.SetException(t.Exception);
}
else
{
promise.SetCanceled();
}
}
Output<Object>
since users will be wondering what is that and what is the null in there.bored-oyster-3147
05/25/2021, 4:57 PM