[Haskell-cafe] A Tool To Show Functions Relationship?

Thomas Hallgren hallgren at cse.ogi.edu
Thu Jun 9 17:00:46 EDT 2005


Dimitry Golubovsky wrote:

>Does there exist a tool which given a Haskell source, shows functions
>that are mutually recursive (i. e. call each other, even via calling
>third, etc. functions)?
>
With pfe, the Programmatica tools command line interface, you can 
currently get a list of definition level dependencies like this 
(assuming your module is called Example):

% pfesetup +h Example.hs
% pfe deps Example

module DepExample:
  declarator:
    Text.ParserCombinators.Parsec.Prim.<?>
    Text.ParserCombinators.Parsec.Prim.try
    Hugs.Prelude.Monad Hugs.Prelude.>>= pointer idd
    Text.ParserCombinators.Parsec.Prim.many cpi
    Hugs.Prelude.return Declarator
    Text.ParserCombinators.Parsec.Prim.inst__Text_ParserCombinators_Parsec_Prim_Monad__l_GenParser_tok_st_r_
  idd:
    Text.ParserCombinators.Parsec.Prim.<?>
    Text.ParserCombinators.Parsec.Prim.<|>
    Text.ParserCombinators.Parsec.Prim.try
    Hugs.Prelude.Monad Hugs.Prelude.>>= anyIdString
    Hugs.Prelude.return Hugs.Prelude.Either
    Hugs.Prelude.Left Hugs.Prelude.>> tkOp declarator
    Hugs.Prelude.Right
    Text.ParserCombinators.Parsec.Prim.inst__Text_ParserCombinators_Parsec_Prim_Monad__l_GenParser_tok_st_r_
  ...
  

The dependency information is computed after type checking, so it 
includes dependencies on instance declarations (which are assign names 
starting with inst__).

I guess it would be usesful to also have an option to eliminate 
dependencies on imported stuff, and an option to display mutually 
recursive groups (strongly connected components of definitions).

> Knowledge of that would help to split the
>module into smaller modules without risk to create recursive modules.
>  
>
The Programatica tools actually support mutually recursive modules, so 
that wouldn't be a problem. We are still waiting for other Haskell 
implementations to catch up :-)

-- 
Thomas H




More information about the Haskell-Cafe mailing list