when I’m designing APIs in Elm, I like to start with just the types—this is pretty common advice around these parts! But when I’m refactoring stuff, or talking about a design I want to be able to use the same technique to guide my thinking.
So, here’s a shell script I use to get a rough idea of how a module is structured:
elm_outline() {
MODULE=$1
grep -E '^(type|--|\w+ : .+)' $MODULE
}
a couple caveats: this will grab all top-level comments (so section headers like -- FOO
work fine) but no doc comments or type constructors and you will have to remove non-exposed variables manually. Despite that, I’ve found this useful for a while, so I wanted to share it here!
You can see an example of the output in Interesting query pattern for repeatedly bisecting lists.