Skip to content

Instantly share code, notes, and snippets.

@andy-morris
Created June 22, 2012 18:34
Show Gist options
  • Save andy-morris/2974419 to your computer and use it in GitHub Desktop.
Save andy-morris/2974419 to your computer and use it in GitHub Desktop.
Wrapper for ghc with haskellmode & cabal-dev
#!/usr/local/bin/zsh
if [[ -d ./cabal-dev ]]; then
ignoreflags=('-O.*' --make -debug -threaded -ticky '.*\.hs' -prof)
ignorere="/^(${(j'|')ignoreflags})\$/"
argflags=(-package-name -package-conf -odir -hidir -stubdir -package-id)
argre="/^(${(j'|')argflags})\$/"
output=`cabal-dev buildopts` || exit 1
args=$(print $output | \
sed '/End/q' | \
sed '/^-o$/,/./d' | \
sed -E "$argre { N; s/\\n/ /; }" | \
sed -E '/^[^-]/d' | \
sed -E "1d; \$d; ${ignorere}d;")
#print -- $args
ghc ${(f)args} $@
else
ghc $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment