flycheck / flycheck-haskell

Improved Haskell support for Flycheck
GNU General Public License v3.0
67 stars 25 forks source link

Doesn't recognize default-extensions in cabal file #43

Closed taksuyu closed 9 years ago

taksuyu commented 9 years ago

My cabal file contains default-extensions: TemplateHaskell for the project which enables it for any exposed module.

However flycheck gives me this error on a naked expression when the Pragma isn't at the top of the file.

Parse error: naked expression at top level
Perhaps you intend to use TemplateHaskell
swsnr commented 9 years ago

@TakSuyu Can you try again with the latest MELPA build?

taksuyu commented 9 years ago

Still giving me the same error; is there anything I can type in for some debug information?

It didn't recheck when I opened the file. Works just fine once I rewrote the function.

taksuyu commented 9 years ago

Reopened the file and the error came back.

taksuyu commented 9 years ago

Here is the piece of code that throws the error

import Control.Lens (makeFields)

data Player
  = Player
    { score       :: Integer
    , hand        :: Hand
    , stolenMelds :: [Meld]
    , discardPile :: Pile
    }
  deriving (Show)
makeFields ''Player -- The one liner from lens
swsnr commented 9 years ago

@TakSuyu That is strange because we do actually extract the language extensions. Can you show the output of C-c ! C-c haskell-ghc in the affected buffer?

taksuyu commented 9 years ago
-*- mode: compilation; default-directory: "~/git/mahjong/src/Mahjong/Riichi/" -*-
Compilation started at Mon Sep  7 09:17:27

ghc -Wall -no-link -outputdir /tmp/flycheck-haskell-ghc-cache2322Iib -i/home/tak/git/mahjong/src/ -x hs /home/tak/git/mahjong/src/Mahjong/Riichi/Base.hs
[1 of 3] Compiling Mahjong.Tile     ( /home/tak/git/mahjong/src/Mahjong/Tile.hs, /tmp/flycheck-haskell-ghc-cache2322Iib/Mahjong/Tile.o )
[2 of 3] Compiling Mahjong.Meld     ( /home/tak/git/mahjong/src/Mahjong/Meld.hs, /tmp/flycheck-haskell-ghc-cache2322Iib/Mahjong/Meld.o )
[3 of 3] Compiling Mahjong.Riichi.Base ( /home/tak/git/mahjong/src/Mahjong/Riichi/Base.hs, /tmp/flycheck-haskell-ghc-cache2322Iib/Mahjong/Riichi/Base.o )

/home/tak/git/mahjong/src/Mahjong/Riichi/Base.hs:65:1:
    Parse error: naked expression at top level
    Perhaps you intended to use TemplateHaskell

Compilation exited abnormally with code 1 at Mon Sep  7 09:17:29
taksuyu commented 9 years ago

For whatever reason ghc and ghc through stack (I went ahead and tried using the same command but haskell-stack-ghc instead) Both give me those errors. However from CLI, even stack build --pedantic (which turns on -Wall and -Werror) compiles no problem.

swsnr commented 9 years ago

@TakSuyu Do you actually have Flycheck Haskell enabled? There are no options at all in your GHC command, even though there are some that are always set by Flycheck Haskell and definitely must appear there if the package is correctly setup.

taksuyu commented 9 years ago

spacemacs pulls it in as a dependency for the layers I'm using. Maybe it's configured incorrectly?

Yep they misconfigured the hook. Sorry for wasting your precious time.