[erlang-questions] How to access functions type signatures?

Kostis Sagonas <>
Mon Aug 11 13:23:30 CEST 2008


Dimitry Golubovsky wrote:
> Joseph,
> 
> On Wed, Jul 30, 2008 at 10:12 AM, Joseph Wayne Norton
> <> wrote:
>> Dimitry -
>>
>> If edoc specs are available, edoc can be used for this purpose.  The
>> outputed xml can be parsed.  There might be other (or better approaches).
>>
> 
> This way it works perfectly, thanks for the suggestion. What if edoc
> specs are not available (developer simply omitted them as they are not
> mandatory)? In some cases type spec may be written for a function with
> arity X, but omitted for arity X-1 and same name.
> 
> There was some static type check tool for Erlang mentioned named TypEr
> [1]: is it capable to produce such specs?
> 
> Thank you.
> 
> [1] http://www.erlang.se/workshop/2005/TypEr_Erlang05.pdf which means
> that it has been around for some time (since 2005): what is its
> current status?

Its current status is that it is part of Erlang/OTP R12B-*.
Typer. although a separate tool, is really a front-end to dialyzer.

It's really simple to use and it does most of what you want it to do.
You can use it by the command:

	typer module.erl

which will show the inferred types of all functions of module.erl.
For functions with -spec declarations, these declarations are trusted 
and are output as is.  It does not understand @edoc declarations though.

Try also:
	typer --help

Comments and suggestions for improvements are welcome.

Kostis



More information about the erlang-questions mailing list