# `Ash.Type.Function`
[🔗](https://github.com/ash-project/ash/blob/v3.33.1/lib/ash/type/function.ex#L5)

Represents a function.

By default a function is dumped to a native format with
`:erlang.term_to_binary(term, [:safe])`, and this is *NOT SAFE* to use with
external input (see https://erlang.org/doc/man/erlang.html#binary_to_term-2).

With the `mfa` constraint the value is restricted to external captures
(`&Module.function/arity`) and stored as a portable capture string such as
`"&Elixir.MyApp.callback/2"`, late-bound back to the function on read. This
decouples the stored reference from the compiled implementation, so it survives
across VMs and releases where a serialized closure would not.

### Constraints

* `:mfa` (`t:boolean/0`) - Restricts the value to external captures (`&Module.function/arity`), refusing anonymous functions and closures. Only external captures can be stored: a closure captures its environment, which cannot be rehydrated in another VM. The default value is `false`.

* `:arity` (`t:pos_integer/0`) - Enforces a specific arity on the provided function

# `handle_change?`

# `prepare_change?`

---

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