Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmonad lib subdirectory #3

Closed
joe9 opened this issue Feb 28, 2014 · 5 comments
Closed

xmonad lib subdirectory #3

joe9 opened this issue Feb 28, 2014 · 5 comments

Comments

@joe9
Copy link

joe9 commented Feb 28, 2014

Hello,

I need some advice on what would be the recommend way of dealing with the issue.

When editing xmonad.hs using flycheck-hdevtools, flycheck does not search the lib/ subdirectory for modules and throws the below error:

69 18 error Could not find module `XMonad.Util.DTrace'
Perhaps you meant
XMonad.Util.Image (from xmonad-contrib-0.12)
XMonad.Util.Replace (from xmonad-contrib-0.12)
XMonad.Util.Stack (from xmonad-contrib-0.12)
Use -v to see a list of the files searched for. (haskell-hdevtools)

Below is the relevant recompile command in xmonad:

-- | 'recompile force', recompile @~/.xmonad/xmonad.hs@ when any of the
...
...
recompile :: MonadIO m => Bool -> m Bool
recompile force = io $ do
dir <- getXMonadDir
let binn = "xmonad-"++arch++"-"++os
bin = dir </> binn
base = dir </> "xmonad"
err = base ++ ".errors"
src = base ++ ".hs"
lib = dir </> "lib"
libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib
srcT <- getModTime src
binT <- getModTime bin
if force || any (binT <) (srcT : libTs)
then do
-- temporarily disable SIGCHLD ignoring:
uninstallSignalHandlers
status <- bracket (openFile err WriteMode) hClose $ \h ->
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-main-is", "main", "-v0", "-o",binn](Just dir)
Nothing Nothing Nothing (Just h)

----- relevant hdevtools commands
hdevtools check -g -Wall xmonad.hs
xmonad.hs:69:18:
Could not find module `XMonad.Util.DTrace'
Perhaps you meant
XMonad.Util.Image (from xmonad-contrib-0.12)
XMonad.Util.Replace (from xmonad-contrib-0.12)
XMonad.Util.Stack (from xmonad-contrib-0.12)
Use -v to see a list of the files searched for.


hdevtools check -g -Wall -g -ilib xmonad.hs
xmonad.hs:230:1: Warning:
Top-level binding with no type signature:
myLayoutHook :: .....

Any thoughts, please?

I need to add a parameter to hdevtools. Not sure if it is a good idea to have it as a flycheck-hdevtools variable?

Thanks
Joe

@freiric
Copy link

freiric commented Feb 28, 2014

Not sure whether it is a good idea, but I would be interested too. In the meantime, I've followed this path. I've a branch of flycheck-hdevtools which looks for a file .ghc-options containing ghc options in the current cabal project, and add these options to hdevtools. It depends on haskell-mode, and on the existence of a *.cabal file to find the file .ghc-options, but I guess one could easily drop both these requirements.
https://github.com/freiric/flycheck-hdevtools/tree/ghc-options

@purcell
Copy link
Member

purcell commented Mar 1, 2014

Firstly, it's worth noting that if you install the flycheck-haskell package, then the basic ghc-based checker in flycheck should automatically be aware of the project's Cabal environment. So please give that a try, and see if it works any better.

It should be possible to make flycheck-hdevtools use the same hints about the project layout, but I haven't yet tackled that. (It also affects issue #2.)

-Steve

@freiric
Copy link

freiric commented Mar 1, 2014

flycheck-haskell finds the cabal project file using haskell-mode (it does a require haskell-cabal), and inside this cabale file, it finds the source directories of the project by running a haskell script. Say it found the directories lib and src.
flycheck then just prepends a -i to these directories and pass them to ghc resulting in ghc ... -ilib -isrc ....

So if your only requirement is to have the lib directory in the search path and this directory is listed as a source directory in the cabal file, using flycheck-haskell should work for you.

From here, it may be a bit off-topic, but I do not quite know where to post this:
My use case was a bit different, as I wanted to pass to the checker the cpp options -DTEST_EXPORT. This option is defined in the cabal file of the project and is used to compile in test mode (some functions are exported in test mode which wouldn't be exported in normal mode).

I've tried to extend flycheck-haskell to pass the cpp options from the cabal file, and this is possible, but the problem is that the ghc checker in flycheck use the options -fno-code to not generate any code while checking (which makes sense), however ghc somehow needs to have existing compiled files to work with cpp options.
In contrast, hdevtools is happy with these cpp options (I am no expert but I guess that hdevtools is generating the compiled files somewhere), so in this case using flycheck-hdevtools solves the options issues whereas flycheck-haskell does not.

I am still not sure in which direction to go from here:

  • adapt flycheck-hdetools to pass it cabal options,
  • adapt flycheck-haskell to pass it more cabal options, and may be use the compiled files from cabal instead of not generating any file?

@joe9
Copy link
Author

joe9 commented Mar 2, 2014

Hello,

Thanks for responding and checking out the issue.

Firstly, it's worth noting that if you install the flycheck-haskell package,
then the basic ghc-based checker in flycheck should automatically be aware
of the project's Cabal environment. So please give that a try, and see if it
works any better.

xmonad configuration does not have a cabal file. There is a cabal file but that
belongs to the xmonad package
(cabal/packages/hackage.haskell.org/xmonad/xmonad/xmonad.cabal). The
configuration requires that you provide a ~/.xmonad/xmonad.hs, which is compiled
and used by the xmonad executable. As an fyi,
https://wiki.archlinux.org/index.php/xmonad#Configuring_xmonad has some more
details on the configuration.

The -ilib is added by the xmonad executable when recompiling.

It should be possible to make flycheck-hdevtools use the same hints about
the project layout, but I haven't yet tackled that. (It also affects issue
#2.)

Oh, ok.

Please let me know if I can provide more details.

Thanks again
Joe

@swsnr
Copy link
Contributor

swsnr commented Jan 15, 2016

Closing due to the lack of activity.

@swsnr swsnr closed this as completed Jan 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants