@@ -216,69 +216,7 @@ type TaskBuilder() =
216216 sm.Data.MethodBuilder.Start(& sm)
217217 sm.Data.MethodBuilder.Task))
218218 else
219- TaskBuilder.RunDynamic( code)
220-
221- // This is required for type inference in tasks cases
222- member inline this.MergeSources ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
223- : Task < ^TResult1 * ^TResult2 > =
224- this.Run(
225- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
226- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
227- this.Return( result1, result2)
228- )
229- )
230- )
231-
232- // This is required for type inference in tasks cases
233- member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
234- when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
235- and ^Awaiter2 :> ICriticalNotifyCompletion
236- and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
237- and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
238- ( task1 : Task < ^TResult1 >, task2 : ^TaskLike2 )
239- : Task < ^TResult1 * ^TResult2 > =
240- this.Run(
241- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
242- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
243- this.Return( result1, result2)
244- )
245- )
246- )
247-
248- // This is required for type inference in tasks cases
249- member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
250- when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
251- and ^Awaiter1 :> ICriticalNotifyCompletion
252- and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
253- and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
254- ( task1 : ^TaskLike1 , task2 : Task < ^TResult2 >)
255- : Task < ^TResult1 * ^TResult2 > =
256- this.Run(
257- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
258- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
259- this.Return( result1, result2)
260- )
261- )
262- )
263-
264- member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
265- when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
266- and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
267- and ^Awaiter1 :> ICriticalNotifyCompletion
268- and ^Awaiter2 :> ICriticalNotifyCompletion
269- and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
270- and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
271- and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
272- and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
273- ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
274- : Task < ^TResult1 * ^TResult2 > =
275- this.Run(
276- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
277- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
278- this.Return( result1, result2)
279- )
280- )
281- )
219+ TaskBuilder.RunDynamic( code)
282220
283221type BackgroundTaskBuilder () =
284222
@@ -334,7 +272,6 @@ type BackgroundTaskBuilder() =
334272 else
335273 BackgroundTaskBuilder.RunDynamic( code)
336274
337-
338275module TaskBuilder =
339276
340277 let task = TaskBuilder()
@@ -500,3 +437,67 @@ module MediumPriority =
500437
501438 member inline this.ReturnFrom ( computation : Async < 'T >) : TaskCode < 'T , 'T > =
502439 this.ReturnFrom( Async.StartImmediateAsTask computation)
440+
441+ type TaskBuilder with
442+
443+ // This is required for type inference in tasks cases
444+ member inline this.MergeSources ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
445+ : Task < ^TResult1 * ^TResult2 > =
446+ this.Run(
447+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
448+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
449+ this.Return( result1, result2)
450+ )
451+ )
452+ )
453+
454+ // This is required for type inference in tasks cases
455+ member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
456+ when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
457+ and ^Awaiter2 :> ICriticalNotifyCompletion
458+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
459+ and ^Awaiter2 : ( member GetResult : unit -> 'TResult2 )>
460+ ( task1 : Task < ^TResult1 >, task2 : ^TaskLike2 )
461+ : Task < ^TResult1 * ^TResult2 > =
462+ this.Run(
463+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
464+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
465+ this.Return( result1, result2)
466+ )
467+ )
468+ )
469+
470+ // This is required for type inference in tasks cases
471+ member inline this.MergeSources < ^TaskLike1 , ^TResult1 , ^TResult2 , ^Awaiter1
472+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
473+ and ^Awaiter1 :> ICriticalNotifyCompletion
474+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
475+ and ^Awaiter1 : ( member GetResult : unit -> 'TResult1 )>
476+ ( task1 : ^TaskLike1 , task2 : Task < ^TResult2 >)
477+ : Task < ^TResult1 * ^TResult2 > =
478+ this.Run(
479+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
480+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
481+ this.Return( result1, result2)
482+ )
483+ )
484+ )
485+
486+ member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
487+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
488+ and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
489+ and ^Awaiter1 :> ICriticalNotifyCompletion
490+ and ^Awaiter2 :> ICriticalNotifyCompletion
491+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
492+ and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
493+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
494+ and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
495+ ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
496+ : Task < ^TResult1 * ^TResult2 > =
497+ this.Run(
498+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
499+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
500+ this.Return( result1, result2)
501+ )
502+ )
503+ )
0 commit comments