> For the complete documentation index, see [llms.txt](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/teefunctions.md).

# tee Functions

These functions allow us to execute side effects based on our option. They are useful for logging and other side effects that we want to execute without changing the option.

Consider the following code for the examples below

```fsharp
// string -> unit
let log (message: string) =
    printfn "%s" message
```

## teeSome

If the option is Some, executes the function on the Some value. Passes through the input value unchanged.

### Function Signature

```fsharp
('a -> unit) -> 'a option -> 'a option
```

### Examples

#### Example 1

```fsharp
let option : int option =
    Some 1
    |> Option.teeSome (fun value -> log (sprintf "Value is %i" value))

// Value is 1
// Some 1
```

## teeNone

If the option is None, executes the function. Passes through the input value unchanged.

### Function Signature

```fsharp
(unit -> unit) -> 'a option -> 'a option
```

### Examples

#### Example 1

```fsharp
let option : int option =
    None
    |> Option.teeNone (fun () -> log "Option is None")

// Option is None
// None
```

## teeIf

If the option is Some and the predicate returns true for the wrapped value, executes the function on the Some value. Passes through the input value unchanged.

### Function Signature

```fsharp
('a -> bool) -> ('a -> unit) -> 'a option -> 'a option
```

### Examples

#### Example 1

```fsharp
let option : int option =
    Some 1
    |> Option.teeIf (fun value -> value = 1) (fun value -> log (sprintf "Value is %i" value))

// Value is 1
// Some 1
```

#### Example 2

```fsharp
let option : int option =
    Some 1
    |> Option.teeIf (fun value -> value = 2) (fun value -> log (sprintf "Value is %i" value))

// Some 1
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/option/teefunctions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
