# `ShotDs.Data.Context`
[🔗](https://github.com/jcschuster/ShotDs/blob/v1.0.0/lib/shot_ds/data/context.ex#L1)

Represents a type environment for parsing and type checking. Can also be
created by using the `~e` sigil from `ShotDs.Hol.Sigils`.

## Examples

    iex> Context.new()
    %ShotDs.Data.Context{vars: %{}, consts: %{}, constraints: MapSet.new([])}

    iex> Context.new() |> Context.put_var("X", Type.new(:o))
    %ShotDs.Data.Context{
      vars: %{"X" => %ShotDs.Data.Type{goal: :o, args: []}},
      consts: %{},
      constraints: MapSet.new([])
    }

# `t`

```elixir
@type t() :: %ShotDs.Data.Context{
  constraints: MapSet.t({ShotDs.Data.Type.t(), ShotDs.Data.Type.t()}),
  consts: %{required(String.t()) =&gt; ShotDs.Data.Type.t()},
  vars: %{required(String.t()) =&gt; ShotDs.Data.Type.t()}
}
```

The type of the type environment.

A context contains the type of variables (`:vars`) as a `Map` from its name
to its type. Likewise for the constants (`:consts`). The type constraints
are represented as a `MapSet` of `ShotDs.Data.Type` pairs.

# `add_constraint`

```elixir
@spec add_constraint(t(), ShotDs.Data.Type.t(), ShotDs.Data.Type.t()) :: t()
```

Adds a type constraint to the context.

# `get_type`

```elixir
@spec get_type(t(), String.t()) :: ShotDs.Data.Type.t() | nil
```

Returns the type of the given name of a constant or variable. Returns `nil`
if the name is not present in the context.

# `new`

```elixir
@spec new() :: t()
```

Creates an empty context.

# `put_const`

```elixir
@spec put_const(t(), String.t(), ShotDs.Data.Type.t()) :: t()
```

Associates the constant with the given name with the given type in the
context. Overwrites the old value if present.

# `put_var`

```elixir
@spec put_var(t(), String.t(), ShotDs.Data.Type.t()) :: t()
```

Associates the variable with the given name with the given type in the
context. Overwrites the old value if present.

---

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