SublimeHaskell/SublimeHaskell — pull request #162 by anton-dessiatov (2014-08-26 11:54:03+00:00)
Title: Used cabal project directory to run ghc-mod when possible

I'm doing lots of development with Yesod on Windows, so I had an issue with Sublime Haskell. The problem was that whenever I imported an external template file to my module like this:

$(whamletFile "templates/content-configuration-form.hamlet")

I had the following error when running ghc-mod lint:

Exception when trying to run compile-time code:
static: getDirectoryContents: does not exist (The system cannot find the path specified.)
Code: staticFiles staticDir

The reason of an error is that while cabal runs ghc binary right in the directory where .cabal file is located, SublimeHaskell attempts to run ghc-mod in the directory with the source file. That's why relative paths that are valid when building with cabal aren't valid anymore when running ghc-mod.

The proposed patch fixes that by using .cabal file directory when it's available