Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created September 25, 2011 20:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sritchie/1241073 to your computer and use it in GitHub Desktop.
Save sritchie/1241073 to your computer and use it in GitHub Desktop.
hslint!
#!/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