[erlang-questions] edoc, erlc and dialyser type spec consistency

Kostis Sagonas <>
Fri Nov 20 19:35:37 CET 2009


David Mercer wrote:
> I agree also with Kostis, but I would also like to request that -type
> declarations permit recursive data types.

I also want that...  Be my guest ;-)

>  Recursive data types are not
> really that uncommon, and are the reason I stopped using -spec/-type
> declarations.

But in the meantime, I do not see the fact that you cannot declare 
recursive data types as any show stopper.  I usually declare them as 
follows:

-type mytree() :: 'empty'
                 | {'tree', atom(), _, _}. % this overapproximates
                                  % {'tree', atom(), mytree(), mytree()}.

(or you can unfold the above definition as many levels as you feel like)

> Another thing I'd like to have is the ability to define a -type as some sort
> of fun(...), and then in a -spec, be able to say that the spec for the
> function being spec'd is the type previously defined.  E.g.,
> 
> 	-type funtype() :: fun((args()) -> return_type()).
> 	-spec f :: funtype ().
> 
> Instead of having to retype the spec for every function with the same
> interface:
> 
> 	-spec f(args()) -> return_type().

You managed to confuse me here... How can you have a "reusable" funtype?
You cannot have functions with the same arguments in an Erlang module.
Can you give us a concrete example of what you want to achieve and you 
cannot?

Kostis


More information about the erlang-questions mailing list