[erlang-questions] Type Specifications for Parameterized Modules

Kostis Sagonas <>
Tue Mar 15 16:30:06 CET 2011


Alain O'Dea wrote:
> Hi Eric:
> 
> On Tue, Mar 15, 2011 at 11:04 AM, Eric Merritt <> wrote:
>> Hello All,
>>
>>   Is there any way to specify the types for parameters in
>> parameterized modules?
>>
>> Parameterized modules are still experimental so perhaps they are not
>> supported for specs. In any case, I have yet to find anything
>> mentioning parameterized modules and specs in the same context.
>>
>> Thanks,
>>  Eric
>>
> 
> In an interview with Erlang Inside, Kostis Sagonas says parameterized
> modules are supported by Dialyzer:
> http://erlanginside.com/interview-with-kostis-sagonas-leader-of-the-hipe-team-and-erlang-tool-developer-244
> 
> However, I am not sure how the support works.

There are two different issues here, which should not be confused:

  1. Support for parameterized modules by dialyzer
     i.e. support for modules which do not start with
	-module(mod).
      but with:
	-module(mod, [Param1, ..., ParamN]).

     I am pretty confident that this support is in place;
     if you encounter any problems please report them.


  2. Writing specs for functions in parameterized modules

     I believe that all what's needed is to modify the translation
     that handles parameterized modules also take the specs into account
     and translate them to their proper counterparts (i.e., add types for
     the extra function parameters).  This can be as simple as adding the
     type any() for the extra parameters or be more fancy by extending
     the module declaration with the ability to specify proper types for
     the parameters, as in:

	-module(mod, [Param1 :: type1(), ..., ParamN :: typeN()]).

     and use these types in the translation.

Volunteers wanted among the developers that care about parameterized 
modules.  This is really really low on my todo list.

Kostis


More information about the erlang-questions mailing list