Created
April 9, 2015 04:37
-
-
Save sordina/053a4129d7c3e8a63596 to your computer and use it in GitHub Desktop.
Generate diagrams of your Haskell data-type interrelationships with this robust and elegant program!
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
#!/bin/bash | |
echo 'digraph {' | |
data="$(grep '^data' Prototype.hs | sed 's/data //; s/ .*//')" | |
for i in $data | |
do | |
echo "$i;" | |
targets="$(grep "data $i .*=" Prototype.hs -A 6 \ | |
| sed '/^$/,$d' \ | |
| grep '::' \ | |
| sed 's/.*:: //; s/Maybe //; s/J.Value//; s/String//; s/ .*//')" | |
for j in $targets | |
do | |
echo "$i -> $j;" | |
done | |
done | |
types="$(grep '^type' Prototype.hs | grep -v '^type Lookup' | sed 's/type //; s/ .*//')" | |
for i in $types | |
do | |
echo "$i;" | |
targets="$(grep "type $i .*=" Prototype.hs \ | |
| sed 's/^.*= //' \ | |
| sed 's/[[:<:]]M.Map[[:>:]]/ /g' \ | |
| sed 's/[[:<:]]J.Value[[:>:]]/ /g' \ | |
| sed 's/[[:<:]]String[[:>:]]/ /g' \ | |
| sed 's/[[:<:]]Int[[:>:]]/ /g' \ | |
| sed 's/[[:<:]]Lookup[[:>:]]/ /g')" | |
for j in $targets | |
do | |
echo "$i -> $j;" | |
done | |
done | |
echo '}' |
Author
sordina
commented
Apr 9, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment