Skip to content

Instantly share code, notes, and snippets.

@robinp
Created July 13, 2017 20:38
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 robinp/5b2494c2216eeb1c4d7bf090fa59bc96 to your computer and use it in GitHub Desktop.
Save robinp/5b2494c2216eeb1c4d7bf090fa59bc96 to your computer and use it in GitHub Desktop.
Random GHC wrapper script.
import GHC.Paths
import System.Posix.Process
import System.Environment
import System.IO
import Data.List (intercalate)
import Control.Monad (when)
lg = appendFile "/tmp/fake.lg" . (++ "\n")
main = do
args <- getArgs
let make = "--make" `elem` args
args' = do
arg <- args
case arg of
"--make" ->
["--frontend", "CabalWrapper",
"-plugin-package", "cabal-wrapper"]
_ -> return arg
lg "=== new run"
lg (intercalate ", " args)
lg (intercalate ", " args')
forkProcess (executeFile ghc False args Nothing) >>= getProcessStatus True False
when make $ do
lg "== my thing"
executeFile ghc False (args' ++ ["-user-package-db"]) Nothing
{-
main = do
args <- getArgs
let interactive = "--interactive" `elem` args
args' = do
arg <- args
case arg of
"--interactive" ->
["--frontend", "CabalWrapper",
"-plugin-package", "cabal-wrapper"]
_ -> return arg
executeFile ghc False (args' ++ if interactive then ["-user-package-db"] else []) Nothing
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment