For example, the httpc library (http://erlang.org/doc/man/httpc.html#request-4) defines some types:
status_line() = {http_version(), status_code(), reason_phrase()}
http_version() = string(), for example, "HTTP/1.1"
status_code() = integer()
reason_phrase() = string()
content_type() = string()
headers() = [header()]
header() = {field(), value()}
In my code, I want to write a function that, for example, consumes a Result and produces something else. However, rebar3 dialyzer
complains:
===> Verifying dependencies...
===> Compiling xxx
===> Compiling src/httpabs.erl failed
src/httpabs.erl:35: type headers() undefined
src/httpabs.erl:35: type status_code() undefined
src/httpabs.erl:35: type status_line() undefined
So how do I import those type declarations so I can re-use them?
In general, you use types exported from another module by prefixing the module name, similar to the way you use exported functions: module:type_name()
.
However, the types you mention are only used in the documentation; they are not actually exported from the httpc
module.
You can search for -export_type
directives in the Erlang/OTP source tree; I don't know any other way to know which types are actually exported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With