nm shows symbols defined in an executable. GHC includes library name in symbols, so we can use this to inspect libraries that make it into the compiled binary. GHC uses z-encoding so we pipe the output of nm into an ad-hoc invocation of sed, viz.

$ nm -D $(which pandoc) \ | sed 's/\([^z]\)zi/\1./g ;s/\([^z]\)zm/\1-/g; s/\([^z]\)zd/\1$/g; s/ZC/:/g; s/zz/z/g' ... 000000000d50d930 D zlib- 000000000d50d930 D zlib- 000000000d50f198 D zlib- 00000000097c3688 T zlib- 000000000d50c060 D zlib-

To focus on only the library name, we use a regular to expression to capture and then Jacinda's ~. to deduplicate.

$ nm -D $(which pandoc) \ | sed 's/\([^z]\)zi/\1./g ;s/\([^z]\)zm/\1-/g; s/\([^z]\)zd/\1$/g; s/ZC/:/g; s/zz/z/g' \ | ja '~..?{`2 ~ /^(T|t)$/}{`3 ~* 1 /([A-Za-z][A-Za-z0-9\-]*-\d+(\.\d+)*)-[0-9a-f]{4}/}' aeson- aeson-pretty-0.8.10 appar-0.1.8 array- asn1-encoding-0.9.6 ...

Thus we have a list of libraries that provide functions that end up in the final executable. This is different from library dependencies that get linked, and in fact we can compare with diff (don't forget the | sort):

diff \ <(readelf -p '.debug-ghc-link-info' $(which ja) | ja -R, '.?{|`0 ~* 1 /-lHS([A-Aa-z][A-Za-z0-9\-]*\d+(\.\d+)*)/}' | sort) \ <(nm $(which ja) | sed 's/\([^z]\)zi/\1./g ;s/\([^z]\)zm/\1-/g; s/\([^z]\)zd/\1$/g; s/ZC/:/g; s/zz/z/g' | ja '~..?{`2 ~ /^(T|t)$/}{`3 ~* 1 /([A-Za-z][A-Za-z0-9\-]*\-\d+(\.\d+)*)\-[0-9a-f]{4}/}' | sort)

<( ... ) is the syntax for process substitution provided by the shell.

This gives us:

< array- < base- < binary- 8d4 < composition-prelude- 14,19d9 < ghc-bignum-1.3 < ghc-boot-th-9.8.2 < ghc-prim-0.11.0 < jacinda- < microlens- < microlens-mtl- 23d12 < pretty- 30d18 < rts-1.0.2 32,33d19 < stm- < template-haskell- 37d22 < transformers-compat-0.7.2

Notably, this shows that microlens is linked at compile-time but there are no functions from microlens in the final executable. This means that GHC's simplifier worked and optimized away all lenses.

Again, this is tortuous, but it shows some of the features of the Unix compiler toolchain and the shell's impressive capabilities when marshaling text input/output. What dignity it loses from being jury-rigged is made up by its flexibility—IDEs offer no such capability.