inaka/erlang_guidelines — pull request #32 by elbrujohalcon (2014-12-17 04:55:42+00:00)
Title: Types in exported functions

***
##### rule
> All custom data types used in exported functions should be defined with Erlang type declarations and exported from the module

```erlang
%% bad
-spec exported_function({integer(), string()}) -> {ok, {binary(), binary()}}.

%% good
-type your_type() :: {integer(), string()}.
-opaque my_type() :: {binary(), binary()}.
-export_type([your_type/0, my_type/0]).
-spec exported_function(your_type()) -> {ok, my_type()}.
```

##### reasoning
It helps with function documentation and, with opaque types we ensure encapsulation.