diff --git a/src/FSharpPlus/Extensions/Task.fs b/src/FSharpPlus/Extensions/Task.fs index b10569567..1b87d8653 100644 --- a/src/FSharpPlus/Extensions/Task.fs +++ b/src/FSharpPlus/Extensions/Task.fs @@ -134,6 +134,28 @@ module Task = ) |> ignore) |> ignore) |> ignore tcs.Task + /// Creates a task workflow from two workflows 'x' and 'y', mapping its results with 'f'. + /// Similar to map2 but workflows are run in parallel. + /// The mapping function. + /// First task workflow. + /// Second task workflow. + let pmap2 f x y = task { + let! x' = x + let! y' = y + return f x' y' } + + /// Creates a task workflow from three workflows 'x', 'y' and z, mapping its results with 'f'. + /// Similar to map2 but workflows are run in parallel. + /// The mapping function. + /// First task workflow. + /// Second task workflow. + /// Third task workflow. + let pmap3 f x y z = task { + let! x' = x + let! y' = y + let! z' = z + return f x' y' z' } + /// Creates a task workflow that is the result of applying the resulting function of a task workflow /// to the resulting value of another task workflow /// Task workflow returning a function diff --git a/src/FSharpPlus/Extensions/ValueTask.fs b/src/FSharpPlus/Extensions/ValueTask.fs index 1138bcf5b..669470975 100644 --- a/src/FSharpPlus/Extensions/ValueTask.fs +++ b/src/FSharpPlus/Extensions/ValueTask.fs @@ -62,6 +62,35 @@ module ValueTask = with e -> tcs.SetException e))) tcs.Task |> ValueTask<'W> + /// Creates a task workflow from two workflows 'x' and 'y', mapping its results with 'f'. + /// Similar to map2 but workflows are run in parallel. + /// The mapping function. + /// First ValueTask workflow. + /// Second ValueTask workflow. + /// Third ValueTask workflow. + let pmap2 (f: 'T -> 'U -> 'V) (x: ValueTask<'T>) (y: ValueTask<'U>) : ValueTask<'V> = + task { + let! x' = x + let! y' = y + return f x' y' + } + |> ValueTask<'V> + + /// Creates a ValueTask workflow from three workflows 'x', 'y' and z, mapping its results with 'f'. + /// Similar to map3 but workflows are run in parallel. + /// The mapping function. + /// First ValueTask workflow. + /// Second ValueTask workflow. + /// Third ValueTask workflow. + let pmap3 (f: 'T -> 'U -> 'V -> 'W) (x: ValueTask<'T>) (y: ValueTask<'U>) (z: ValueTask<'V>) : ValueTask<'W> = + task { + let! x' = x + let! y' = y + let! z' = z + return f x' y' z' + } + |> ValueTask<'W> + /// Creates a ValueTask workflow that is the result of applying the resulting function of a ValueTask workflow /// to the resulting value of another ValueTask workflow /// ValueTask workflow returning a function