例如,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()}在我的代码中,我想要编写一个函数,例如,它使用一个结果并产生一些其他的东西。但是,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那么,如何导入这些类型声明以便可以重用它们呢?
发布于 2016-11-16 21:58:23
通常,通过对模块名称进行前缀来使用从另一个模块导出的类型,类似于您使用导出函数的方式:module:type_name()。
但是,您提到的类型仅在文档中使用;它们实际上并不是从httpc模块导出的。
您可以在Erlang/OTP源代码树中搜索-export_type指令;我不知道其他任何方法来了解实际导出的类型。
https://stackoverflow.com/questions/40641883
复制相似问题