Skip to content

Instantly share code, notes, and snippets.

@fendor
Created May 22, 2019 14:36
Show Gist options
  • Save fendor/f3a21bca7e94d18d693e29129656be75 to your computer and use it in GitHub Desktop.
Save fendor/f3a21bca7e94d18d693e29129656be75 to your computer and use it in GitHub Desktop.
-- | Parse command line ghc options and add them to the 'DynFlags' passed
addCmdOpts :: GhcMonad m => LoadGhcEnvironment -> [GHCOption] -> DynFlags -> m DynFlags
addCmdOpts loadGhcEnv cmdOpts df =
if loadGhcEnv == LoadGhcEnvironment
then fst3 <$> G.parseDynamicFlags df (map G.noLoc cmdOpts)
else
--
-- Passes "-hide-all-packages" to the GHC API to prevent parsing of
-- package environment files. However this only works if there is no
-- invocation of `setSessionDynFlags` before calling `initDynFlagsPure`.
-- See ghc tickets #15513, #15541.
-- Thanks @lspitzner
fst3 <$> G.parseDynamicFlags df (map G.noLoc ("-hide-all-packages":cmdOpts))
-- fst3 <$> G.parseDynamicFlags df (map G.noLoc cmdOpts)
where
fst3 (a,_,_) = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment