# Computation Expression

### JobResultOption Computation Expression

Namespace: `FsToolkit.ErrorHandling`

### Examples

#### Example 1

Given the following functions:

```fsharp
getUserById : UserId -> Job<Result<User option, exn>>
getPostById : PostId -> Job<Result<Post option, exn>>
```

We can compose them using the `jobResultOption` computation expression:

```fsharp
// Job<Result<(User * Post) option, exn>>
jobResultOption {
  let! post = getPostById samplePostId
  let! user = getUserById post.UserId
  return (user, post)
}
```

#### Example 2

```fsharp
tryFindUser : string -> Job<Result<User option, string>>
tryFindPost : string -> Job<Result<Post option, string>>

// Job<Result<string option, string>>
let result = jobResultOption {
  let! user = tryFindUser "alice"
  let! post = tryFindPost "my-post"
  return sprintf "%s wrote: %s" user.Name post.Title
}
```


---

# 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.jobresult/jobresultoption/ce.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.
