[erlang-questions] encapsulating types and dialyzer
Thu Sep 11 18:56:17 CEST 2008
Anthony Shipman wrote:
> Suppose I have a module MC that implements a collection type known as coll().
> Internally this is some record that I want to be private to the module.
> The external functions in the interface mention the type coll(). So the
> clients of the interface must also mention coll() if dialyzer is to check the
> As far as I can see the only way to do this is to put the coll() type into
> a .hrl file. This exposes the record definition, and recursively every other
> type that it depends on.
> Is there a better way to do this?
In the HiPE group, we have had extensive discussions about this issue.
The solution we came up with is to allow module-qualified types, as in
mc:col(), which can then be used in other modules. This works in R12B-4
but not in any previous version.
Currently, all types defined in a module are also implicitly exported --
this might change in a future version and modules might need to declare
their exported types.
PS. I should point out that the language of types and -spec declarations
is currently an EEP. Officially, it is not part of Erlang yet.
More information about the erlang-questions