A Tool To Show Functions Relationship?

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)? Knowledge of that would help to split the module into smaller modules without risk to create recursive modules. For example (slightly artificial, from a parsec-based C syntax parser): declarator = try (do ps <- pointer id <- idd cp <- many cpi return (Declarator ps id cp)) <?> "declarator" idd = try (do s <- anyIdString return (Left s)) <|> try (do tkOp "(" d <- declarator tkOp ")" return (Right d)) <?> "idd" `declarator' and `idd' are mutually recursive, so placing them into different modules would create recursive modules. -- Dimitry Golubovsky Anywhere on the Web

Dimitry Golubovsky
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)? Knowledge of that would help to split the module into smaller modules without risk to create recursive modules.
hIDE had such a tool[1], though I don't know how it worked. It's possible you could find similar functionality in either HaRe, the Haskell Refactoring Browser[2] or the Programatica toolset[3]. Maybe once the ghc-api works that sort of tool will be easy? [1] http://www.scannedinavian.org/~shae/hIDE.png [2] http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html [3] http://www.cse.ogi.edu/~hallgren/Programatica/ -- It seems I've been living two lives. One life is a self-employed web developer In the other life, I'm shapr, functional programmer. | www.ScannedInAvian.com One of these lives has futures (and subcontinuations!)| --Shae Matijs Erisson

On 6/6/05, Dimitry Golubovsky
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)? Knowledge of that would help to split the module into smaller modules without risk to create recursive modules.
When you sent this mail I seemed to recall a simple tool written by Martin Nordbäck which could take a Haskell module an generate its call graph. But when I searched the web for it I couldn't find it. But to my surprise I found it today when wading through the heaps of old Haskell code that I have around (looking for something completely different.) I'm attaching it in the hope that you will find it useful. It may have suffered from slight bit rot but it should be fairly easy to get it up and running. Cheers, /Josef

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
participants (4)
-
Dimitry Golubovsky
-
Josef Svenningsson
-
Shae Matijs Erisson
-
Thomas Hallgren