Extracting detailed information from TypEr/Dialyzer

Torben Hoffmann torben.lehoff@REDACTED
Tue Oct 12 09:00:00 CEST 2010


I want to extract the following information from a gen_fsm:

   - all the states
   - the incoming events
   - possible next states

but I want to do it per function clause and not only on the function level
as TypEr and Dialyzer does it.
(I have to help a little by stating which functions are states in the
gen_fsm, but that is so easy that I can live with the manual labour

I have created a half-baked solution that is very specific to the code style
I use so that I can extract the following about a gen_fsm:

Each state has an entry in the list for each incoming event.
(The format should probably be
{state_name,event(),[outgoing_messages()],{next_state,[state_name()]}, but
that is besides the point right now.)

My problem is that my quick'n'dirty approach does not come out on top for
all the next_state calculations since you can return from a function clause
in many different ways.

This kind of information must be available at some point during the TypEr
and dialyzer processing of a file - I am okay with throwing my own code away
if I get build on existing code and get the job done in a more general way
than my current hack.

Has anybody been down this road before me? If so, do you have some insights
to share?

For those who is questioning why I want to extract this information: I have
modules which are several thousand lines long and no matter how readable and
nice Erlang code is there is still a need to get a quick overview of what
goes on in a module. The information above would be enough to create an SDL
diagram of the main behaviour of a module which greatly helps when you have
to communicate with non-Erlangers about the functionality of your code. This
way I can acknowledge that the code is King and any manually created
documentation is, well, at best a valiant Knight ;-)

Thanks in advance,

More information about the erlang-questions mailing list