Set-theoretic types cheatsheet
View SourceSet operators
Union
type1 or type2Intersection
type1 and type2Difference
type1 and not type2Negation
not typeData types
Indivisible types
binary()
empty_list()
integer()
float()
pid()
port()
reference()Atoms
All atoms
atom()Individual atoms
:ok
:error
SomeModuleFunctions
All functions
function()n-arity functions
(-> :ok)
(integer() -> boolean())
(binary(), binary() -> binary())Multiple clauses
(integer() -> binary()) and (binary() -> atom())Maps
All maps
map()Empty map
empty_map()Maps with atom keys
# Only has the keys name and age
%{name: binary(), age: integer()}
# Has the name key and age is optional
%{name: binary(), age: if_set(integer())}
# Has the keys name and age and may have other keys (open map)
%{..., name: binary(), age: integer()}
# Has the key name, may have other keys, but age is not set
%{..., name: binary(), age: not_set()}Maps with domain keys (domain keys are always treated as optional)
# Has atom and binary keys
%{atom() => binary(), binary() => binary()}
# Has atom and binary keys and may have other keys (open map)
%{..., atom() => binary(), binary() => binary()}Maps with mixed keys
# Has atom keys with binary values but a `:root` key of type integer
%{atom() => binary(), root: integer()}
# Has atom keys with binary values but a `:root` key of type integer, and may have other keys
%{..., atom() => binary(), root: integer()}Domain keys are atom(), binary(), integer(), float(), fun(), list(), map(), pid(), port(), reference(), tuple()
Non-empty lists
Proper lists
non_empty_list(elem_type)Improper lists (as long as tail_type does not include lists)
non_empty_list(elem_type, tail_type)Tuples
All tuples
tuple()n-element tuples
{:ok, binary()}
{:error, binary(), term()}
{pid(), reference()}At least n-element tuples
{binary(), binary(), ...}Additional types for convenience
Aliases
bitstring() = binary()
boolean() = true or false
number() = integer() or float()The type system currently does not distinguish between binaries and bitstrings.
Lists
list() = empty_list() or non_empty_list(term())
list(a) = empty_list() or non_empty_list(a)
list(a, b) = empty_list() or non_empty_list(a, b)