BJ Terry | 10 Sep 2012 23:55
Picon

Yesod, Emacs, Flymake

I have been vexed several times in trying to get my Yesod project (based on the scaffold) to work with flymake on Emacs using ghc-mod. It appears that I've finally gotten it working with these commands added to my .emacs: https://gist.github.com/3693479

I offer this for posterity, because as far as I can tell this has never been covered anywhere that google indexes. The fundamental problem is that flymake in emacs by default runs with the working directory pointing to the file in question. In the Yesod template haskell there are references to folders that depend on the working directory, such as the "static" folder. These commands change the working directory in emacs to any parent folder that has a .cabal file in it. It hasn't been extensively tested, and I am running Aquamacs but it should work elsewhere. Interestingly, this issue was identified and solved in the vim version of ghc-mod.

If you are starting from scratch with emacs:
1. Install haskell-mode as described here: http://www.haskell.org/haskellwiki/Emacs/Installing_haskell-mode
2. Install ghc-mod from cabal: cabal install ghc-mod
3. Add the ghc-mod elisp files to your emacs load-path with a command similar the following added to your .emacs: (setq load-path (cons "~/.cabal/share/ghc-mod-1.11.0" load-path))
4. Add the code from the gist to make flymake work with Yesod projects: https://gist.github.com/3693479


Gmane