Skip to content

Instantly share code, notes, and snippets.

@blacktaxi
Created February 27, 2013 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacktaxi/5047162 to your computer and use it in GitHub Desktop.
Save blacktaxi/5047162 to your computer and use it in GitHub Desktop.
Haskell lint script for Emacs.
#!python
'''Haskell lint script for Emacs.
Translated from this: https://gist.github.com/1241073
'''
from __future__ import print_function
import sys
import subprocess
import re
ghc = 'ghc'
ghc_options = ['-Wall']
ghc_packages = []
command = [ghc, '--make', '-fno-code', sys.argv[1]] + ghc_options + ['-package %s' % x for x in ghc_packages]
try:
out = subprocess.check_output(command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
out = e.output
for l in out.splitlines():
r1 = re.match('(^\S+\.l?hs)(:\d*:\d*:)\s?(.*)', l)
r2 = re.match('^\s+(.+)', l)
if r1:
print('\n{0}{1}{2}'.format(r1.groups()[0], r1.groups()[1], r1.groups()[2].strip()))
if r2:
print('{0} '.format(r2.groups()[0].strip()))
print('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment