XMonad can be installed via Stackage. But it's not enough to install, it needs to compile the user configuration -
xmonad.hs. Being installed through
stack install, XMonad tries to call the system GHC, which expectedly can't find the required libraries.
Ideally, XMonad could understand that it's installed through Stack, and called the corresponding compiler. There are precedents - HLint, for example, loads the required libraries for checking the code if it finds
stack.yaml. But meanwhile it can be done manually.
XMonad calls GHC to compile the configuration, so one must first point to it from a wrapper script
This script has to be put in a directory preceding the one used by Stack -
~/.local/bin - in
Now XMonad will call GHC installed through Stack, compile the configuration and launch the result. But all the other programs launched from within it will inherit the same settings, which confuses, among others, Stack itself. To fix this, we need to reinstate the system settings after the launch. Thus, in
The full configuration can be found in my repository:
XMonad 0.13, or any version with e159ec3, supports a custom user build script that should make most of the above unnecessary.