# `ToolCall.TypeExpr.Projection`

Exact set operations on `ToolCall.TypeExpr`, used to lower intersections and
negations before they reach `ToolCall.IR.Type`.

JSON Schema cannot carry an arbitrary intersection or complement, so each
operation either returns a value that is *exactly* the intersection (or
difference) or reports `:error`. A caller that receives `:error` must degrade
explicitly rather than approximate the type — silently widening to `anyOf` or
`any` would tell the model the wrong contract.

Supported exactly today:

  * `:any` and `:none` identities
  * integer ranges and `integer()`, including disjoint ranges (an empty
    intersection, and a difference that splits into at most two ranges)
  * `{:literal, value}` against literals and enums
  * enums against enums
  * maps whose fields and additional properties can be merged
  * identical nodes

# `result`

```elixir
@type result() :: {:ok, ToolCall.TypeExpr.t()} | :error
```

# `intersect`

```elixir
@spec intersect(ToolCall.TypeExpr.t(), ToolCall.TypeExpr.t()) :: result()
```

Intersects two type expressions.

A `{:negation, inner}` operand is handled as a difference, so
`atom() and not nil` lowers without ever emitting a JSON Schema `not`.

# `subtract`

```elixir
@spec subtract(ToolCall.TypeExpr.t(), ToolCall.TypeExpr.t()) :: result()
```

Subtracts `right` from `left`, producing the type of values in `left` that are
not in `right`.

---

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