Last active
August 29, 2015 13:56
-
-
Save cstrahan/8984109 to your computer and use it in GitHub Desktop.
cabal sandbox aware ghc wrapper
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
# This is a cabal-sandbox aware wrapper for GHC. | |
# | |
# To see the Template Haskell expansions in my Yesod app, | |
# I tried running (unseccessfully): | |
# | |
# $ ghc -XTemplateHaskell -ddump-splices Foundation.hs | |
# Foundation.hs:21:8: | |
# Could not find module `Yesod.Core.Types' | |
# Use -v to see a list of the files searched for. | |
# | |
# The problem is that ghc will (by default) search for | |
# packages in the locations listed by `ghc-pkg list`. | |
# But, one can grab the package db from the cabal.sandbox.config | |
# and pass that path directly to ghc - which is exactly what | |
# this function does. | |
# | |
# Enjoy! | |
function ghcs { | |
local DIR=$PWD | |
local TARGET="cabal.sandbox.config" | |
while [ ! -e $DIR/$TARGET -a $DIR != "/" ]; do | |
DIR=$(dirname $DIR) | |
done | |
if test $DIR != "/"; then | |
local DB=$(sed -ne '/^package-db: */{s///p;q;}' "$DIR/$TARGET") | |
ghc -no-user-package-db -package-db="$DB" "$@" | |
else | |
ghc "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment