View Source Bunch.Typespec (Bunch v1.3.1)
A bunch of typespec-related helpers.
Link to this section Summary
Link to this section Functions
Allows to define a type in form of t :: x | y | z | ...
and a module parameter
in form of @t [x, y, z, ...]
at once.
example
Example
iex> defmodule Abc do
...> use Bunch.Typespec
...> @list_type t :: [:a, :b, :c]
...> @spec get_at(0..2) :: t
...> def get_at(x), do: @t |> Enum.at(x)
...> end
iex> Abc.get_at(1)
:b