haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.33k stars 342 forks source link

Indentation parse error with GADTs #1481

Open adamflott opened 7 years ago

adamflott commented 7 years ago

Parse error on valid syntax. Given,

{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}

data Bar a where
    Bar :: Show a => {
        getStr' :: String,
        getData' :: a, -- can Show 
        getInt' :: Int
    } -> Bar a -- have (Show a)
deriving instance Show (Bar a)

haskell-mode is telling me there is parse error at the {

Snippet from http://stackoverflow.com/questions/21505975/write-gadt-record-with-constrained-type

gracjan commented 7 years ago

Interesting. I did not know this is valid Haskell. Where is a specification for this grammar production?

adamflott commented 7 years ago

The best resources I can find are https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#ghc-flag--XGADTSyntax and https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/gadt-pldi.pdf

gracjan commented 7 years ago

I just tried and I do not get the error. Can you update to latest version and check again?

Reopen if you are able to reproduce the issue.

adamflott commented 7 years ago

Updated. Still getting the error but that may be due to using spacemacs / intero. The version used is: "16.2-git".

gracjan commented 7 years ago

Interesting.

alanz commented 7 years ago

I just opened this in spacemacs, the straight flycheck says it is fine, loading it into inf-haskell mode works fine.

Can't comment on intero, I have not used it.

alanz commented 7 years ago

What version of compiler are you using?

gracjan commented 7 years ago

@adamflott: Can you restart Emacs?

adamflott commented 7 years ago

@alanz 8.0.2 with stackage lts 8.0

@gracjan I did (after upgrading all the packages)

gracjan commented 7 years ago

I still cannot reproduce the error. Is it after pressing TAB? When does it happen?

adamflott commented 7 years ago

@gracjan not after tab. I cleaned my spacemacs dirs (git clean -f -d -x; git branch has me on release-0.200), removed my intero spacemacs glue that's been upstreamed to spacemacs haskell (https://github.com/cydparser/spacemacs-intero) layer, did a intero-restart and still get the error: http://imgur.com/a/1b6kE .

alanz commented 7 years ago

I am sure that code is using DatatypeContexts, which has been deprecated?

gracjan commented 7 years ago

@adamflott: Is this a tooltip? I've never seen such a tool tip. Do you have a Haskell linter enabled?

adamflott commented 7 years ago

@gracjan yes it is a tooltip. I'm assuming its a part of spacemacs. My .spacemacs has

dotspacemacs-configuration-layers
   '((haskell :variables haskell-completion-backend 'intero)
)

I don't have any other linters in use.

gracjan commented 7 years ago

This looks like a problem that is outside of haskell-mode and related to flycheck. Specifically flycheck uses ghc executable available in PATH to check syntax of Haskell source code. Probably you have old version of ghc in your PATH that does not match your stack.yml setup.

Can you check if you have a ghc in your PATH and remove it from there temporarily? That would confirm that flycheck is the culprit here.

adamflott commented 7 years ago

Removed all traces of ghc from my system install so only stack remains. Still showing the parse error.

Relevant lines from my emacs messages buffer:

(Spacemacs) Warning: package flycheck not initialized in layer intero, you may consider removing this package from the package list or use the :toggle keyword instead of a `when' form.
(Spacemacs) Warning: More than one init function found for package intero. Previous owner was haskell, replacing it with layer intero.
...
Booting up intero ...
Booted up intero!
...
Disabling interactive-haskell-mode ...

I can try this experiment at home on my Arch Linux install. This one is from my Ubuntu 14.04 install with a custom emacs.