I found the below type specification in Erlang module. I am trying to understand how is it used? Is it similar to record?
-type timestamp() :: {MegaSecs :: non_neg_integer(),
Secs :: non_neg_integer(),
MicroSecs :: non_neg_integer()}.
1条答案
按热度按时间lx0bsm1f1#
I found the below type specification in Erlang module. I am trying to understand how is it used? Is it similar to record?
No, it is a user defined type.
...types can be used to specify types of record fields and also the argument and return types of functions.
Type information can be used for the following:
To document function interfaces
To provide more information for bug detection tools, such as Dialyzer
To be exploited by documentation tools, such as EDoc, for generating program documentation of various forms
For more information about types, see:
http://erlang.org/doc/reference_manual/typespec.html
and:
https://learnyousomeerlang.com/dialyzer
Here is an example:
In the shell:
Dialyzer: