View Source TypeCheck.Builtin.FixedList (TypeCheck v0.13.5)

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

@type 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: non_neg_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: non_neg_integer()},
   list()}
@type t() :: %TypeCheck.Builtin.FixedList{element_types: [TypeCheck.Type.t()]}

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

Full definition:

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