Skip to content

Instantly share code, notes, and snippets.

@songpp
Forked from sritchie/hslint
Created April 5, 2013 16:52
Show Gist options
  • Save songpp/5320825 to your computer and use it in GitHub Desktop.
Save songpp/5320825 to your computer and use it in GitHub Desktop.
#!/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