TypeCheck v0.2.0 TypeCheck.Builtin.FixedList View Source

Checks whether the value is a list with the expected elements

On failure returns a problem tuple with:

  • :not_a_list if the value is not a list
  • :different_length if the value is a list but not of equal size.
  • :element_error if one of the elements does not match. The extra information contains in this case :problem and :index to indicate what and where the problem occured.

Link to this section Summary

Types

This type is managed by TypeCheck, which allows checking values against the type at runtime.

t()

This type is managed by TypeCheck, which allows checking values against the type at runtime.

Link to this section Types

Specs

problem_tuple() ::
  {t(), :not_a_list, %{}, any()}
  | {t(), :different_length, %{expected_length: non_neg_integer()}, list()}
  | {t(), :element_error,
     %{
       problem: TypeCheck.TypeError.Formatter.problem_tuple(),
       index: integer()
     }, list()}

This type is managed by TypeCheck, which allows checking values against the type at runtime.

Full definition:

problem_tuple :: {t(), :not_a_list, %{}, any()} | {t(), :different_length, %{expected_length: non_neg_integer()}, list()} | {t(), :element_error, %{problem: lazy(TypeCheck.TypeError.Formatter.problem_tuple()), index: integer()}, list()}

Specs

t() :: %TypeCheck.Builtin.FixedList{element_types: list()}

This type is managed by TypeCheck, which allows checking values against the type at runtime.

Full definition:

t :: %TypeCheck.Builtin.FixedList{element_types: list()}