spion / purscheck

A tiny wrapper for the purescript compiler compatible with flycheck
MIT License
13 stars 1 forks source link

Not catching all errors? #3

Open FrigoEU opened 9 years ago

FrigoEU commented 9 years ago

Hey,

Just started with Purescript and I'm using purscheck while working through the examples in the Purescript book. I seem to not be able to get purscheck to catch all errors emitted by the compiler. For example I have this file:

module Data.Hashable where

newtype Complex = Complex
   { real :: Number
   , imaginary :: Number
   }

instance showComplex :: Show Complex where
  show (Complex {real = r, imaginary = i}) = "real: " ++ (show r) ++ " imaginary: " ++ (show i)

instance eqComplex :: Eq Complex where
  (==) (Complex {real = r1, imaginary = i1}) (Complex {real = r2, imaginary = i2}) = (r1 == r2) && (i1 == i2)

purscheck is not getting any errors out of this, but when I just run psc src\Data\Hashable.purs it gives me this error:

Error at src\Data\Hashable.purs line 11, column 1 - line 15, column 1:
  Error in type class instance Prelude.Eq Data.Hashable.Complex:
  Member (/=) has not been implemented
See https://github.com/purescript/purescript/wiki/Error-Code-MissingClassMember for more information, or to contribute content related to this error.

Is some of my configuration still off? Running purescript v0.6.9.3, Windows 8.1, emacs 24.4.

spion commented 9 years ago

I think the purescript error format changed recently and I haven't updated purscheck to reflect that. The regular expression that captures the errors needs to be changed.

spion commented 9 years ago

Should be fixed in the latest master.

FrigoEU commented 9 years ago

Sorry to bother you again, but I've been trying for hours yesterday to get this to work, but I'm still only getting a fraction of the errors. I've been fiddling with the regexp to somehow match the different kind of errors I want flycheck to catch, but it's just not happening. Is there some way for me to easily test/debug what purscheck is doing and why the regex is not matching?

spion commented 9 years ago

@FrigoEU no problem, feel free to write any time, I don't mind.

The problem in your case could be the filename - I'll try to fix it.

edit: I tried your exact same file, and I get the error reported by flycheck. Are you sure you tried the latest master? I updated it yesterday

FrigoEU commented 9 years ago

Hey @spion ,

Yup I'm using the latest one. I rebuilt everything again just now just in case, and did a clean copy-paste of purscheck.el . I'm getting more and more the feeling however that the problem is not in the regexp. I wanted to compile a list of errors, mentioning whether each case gets picked up by flycheck or not. However I came across these two cases:

First one, trying to make an instance of typeclass Foldable without importing the necessary package. This one does not get shown in Flycheck:

Error in module Main:
Error at src\Main.purs line 12, column 1 - line 12, column 48:
  Unknown type class Foldable
See https://github.com/purescript/purescript/wiki/Error-Code-UnknownTypeClass for more information, or to contribute content related to this error.

The second case, where I uncomment the implementation of function sum. This one does show up in Flycheck:

Error in module Main:
Error at src\Main.purs line 3, column 1 - line 5, column 1:
  Orphan type declaration for sum
See https://github.com/purescript/purescript/wiki/Error-Code-OrphanTypeDeclaration for more information, or to contribute content related to this error.

I can't figure out why the regex would match the second case and not the first.

Just some extra info: Windows 8.1, Emacs 25.0 (not 24.4 as I mentioned earlier), Flycheck v0.23snapshot, Purescript v0.6.9.3, running compiler with psc src\Main.purs .

spion commented 9 years ago

Do you mean Emacs 24.5 pretest? I haven't tried purscheck in it yet.

I wondered if its flycheck not recognizing the backslash as part of the path (expecting a regular slash instead), but it doesn't seem to be that either.

FrigoEU commented 9 years ago

I just downloaded the official 24.4 release, wiped all my modules and just installed flycheck and haskell mode and added purscheck.el to my init.el, and I'm still getting the same results.

spion commented 9 years ago

Okay, I updated the regex to handle multiple errors being reported for a file. Can you check if that helped?

FrigoEU commented 9 years ago

Unfortunately, that hasn't helped either. Is there something inside purscheck.hs that could cause this? Maybe different error codes being returned from the compiler or something? I'm not a very good purescript or haskell programmer so unfortunately I've been unable to figure what exactly is going on under the hood there.

Anyway, thanks already for all the help already, much appreciated!

spion commented 9 years ago

@FrigoEU I have no idea whats going on. Everything is working fine here (but I'm testing on OS X and Linux - haven't had the chance to test on Windows).

But feel free to post examples and maybe I'll be able to reproduce the issue with one of them.

FrigoEU commented 9 years ago

Totally understand. This evening I'll boot up my Linux partition and see if I can also reproduce it there. I'll keep you posted.

FrigoEU commented 9 years ago

OK, managed to get it running on Linux and it works flawlessly! Needless to say I'll just use Linux and bench Windows for Purescript. Thanks!

spion commented 9 years ago

Added support for windows style new lines (\r\n). Maybe that helps?

FrigoEU commented 9 years ago

Nope, still the same. Works on Linux, doesn't work on Windows.