Typle.Type
(Typle v0.1.0)
View Source
Representation of Elixir set-theoretic types.
Each type is a struct with a kind field indicating the type category
and a params field carrying kind-specific data. The dynamic? flag
indicates whether the type is wrapped in dynamic().
Summary
Functions
Returns the atom() type, optionally with a literal value.
Returns the binary() type.
Returns the bitstring() type.
Returns true or false -- the boolean type.
Returns dynamic() or dynamic(inner).
Returns the empty_list() type.
Returns the float() type.
Returns a function() type with the given clauses.
Returns the integer() type.
Returns an intersection of the given types. Single-element intersections collapse.
Returns a list() type with the given element type (defaults to term()).
Returns a map() type with optional keys and open/closed flag.
Returns the negation of the given type.
Returns the none() type (bottom type, empty set).
Returns true if the type represents the empty/bottom type.
Returns integer() or float() -- the number type.
Returns an open tuple type (at least the given elements, possibly more).
Returns the pid() type.
Returns the port() type.
Returns the reference() type.
Returns the term() type (top type, set of all values).
Returns true if the type represents the unknown/top type.
Formats the type using Elixir's type notation.
Returns a closed tuple type with the given element types.
Returns a union of the given types. Single-element unions collapse.
Types
Functions
Returns the atom() type, optionally with a literal value.
@spec binary() :: t()
Returns the binary() type.
@spec bitstring() :: t()
Returns the bitstring() type.
@spec boolean() :: t()
Returns true or false -- the boolean type.
Returns dynamic() or dynamic(inner).
@spec empty_list() :: t()
Returns the empty_list() type.
@spec float() :: t()
Returns the float() type.
Returns a function() type with the given clauses.
@spec integer() :: t()
Returns the integer() type.
Returns an intersection of the given types. Single-element intersections collapse.
Returns a list() type with the given element type (defaults to term()).
Returns a map() type with optional keys and open/closed flag.
Returns the negation of the given type.
@spec none() :: t()
Returns the none() type (bottom type, empty set).
Returns true if the type represents the empty/bottom type.
@spec number() :: t()
Returns integer() or float() -- the number type.
Returns an open tuple type (at least the given elements, possibly more).
@spec pid() :: t()
Returns the pid() type.
@spec port() :: t()
Returns the port() type.
@spec reference() :: t()
Returns the reference() type.
@spec term() :: t()
Returns the term() type (top type, set of all values).
Returns true if the type represents the unknown/top type.
Formats the type using Elixir's type notation.
Examples
iex> Typle.Type.to_string(Typle.Type.integer())
"integer()"
iex> Typle.Type.to_string(Typle.Type.union([Typle.Type.atom(:ok), Typle.Type.atom(:error)]))
":error or :ok"
Returns a closed tuple type with the given element types.
Returns a union of the given types. Single-element unions collapse.