# `Diffo.Type.Primitive`
[🔗](https://github.com/diffo-dev/diffo/blob/v0.9.0/lib/diffo/type/primitive.ex#L4)

`Diffo.Type.Primitive` is a discriminated union of primitive types: string, integer, float,
boolean, date, time, datetime, and duration.

Use `wrap/2` to construct a Primitive from a type name string and a value.
Use `Diffo.Unwrap.unwrap/1` to extract the value.
Outstanding comparison is implemented inline via `defoutstanding`.

> #### Temporal types {: .info}
>
> Date, time, datetime, and duration values are stored internally as ISO 8601 strings
> to avoid nested serialisation issues. `Diffo.Unwrap.unwrap/1` returns the string form.

## Examples

    iex> Diffo.Type.Primitive.wrap("string", "connectivity") |> Diffo.Unwrap.unwrap()
    "connectivity"

    iex> Diffo.Type.Primitive.wrap("integer", 42) |> Diffo.Unwrap.unwrap()
    42

    iex> Diffo.Type.Primitive.wrap("float", 3.14) |> Diffo.Unwrap.unwrap()
    3.14

    iex> Diffo.Type.Primitive.wrap("boolean", false) |> Diffo.Unwrap.unwrap()
    false

    iex> Diffo.Type.Primitive.wrap("date", ~D[2026-04-24]) |> Diffo.Unwrap.unwrap()
    "2026-04-24"

    iex> Diffo.Type.Primitive.wrap("unknown", "x")
    nil

# `handle_change?`

# `new`

Create a new Elixir.Diffo.Type.Primitive, or return an error

# `new!`

# `prepare_change?`

# `wrap`

---

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