# parallelZip

### CancellableTaskResult.parallelZip

Namespace: `FsToolkit.ErrorHandling`

Function Signature:

```fsharp
CancellableTaskResult<'left, 'Error>
  -> CancellableTaskResult<'right, 'Error>
  -> CancellableTaskResult<'left * 'right, 'Error>
```

Takes two `CancellableTaskResult` values, starts them **concurrently**, and returns a tuple of the results once both complete. If either computation returns an `Error`, that error is returned.

Unlike [`zip`](/fstoolkit-errorhandling/fstoolkit.errorhandling.icedtasks/index/zip.md), both computations are started before waiting for either to complete, which can improve throughput when the two operations are independent.

### Examples

#### Example 1

Fetching two independent resources in parallel:

```fsharp
let getUserAndPermissions (userId: UserId) : CancellableTaskResult<User * Permission list, string> =
    CancellableTaskResult.parallelZip
        (fetchUser userId)
        (fetchPermissions userId)
```

#### Example 2

Combining two concurrent API calls in a larger computation:

```fsharp
let loadDashboard (userId: UserId) : CancellableTaskResult<Dashboard, string> =
    cancellableTaskResult {
        let! user, settings =
            CancellableTaskResult.parallelZip
                (fetchUser userId)
                (fetchUserSettings userId)
        return buildDashboard user settings
    }
```

#### Example 3

Unlike [`zip`](/fstoolkit-errorhandling/fstoolkit.errorhandling.icedtasks/index/zip.md), both tasks are started at the same time — neither is skipped even if the other returns an error first:

```fsharp
let validateCredentials (username: string) (password: string) : CancellableTaskResult<User * Role, AuthError> =
    CancellableTaskResult.parallelZip
        (lookupUser username)          // both run concurrently
        (lookupRole username)          // both run concurrently; short-circuits on first Error
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling.icedtasks/index/parallelzip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
