September 2013
Intermediate to advanced
548 pages
12h 25m
English
So far, we have introduced types through informal descriptions. To make full use of the type system, we need to understand the type grammar so we can read and write more precise type descriptions.
Types are defined informally using the following syntax:
| | T1 :: A | B | C ... |
This means that T1 is defined to be one of
A, B, or C.
Using this notation, we can define a subset of Erlang types as follows:
| | Type :: any() | none() | pid() | port() | reference() | [] |
| | | Atom | binary() | float() | Fun | Integer | [Type] | |
| | | Tuple | Union | UserDefined |
| | |
| | Union :: Type1 | Type2 | ... |
| | |
| | Atom :: atom() | Erlang_Atom |
| | |
| | Integer :: integer() | Min .. Max |
| | |
| | Fun :: fun() | fun((...) -> Type) |
| | |
| | Tuple :: tuple() ... |
Read now
Unlock full access