There was another thread that asked about a similar problem:
However, in this thread we had no problem with linking to zlib when doing cabal build, but we did have a problem with cabal repl.
In one of the posts in that thread, I listed some of the steps I used to try to debug this problem. You might find this helpful.
If you can’t get this working at all, then going with the nix-shell -A xmonad-with-packages route is probably the easiest workaround.