# Use a Typespec function type

**URL:** <https://forum.elixirforum.com/t/use-a-typespec-function-type/55012>\
**Category:** Questions\
**Tags:** spec\
**Created:** [April 3, 2023, 7:53pm UTC](https://forum.elixirforum.com/t/use-a-typespec-function-type/55012 "2023-04-03T19:53:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![zachallaun](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachallaun/32/29208_2.png) [@zachallaun](https://forum.elixirforum.com/u/zachallaun)\
**Post date:** [April 3, 2023, 8:13pm UTC](https://forum.elixirforum.com/t/use-a-typespec-function-type/55012/2 "2023-04-03T20:13:51Z")

</div>

This is accomplished using behaviours:

```elixir
defmodule A do
  @callback simple_function(integer()) :: non_neg_integer()
end

defmodule B do
  @behaviour A

  @impl A
  def simple_function(int), do: ...
end

```

I’ll add, however, that it’s not advisable to create behaviours if your goal is really only to re-use some typespecs. Two different functions sharing a common, duplicated typespec is not a code smell.

---

_[View the full topic](https://forum.elixirforum.com/t/use-a-typespec-function-type/55012)._
