neovimhaskell / nvim-hs

Neovim API for Haskell plugins as well as the plugin provider
Other
267 stars 18 forks source link

Compile error in TH.hs during `cabal install` #46

Closed vpetro closed 8 years ago

vpetro commented 8 years ago

Following the instructions in the docs with a clean clone of nvim-hs, I get the following errors when running cabal install:

[17 of 27] Compiling Neovim.API.TH    ( library/Neovim/API/TH.hs, dist/dist-sandbox-81f5234c/build/Neovim/API/TH.o )

library/Neovim/API/TH.hs:186:9: error:
    • Couldn't match expected type ‘Q Dec’
                  with actual type ‘CxtQ -> DecQ’
    • Probable cause: ‘dataD’ is applied to too few arguments
      In a stmt of a 'do' block:
        dataD
          (return [])
          nme
          []
          (map (\ n -> normalC n [return (IsStrict, tObject)]) cs)
          (mkName <$> ["Typeable", "Eq", "Show"])
      In the expression:
        do { tObject <- [t| ByteString |];
             dataD
               (return [])
               nme
               []
               (map (\ n -> normalC n [return ...]) cs)
               (mkName <$> ["Typeable", "Eq", ....]) }
      In an equation for ‘createDataTypeWithByteStringComponent’:
          createDataTypeWithByteStringComponent nme cs
            = do { tObject <- [t| ByteString |];
                   dataD
                     (return [])
                     nme
                     []
                     (map (\ n -> normalC n [...]) cs)
                     (mkName <$> ["Typeable", ....]) }

library/Neovim/API/TH.hs:190:14: error:
    • Couldn't match expected type ‘Maybe Kind’
                  with actual type ‘[ConQ]’
    • In the fourth argument of ‘dataD’, namely
        ‘(map (\ n -> normalC n [return (IsStrict, tObject)]) cs)’
      In a stmt of a 'do' block:
        dataD
          (return [])
          nme
          []
          (map (\ n -> normalC n [return (IsStrict, tObject)]) cs)
          (mkName <$> ["Typeable", "Eq", "Show"])
      In the expression:
        do { tObject <- [t| ByteString |];
             dataD
               (return [])
               nme
               []
               (map (\ n -> normalC n [return ...]) cs)
               (mkName <$> ["Typeable", "Eq", ....]) }

library/Neovim/API/TH.hs:190:43: error:
    • Data constructor not in scope: IsStrict :: Bang
    • Perhaps you meant one of these:
        variable ‘isStrict’ (imported from Language.Haskell.TH),
        ‘Strict’ (imported from Language.Haskell.TH)

library/Neovim/API/TH.hs:191:14: error:
    • Couldn't match type ‘Name’ with ‘Q Con’
      Expected type: [ConQ]
        Actual type: [Name]
    • In the fifth argument of ‘dataD’, namely
        ‘(mkName <$> ["Typeable", "Eq", "Show"])’
      In a stmt of a 'do' block:
        dataD
          (return [])
          nme
          []
          (map (\ n -> normalC n [return (IsStrict, tObject)]) cs)
          (mkName <$> ["Typeable", "Eq", "Show"])
      In the expression:
        do { tObject <- [t| ByteString |];
             dataD
               (return [])
               nme
               []
               (map (\ n -> normalC n [return ...]) cs)
               (mkName <$> ["Typeable", "Eq", ....]) }

library/Neovim/API/TH.hs:429:13: error:
    • The constructor ‘VarI’ should have 3 arguments, but has been given 4
    • In the pattern: VarI _ functionType _ _
      In a case alternative:
          VarI _ functionType _ _ -> determineNumberOfArguments functionType
      In the second argument of ‘($)’, namely
        ‘case fInfo of {
           VarI _ functionType _ _ -> determineNumberOfArguments functionType
           x -> error
                $ "Value given to function is (likely) not the name of a function.\n"
                  <> show x }’
cabal: Error: some packages failed to install:
nvim-hs-0.0.7 failed during the building phase. The exception was:
ExitFailure 1

Any thoughts on what is going wrong?

saep commented 8 years ago

Probable cause: ‘dataD’ is applied to too few arguments

It seems to be a versioning issue with template-haskell (i.e. the code generation for the API).

I can have a look at it, if you can tell me the GHC and template-haskell version you are using.

In any case, I've used stack for most my Haskell development needs since I wrote the documentation and I think it's easier to set up. I should probably adjust the documentation to reflect that. The curated set of packages helps a lot with finding the right version bounds (i.e. nothing has to be done :-)).

Recently, I found out that all dependencies are on stackage, so I can add this one to stackage relatively easy, unless the binary dependency to neovim is a problem.

saep commented 8 years ago

The script from the instructions should work for stack as well, so instead of the cabal commands, you can do:

stack setup

stack install

Still, assuming you're using a bleeding edge version of GHC, I should probably add some version bounds or #ifdef the bits of code to make it compile on most recent GHC version.

vpetro commented 8 years ago

Building with stack worked perfectly. Thanks.

As for versions:

oss/nvim-hs master λ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
oss/nvim-hs master λ ghc-pkg list | grep template-haskell
    template-haskell-2.11.0.0
saep commented 8 years ago

Thanks for the version information! Since it's the new hot stuffI should definitely #ifdef that code.