例如,httpc库(http://erlang.org/doc/man/httpc.html#request-4)定义了一些类型:
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()}
Run Code Online (Sandbox Code Playgroud)
在我的代码,我想编写一个函数,例如,消耗一个结果,产生别的东西.然而,rebar3 dialyzer抱怨:
===> 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
Run Code Online (Sandbox Code Playgroud)
那么如何导入这些类型声明以便我可以重用它们呢?
通常,您通过为模块名称添加前缀来使用从另一个模块导出的类型,类似于使用导出函数的方式:module:type_name().
但是,您提到的类型仅用于文档中; 它们实际上并不是从httpc模块中导出的.
您可以-export_type在Erlang/OTP源代码树中搜索指令; 我不知道知道实际导出哪些类型的任何其他方法.
| 归档时间: |
|
| 查看次数: |
573 次 |
| 最近记录: |