Created
September 25, 2011 20:00
-
-
Save sritchie/1241073 to your computer and use it in GitHub Desktop.
hslint!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Remember `chmod a+x hslint, after putting on path. | |
$ghc = '/usr/bin/ghc'; # where is ghc | |
@ghc_options = ('-Wall'); # e.g. ('-fglasgow-exts') | |
@ghc_packages = (); # e.g. ('QuickCheck') | |
### the following should not been edited ### | |
@command = ($ghc, '--make', '-fno-code', $ARGV[0]); | |
while (@ghc_options) { | |
push(@command, shift @ghc_options); | |
} | |
while (@ghc_packages) { | |
push(@command, '-package'); | |
push(@command, shift @ghc_packages); | |
} | |
open(MESSAGE, "@command 2>&1 |"); | |
while (<MESSAGE>) { | |
if (/(^\S+\.l?hs)(:\d*:\d*:)\s?(.*)/) { | |
print "\n"; | |
print $1; | |
print $2; | |
$rest = $3; | |
chomp $rest; | |
print $rest; | |
} | |
if (/^\s+(.+)/) { | |
$rest = $1; | |
chomp $rest; | |
print $rest; | |
print " "; | |
} | |
} | |
close MESSAGE; | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment