# `Skuld.Comp.Cancelled`
[🔗](https://github.com/mccraigmccraig/skuld/blob/main/lib/skuld/comp/cancelled.ex#L1)

Sentinel indicating a computation was cancelled.

Like `Throw`, `Cancelled` goes through the leave_scope chain, allowing
effects to clean up resources (close connections, release locks, etc.)
when a computation is cancelled.

## Usage

When cancelling a suspended computation, use `Skuld.Comp.cancel/2`:

    # Computation yielded a Suspend
    {%Suspend{} = suspend, env} = Comp.run(my_comp)

    # Cancel it (invokes leave_scope chain for cleanup)
    {%Cancelled{reason: :user_cancelled}, final_env} =
      Comp.cancel(suspend, env, :user_cancelled)

## Effect Cleanup

Effects can detect cancellation in their `leave_scope` handler:

    def my_leave_scope(result, env) do
      case result do
        %Cancelled{reason: reason} ->
          cleanup_resources(reason)
          {result, env}

        _ ->
          {result, env}
      end
    end

# `t`

```elixir
@type t() :: %Skuld.Comp.Cancelled{reason: term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
