Type.Helpers behaviour (mavis v0.0.3) View Source
Link to this section Summary
Functions
Wraps the Type.Helpers.group_compare/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Wraps the Type.Properties.intersection/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Wraps the Type.Properties.subtype?/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Wraps the Type.Properties.usable_as/3
function headers in common prologue and
fallback clauses. This prevents errors from being made in code that must be common to all types.
Callbacks
Type modules should implement this function to perform comparisons against all other types in their type group.
Link to this section Functions
Wraps the Type.Helpers.group_compare/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Prologue function matches:
- matches identical types and reports equality
- matches
String.t/0
special case (only forType.Bitstring
) - compares union types and puts them in
- compares opaque types
- compares function var types
Wraps the Type.Properties.intersection/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Prologue function matches:
- matches itself and returns itself
- matches
any/0
and returns itself - calculates intersections for remote types
- intersects union types
- intersects function var types
Wraps the Type.Properties.subtype?/2
function headers in a common prologue.
This prevents errors from being made in code that must be common to all types.
Prologue function matches:
- matches itself and returns true
- matches
none/0
and returns false - matches
any/0
and returns any - calculates intersections for remote types
- intersects union types
- intersects function var types
can also take :usable_as
as an argument; this declares that subtype?/2
is
equivalent to an :ok
response from Type.usable_as/3
.
Wraps the Type.Properties.usable_as/3
function headers in common prologue and
fallback clauses. This prevents errors from being made in code that must be common to all types.
Prologue function matches:
- matches equal types and makes them output :ok
- matches usable_as with
builtin(:any)
and makes them output :ok
Fallback function matches:
- catches usable_as against unions; and performs the appropriate attempt to match into each of the union's subtypes.
- catches all other attempts to run usable_as, and returns
{:error, metadata}
Link to this section Callbacks
Specs
Type modules should implement this function to perform comparisons against all other types in their type group.
See Type.typegroup/1