Created
July 2, 2009 19:19
-
-
Save cmoore/139654 to your computer and use it in GitHub Desktop.
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 | |
# | |
$ghc = '/usr/bin/ghc'; # where is ghc | |
@ghc_options = (); # e.g. ('-fglasgow-exts') | |
@ghc_packages = (); # e.g. ('QuickCheck') | |
### the following should not been edited ### | |
use File::Temp qw /tempfile tempdir/; | |
File::Temp->safe_level( File::Temp::HIGH ); | |
($source, $base_dir) = @ARGV; | |
@command = ($ghc, | |
'-fno-code', | |
"-i$base_dir", | |
$source); | |
while(@ghc_options) { | |
push(@command, shift @ghc_options); | |
} | |
while(@ghc_packages) { | |
push(@command, '-package'); | |
push(@command, shift @ghc_packages); | |
} | |
$dir = tempdir( CLEANUP => 1 ); | |
($fh, $filename) = tempfile( DIR => $dir ); | |
system("@command >$filename 2>&1"); | |
open(MESSAGE, $filename); | |
while(<MESSAGE>) { | |
# this code is wrong - you need a grouping around the .hs|.lhs bit if you | |
# want it to properly notice lhs files and point to the right place | |
# if(/^\S+\.hs|\.lhs:\d*:\d*:.*/) { | |
if(/^\S+(?:\.hs|\.lhs):\d*:\d*:.*/) { | |
print "\n"; | |
chomp $_; | |
print $_; | |
next; | |
} | |
if(/\s+(.*)/) { | |
$rest = $1; | |
chomp $rest; | |
print $rest; | |
print " "; | |
next; | |
} | |
} | |
close($fh); | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment