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

Add Haskell Makers #38

Closed
prikhi opened this issue Jan 18, 2015 · 7 comments
Closed

Add Haskell Makers #38

prikhi opened this issue Jan 18, 2015 · 7 comments

Comments

@prikhi
Copy link
Contributor

prikhi commented Jan 18, 2015

Thanks a lot for doing this, Syntastic's synchronous checking is what made me switch to neovim...

I'm trying to get haskell checking working with ghc-mod and hlint. Adapting the Synastic checkers mostly works, but some error messages are missing or end up looking funky.

Here's a sample file:

module Main where

main = return ()

-- | no type binding
toplevel n = n

-- | eta reduce
etared s l = map s l

-- | why not concat map
cm t r = concat $ map t r

The makers:

let g:neomake_haskell_ghcmod_maker = {
    \ 'exe': 'ghc-mod',
    \ 'args': ['check'],
    \ 'errorformat': 
        \ '%-G%\s%#,' .
        \ '%f:%l:%c:%trror: %m,' .
        \ '%f:%l:%c:%tarning: %m,'.
        \ '%f:%l:%c: %trror: %m,' .
        \ '%f:%l:%c: %tarning: %m,' .
        \ '%f:%l:%c:%m,' .
        \ '%E%f:%l:%c:,' .
        \ '%Z%m'
    \ }
let g:neomake_haskell_hlint_maker = {
    \ 'errorformat':
        \ '%E%f:%l:%v: Error: %m,' .
        \ '%W%f:%l:%v: Warning: %m,' .
        \ '%C%m'
    \ }
let g:neomake_haskell_enabled_makers = ['ghcmod', 'hlint']

The checker's output:

$ ghc-mod check test.hs                                                                                                                            [14:44:29] 
test.hs:3:1:Warning: Top-level binding with no type signature: main :: IO ()
test.hs:6:1:Warning: Top-level binding with no type signature:  toplevel :: forall t. t -> t
test.hs:9:1:Warning: Top-level binding with no type signature:  etared :: forall a b. (a -> b) -> [a] -> [b]
test.hs:12:1:Warning: Top-level binding with no type signature:  cm :: forall a a1. (a1 -> [a]) -> [a1] -> [a]
$ hlint test.hs                                                                                                                                    [14:44:32] 
test.hs:9:1: Error: Eta reduce
Found:
  etared s l = map s l
Why not:
  etared = map

test.hs:12:10: Error: Use concatMap
Found:
  concat $ map t r
Why not:
  concatMap t r

2 suggestions

and finally the location list after running Neomake:

test.hs|9 col 1 error| Eta reduce Found: etared s l = map s l Why not: etared = map
|| 
test.hs|12 col 10 error| Use concatMap Found: concat $ map t r Why not: concatMap t r
|| 
|| 2 suggestions
test.hs|3 col 1 warning| Top-level binding with no type signature: main :: IO ()
test.hs|6 col 1 warning| Top-level binding with no type signature:
test.hs|9 col 1 warning| Top-level binding with no type signature:
test.hs|12 col 1 warning| Top-level binding with no type signature:

You can see extra lines , and the "2 suggestions" from HLint's output, while everything after ghc-mod's first suggestion is dropped.

A solution or pointers on how to proceed would be great.

@prikhi prikhi changed the title Add Haskell Add Haskell Makers Jan 18, 2015
@benekastah
Copy link
Collaborator

Wrt the extra lines, see #27. About the parts of the message that are missing, I'm guessing the errorformat is somehow wrong. When I have ported makers from syntastic and it doesn't work right, usually there is some subtle difference between the errorformats. Unfortunately I'm no expert on vim's errorformat system, so I can't see the issue right off the bat. I can't look at it right away, but if you don't have any luck with it I'd be happy to try my hand at it sometime soon.

@benekastah
Copy link
Collaborator

I actually think this has to do with #15. When I ran each linter in isolation, it worked perfectly. Do you get the same results every time? It's possible that some multiline messages are getting split up between two different job activity handler calls. Try putting let g:neomake_serialize = 1 somewhere in your ~/.vimrc and let me know if that fixes it.

@prikhi
Copy link
Contributor Author

prikhi commented Jan 20, 2015

Hmm, when I enable neomake_serialize I don't receive any hints from ghcmod at all(although I do get Neomake: ghcmod complete).

When I change haskell_enabled_makers to only ghcmod, I get the same erroneous output as above(without the HLint feeback).

@benekastah
Copy link
Collaborator

Ok, I would make sure your version of neovim is relatively recent. I've been building weekly from master and testing agains that. Sometime this weekend I'll see if I can't get this going for myself and track down the different issues here.

@prikhi
Copy link
Contributor Author

prikhi commented Jan 23, 2015

Still happening off of nightly.

It seems specific to the top-level binding warning, I don't see it happening with others during my normal use.

Let me know if you need help getting set up. Usually you can just install cabal-install via your package manager, then run:
cabal update && cabal install hlint ghc-mod && export PATH=~/.cabal/bin/:$PATH.

@benekastah
Copy link
Collaborator

It looks like I was able to figure this out. When running this linters in normal vim, I saw it was outputting ^A at each place that was breaking in neovim. So I did some digging with ghc-mod check test.hs | hexdump and saw that ghc-mod is outputting a null byte at each location that breaks. Neovim breaks in a different way from vim; it interprets null bytes in stdout from jobs as newlines it seems. This has come up as a problem with ghc-mod before.

I was able to fix it with a small output formatting step. I included both these makers in the repo as well.

@prikhi
Copy link
Contributor Author

prikhi commented Jan 25, 2015

Beautiful, thanks :)

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

2 participants