@@ -370,7 +370,48 @@ module LowPriority =
370370 =
371371 ResumableCode.Using( resource, body)
372372
373+ type TaskBuilder with
374+ member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
375+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
376+ and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
377+ and ^Awaiter1 :> ICriticalNotifyCompletion
378+ and ^Awaiter2 :> ICriticalNotifyCompletion
379+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
380+ and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
381+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
382+ and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
383+ ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
384+ : Task < struct ( ^TResult1 * ^TResult2 )> =
385+ this.Run(
386+ this.Bind(
387+ task1,
388+ fun ( result1 : ^TResult1 ) ->
389+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
390+ )
391+ )
392+
393+ type BackgroundTaskBuilder with
394+ member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
395+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
396+ and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
397+ and ^Awaiter1 :> ICriticalNotifyCompletion
398+ and ^Awaiter2 :> ICriticalNotifyCompletion
399+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
400+ and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
401+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
402+ and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
403+ ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
404+ : Task < struct ( ^TResult1 * ^TResult2 )> =
405+ this.Run(
406+ this.Bind(
407+ task1,
408+ fun ( result1 : ^TResult1 ) ->
409+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
410+ )
411+ )
412+
373413module HighPriority =
414+
374415 // High priority extensions
375416 type TaskBuilderBase with
376417
@@ -424,7 +465,36 @@ module HighPriority =
424465 member inline this.ReturnFrom ( task : Task < 'T >) : TaskCode < 'T , 'T > =
425466 this.Bind( task, this.Return)
426467
468+ type TaskBuilder with
469+
470+ // This overload is required for type inference in tasks cases
471+ member inline this.MergeSources
472+ ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
473+ : Task < struct ( ^TResult1 * ^TResult2 )> =
474+ this.Run(
475+ this.Bind(
476+ task1,
477+ fun ( result1 : ^TResult1 ) ->
478+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
479+ )
480+ )
481+
482+ type BackgroundTaskBuilder with
483+
484+ // This overload is required for type inference in tasks cases
485+ member inline this.MergeSources
486+ ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
487+ : Task < struct ( ^TResult1 * ^TResult2 )> =
488+ this.Run(
489+ this.Bind(
490+ task1,
491+ fun ( result1 : ^TResult1 ) ->
492+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
493+ )
494+ )
495+
427496module MediumPriority =
497+ open LowPriority
428498 open HighPriority
429499
430500 // Medium priority extensions
@@ -437,3 +507,213 @@ module MediumPriority =
437507
438508 member inline this.ReturnFrom ( computation : Async < 'T >) : TaskCode < 'T , 'T > =
439509 this.ReturnFrom( Async.StartImmediateAsTask computation)
510+
511+ type TaskBuilder with
512+
513+ // This overload is required for type inference in tasks cases
514+ member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
515+ when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
516+ and ^Awaiter2 :> ICriticalNotifyCompletion
517+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
518+ and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
519+ ( task1 : Task < ^TResult1 >, task2 : ^TaskLike2 )
520+ : Task < struct ( ^TResult1 * ^TResult2 )> =
521+ this.Run(
522+ this.Bind(
523+ task1,
524+ fun ( result1 : ^TResult1 ) ->
525+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
526+ )
527+ )
528+
529+ // This overload is required for type inference in tasks cases
530+ member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
531+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
532+ and ^Awaiter1 :> ICriticalNotifyCompletion
533+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
534+ and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
535+ ( task1 : ^TaskLike1 , task2 : Task < ^TResult2 >)
536+ : Task < struct ( ^TResult1 * ^TResult2 )> =
537+ this.Run(
538+ this.Bind(
539+ task1,
540+ fun ( result1 : ^TResult1 ) ->
541+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
542+ )
543+ )
544+
545+ // This overload is required for type inference in async cases
546+ member inline this.MergeSources
547+ ( computation1 : Async < ^TResult1 >, computation2 : Async < ^TResult2 >)
548+ : Task < struct ( ^TResult1 * ^TResult2 )> =
549+ this.Run(
550+ this.Bind(
551+ computation1,
552+ fun ( result1 : ^TResult1 ) ->
553+ this.Bind( computation2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
554+ )
555+ )
556+
557+ // This overload is required for type inference in task + async cases
558+ member inline this.MergeSources
559+ ( task : Task < ^TResult1 >, computation : Async < ^TResult2 >)
560+ : Task < struct ( ^TResult1 * ^TResult2 )> =
561+ this.Run(
562+ this.Bind(
563+ task,
564+ fun ( result1 : ^TResult1 ) ->
565+ this.Bind( computation, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
566+ )
567+ )
568+
569+ // This overload is required for type inference in async + task case
570+ member inline this.MergeSources
571+ ( computation : Async < ^TResult1 >, task : Task < ^TResult2 >)
572+ : Task < struct ( ^TResult1 * ^TResult2 )> =
573+ this.Run(
574+ this.Bind(
575+ computation,
576+ fun ( result1 : ^TResult1 ) ->
577+ this.Bind( task, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
578+ )
579+ )
580+
581+ type BackgroundTaskBuilder with
582+
583+ // This overload is required for type inference in tasks cases
584+ member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
585+ when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
586+ and ^Awaiter2 :> ICriticalNotifyCompletion
587+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
588+ and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
589+ ( task1 : Task < ^TResult1 >, task2 : ^TaskLike2 )
590+ : Task < struct ( ^TResult1 * ^TResult2 )> =
591+ this.Run(
592+ this.Bind(
593+ task1,
594+ fun ( result1 : ^TResult1 ) ->
595+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
596+ )
597+ )
598+
599+ // This overload is required for type inference in tasks cases
600+ member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
601+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
602+ and ^Awaiter1 :> ICriticalNotifyCompletion
603+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
604+ and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
605+ ( task1 : ^TaskLike1 , task2 : Task < ^TResult2 >)
606+ : Task < struct ( ^TResult1 * ^TResult2 )> =
607+ this.Run(
608+ this.Bind(
609+ task1,
610+ fun ( result1 : ^TResult1 ) ->
611+ this.Bind( task2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
612+ )
613+ )
614+
615+ // This overload is required for type inference in async cases
616+ member inline this.MergeSources
617+ ( computation1 : Async < ^TResult1 >, computation2 : Async < ^TResult2 >)
618+ : Task < struct ( ^TResult1 * ^TResult2 )> =
619+ this.Run(
620+ this.Bind(
621+ computation1,
622+ fun ( result1 : ^TResult1 ) ->
623+ this.Bind( computation2, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
624+ )
625+ )
626+
627+ // This overload is required for type inference in task + async cases
628+ member inline this.MergeSources
629+ ( task : Task < ^TResult1 >, computation : Async < ^TResult2 >)
630+ : Task < struct ( ^TResult1 * ^TResult2 )> =
631+ this.Run(
632+ this.Bind(
633+ task,
634+ fun ( result1 : ^TResult1 ) ->
635+ this.Bind( computation, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
636+ )
637+ )
638+
639+ // This overload is required for type inference in async + task case
640+ member inline this.MergeSources
641+ ( computation : Async < ^TResult1 >, task : Task < ^TResult2 >)
642+ : Task < struct ( ^TResult1 * ^TResult2 )> =
643+ this.Run(
644+ this.Bind(
645+ computation,
646+ fun ( result1 : ^TResult1 ) ->
647+ this.Bind( task, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
648+ )
649+ )
650+
651+ module LowPlusPriority =
652+ open LowPriority
653+ open MediumPriority
654+
655+ type TaskBuilder with
656+ // This overload is required for type inference in async cases
657+ member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
658+ when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
659+ and ^Awaiter2 :> ICriticalNotifyCompletion
660+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
661+ and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
662+ ( computation : Async < ^TResult1 >, task : ^TaskLike2 )
663+ : Task < struct ( ^TResult1 * ^TResult2 )> =
664+ this.Run(
665+ this.Bind(
666+ computation,
667+ fun ( result1 : ^TResult1 ) ->
668+ this.Bind( task, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
669+ )
670+ )
671+
672+ // This overload is required for type inference in async cases
673+ member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
674+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
675+ and ^Awaiter1 :> ICriticalNotifyCompletion
676+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
677+ and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
678+ ( task : ^TaskLike1 , computation : Async < ^TResult2 >)
679+ : Task < struct ( ^TResult1 * ^TResult2 )> =
680+ this.Run(
681+ this.Bind(
682+ task,
683+ fun ( result1 : ^TResult1 ) ->
684+ this.Bind( computation, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
685+ )
686+ )
687+
688+ type BackgroundTaskBuilder with
689+ // This overload is required for type inference in async cases
690+ member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
691+ when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
692+ and ^Awaiter2 :> ICriticalNotifyCompletion
693+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
694+ and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
695+ ( computation : Async < ^TResult1 >, task : ^TaskLike2 )
696+ : Task < struct ( ^TResult1 * ^TResult2 )> =
697+ this.Run(
698+ this.Bind(
699+ computation,
700+ fun ( result1 : ^TResult1 ) ->
701+ this.Bind( task, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
702+ )
703+ )
704+
705+ // This overload is required for type inference in async cases
706+ member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
707+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
708+ and ^Awaiter1 :> ICriticalNotifyCompletion
709+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
710+ and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
711+ ( task : ^TaskLike1 , computation : Async < ^TResult2 >)
712+ : Task < struct ( ^TResult1 * ^TResult2 )> =
713+ this.Run(
714+ this.Bind(
715+ task,
716+ fun ( result1 : ^TResult1 ) ->
717+ this.Bind( computation, fun ( result2 : ^TResult2 ) -> this.Return struct ( result1, result2))
718+ )
719+ )
0 commit comments