It would be nice if more OTP modules included -export_type

It would be nice if more OTP modules included -export_type.

For example we create a module in our application to provide a public API for logging. In that module the logs are implemented with disk_log. We write an API function like this:

-spec log(Log, Event) -> Result
    when
        Log :: term(),
        Event :: event(),
        Result :: ok | {error, Reason},
        Reason :: disk_log:log_error_rsn().
%% @doc Log `Event' to disk.

… however since disk_log doesn’t export log_error_rsn() dialyzer won’t find it. There are many examples like this.

10 Likes

Yes, I agree with you :slight_smile:

There have been some recent improvements in, at least, adding type specs to source code even if the types are not exported(example).

I think that historically (AFAIK), Erlang has not been that big in exporting types.
Exporting the type means a strong commitment, because it is not easy to change without breaking backwards compatibility… Opaques are also weird in their own way… but I would love to see more export_types as well :slight_smile:

4 Likes