# `Mojoler.Dsl.Arith`
[🔗](https://github.com/thanos/mojoler/blob/v0.1.0/lib/mojoler/dsl/arith.ex#L1)

Checked addition generated from `tools/dsl/decls.json`.

The native wrapper decodes the terms and calls `checked_add` in
`native/examples/arith_user.mojo`. This module does not declare the NIF entry.

# `add`

```elixir
@spec add(integer(), integer()) :: {:ok, integer()} | {:error, :overflow}
```

Adds `a` and `b` as signed 64-bit integers.

Both arguments are required integers. There is no optional argument.

## Returns

  * `{:ok, sum}` when the sum fits
  * `{:error, :overflow}` when it does not

## Raises

  * `ArgumentError` when `a` or `b` is not an integer in signed 64 bits

## Examples

    iex> Mojoler.Dsl.Arith.add(20, 22)
    {:ok, 42}

    iex> Mojoler.Dsl.Arith.add(9_223_372_036_854_775_807, 1)
    {:error, :overflow}

    iex> Mojoler.Dsl.Arith.add(1, :nope)
    ** (ArgumentError) argument error

# `load_nif`

```elixir
@spec load_nif() :: :ok | {:error, term()}
```

Loads `priv/native/libdsl_arith.so`.

A second call returns `{:error, {:reload, charlist}}`.

## Examples

    iex> Mojoler.Dsl.Arith.load_nif()
    {:error, {:reload, ~c"NIF library already loaded (reload disallowed since OTP 20)."}}

---

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