# parallelZip

### CancellableTaskValidation.parallelZip

Namespace: `FsToolkit.ErrorHandling`

Function Signature:

```fsharp
CancellableTaskValidation<'left, 'error>
  -> CancellableTaskValidation<'right, 'error>
  -> CancellableTaskValidation<'left * 'right, 'error>
```

Takes two `CancellableTaskValidation` values, starts them **concurrently**, and returns a tuple of the results once both complete. Errors from both computations are **accumulated** — if both return `Error`, all errors are collected into a single list.

Unlike [`zip`](/fstoolkit-errorhandling/fstoolkit.errorhandling.icedtasks/index-1/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 while collecting any errors:

```fsharp
let validateUserAndRole (userId: UserId) : CancellableTaskValidation<User * Role, string> =
    CancellableTaskValidation.parallelZip
        (fetchAndValidateUser userId)
        (fetchAndValidateRole userId)
```

#### Example 2

Using `parallelZip` inside a computation expression:

```fsharp
let buildProfile (userId: UserId) : CancellableTaskValidation<UserProfile, string> =
    cancellableTaskValidation {
        let! user, preferences =
            CancellableTaskValidation.parallelZip
                (fetchUser userId)
                (fetchPreferences userId)
        return UserProfile.create user preferences
    }
```

#### Example 3

Concurrently validating independent fields and accumulating all errors:

```fsharp
let validateSignupForm (form: SignupForm) : CancellableTaskValidation<ValidEmail * ValidUsername, string> =
    CancellableTaskValidation.parallelZip
        (validateEmail form.Email)       // e.g. Error ["Invalid email format"]
        (validateUsername form.Username) // e.g. Error ["Username too short"]
    // Both run concurrently; if both fail: Error ["Invalid email format"; "Username too short"]
```


---

# 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-1/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.
