    module GHC.Driver.Config.CoreToStg.Prep
      ( initCorePrepConfig
      , initCorePrepPgmConfig
      ) where

    import GHC.Prelude

    import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) )
    import GHC.Driver.Env
    import GHC.Driver.Session
    import GHC.Driver.Config.Core.Lint
    import GHC.Driver.Config.Core.Opt.Arity
    import GHC.Types.Var
    import GHC.Utils.Outputable ( alwaysQualify )

    import GHC.CoreToStg.Prep

    initCorePrepConfig :: HscEnv -> IO CorePrepConfig
    initCorePrepConfig :: HscEnv -> IO CorePrepConfig
    initCorePrepConfig HscEnv
    hsc_env = do
       let dflags :: DynFlags
    dflags = HscEnv -> DynFlags
    hsc_dflags HscEnv
    hsc_env
       CorePrepConfig -> IO CorePrepConfig
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (CorePrepConfig -> IO CorePrepConfig)
    -> CorePrepConfig -> IO CorePrepConfig
    forall a b. (a -> b) -> a -> b
    $ CorePrepConfig
          { cp_catchNonexhaustiveCases :: Bool
    cp_catchNonexhaustiveCases = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_CatchNonexhaustiveCases DynFlags
    dflags
          , cp_platform :: Platform
    cp_platform  = DynFlags -> Platform
    targetPlatform DynFlags
    dflags
          , cp_arityOpts :: Maybe ArityOpts
    cp_arityOpts = if GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_DoCleverArgEtaExpansion DynFlags
    dflags
                           then ArityOpts -> Maybe ArityOpts
    forall a. a -> Maybe a
    Just (DynFlags -> ArityOpts
    initArityOpts DynFlags
    dflags)
                           else Maybe ArityOpts
    forall a. Maybe a
    Nothing
          , cp_specEval :: Bool
    cp_specEval  = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_SpecEval DynFlags
    dflags
          , cp_specEvalDFun :: Bool
    cp_specEvalDFun = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_SpecEvalDictFun DynFlags
    dflags
          }

    initCorePrepPgmConfig :: DynFlags -> [Var] -> CorePrepPgmConfig
    initCorePrepPgmConfig :: DynFlags -> [Var] -> CorePrepPgmConfig
    initCorePrepPgmConfig DynFlags
    dflags [Var]
    extra_vars = CorePrepPgmConfig
      { cpPgm_endPassConfig :: EndPassConfig
    cpPgm_endPassConfig     = DynFlags -> [Var] -> NamePprCtx -> CoreToDo -> EndPassConfig
    initEndPassConfig DynFlags
    dflags [Var]
    extra_vars NamePprCtx
    alwaysQualify CoreToDo
    CorePrep
      , cpPgm_generateDebugInfo :: Bool
    cpPgm_generateDebugInfo = DynFlags -> Bool
    needSourceNotes DynFlags
    dflags
      }