Skip to content

Instantly share code, notes, and snippets.

@d4hines
Created June 24, 2025 00:56
Show Gist options
  • Save d4hines/7f350c42e15698902cda76853a63ea8b to your computer and use it in GitHub Desktop.
Save d4hines/7f350c42e15698902cda76853a63ea8b to your computer and use it in GitHub Desktop.
Generate pretty SVG of haskell project dependencies
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p haskellPackages.cabal-plan graphviz
dot="$(cabal-plan dot --tred)"
echo "$dot" > dep_filtered.dot
targets="$(echo "$dot" | grep "color=black" | cut -d ' ' -f 1 | sort | uniq)"
for pkg in "$targets"; do
# Remove surrounding quotes if any.
pkg_clean="$(echo "$pkg" | tr -d '"')"
# Remove lines containing the package name from the working .dot file.
grep -v "$pkg_clean" dep_filtered.dot > /tmp/temp.dot && mv /tmp/temp.dot dep_filtered.dot
done
cat dep_filtered.dot | dot -Tsvg > deps.svg
rm dep_filtered.dot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment