Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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