how to display a guile module dependency tree

the sph-script repository contains guile-module-dependencies, which you can save and use with guile. sph-lib must also be installed for it to work. add the executable bit with "chmod +x filename" and move the file into a path listed in the environment variable $PATH to have it as a global command line command.

guile-module-dependencies can output the list of modules a module depends on. either as a list with indentation or in the graphviz dot language format to view it as a graph drawing.

guile-module-dependencies command-line interface

  options ... name
  displays a dependency tree for a module.
  module name is given with brackets, for example "(srfi srfi-1)"
  --exclude=value  prefixes to exclude
  --format=value  indent or graphviz (dot language)
  --help | -h
  --include=value  prefixes to include, "(a b),(c)"

if the script file is not in a $PATH directory, it can be called as "guile guile-module-dependencies".

example usage

guile-module-dependencies "(sph)" --max-depth=1


  (ice-9 ports)
(ice-9 pretty-print)
  (ice-9 match)
  (srfi srfi-1)
  (rnrs bytevectors)

viewing the output as a graph drawing

guile-module-dependencies "(sph)" --max-depth=1 --format=graphviz > t.dot

the xdot tool can render and display .dot files directly:

xdot t.dot


possible enhancements

  • it might be useful to output a flat list of module names without duplicates. this would allow to list just those modules that would need to be extracted together with another module about to be extracted from a codebase