Created
June 24, 2025 00:56
-
-
Save d4hines/7f350c42e15698902cda76853a63ea8b to your computer and use it in GitHub Desktop.
Generate pretty SVG of haskell project dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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