    -- | Subsystem configuration
    module GHC.Driver.Config
       ( initOptCoercionOpts
       , initSimpleOpts
       , initEvalOpts
       , EvalStep(..)
       )
    where

    import GHC.Prelude

    import GHC.Driver.DynFlags
    import GHC.Core.SimpleOpt
    import GHC.Core.Coercion.Opt
    import GHCi.Message (EvalOpts(..))

    -- | Initialise coercion optimiser configuration from DynFlags
    initOptCoercionOpts :: DynFlags -> OptCoercionOpts
    initOptCoercionOpts :: DynFlags -> OptCoercionOpts
    initOptCoercionOpts DynFlags
    dflags = OptCoercionOpts
       { optCoercionEnabled :: Bool
    optCoercionEnabled = Bool -> Bool
    not (DynFlags -> Bool
    hasNoOptCoercion DynFlags
    dflags)
       }

    -- | Initialise Simple optimiser configuration from DynFlags
    initSimpleOpts :: DynFlags -> SimpleOpts
    initSimpleOpts :: DynFlags -> SimpleOpts
    initSimpleOpts DynFlags
    dflags = SimpleOpts
       { so_uf_opts :: UnfoldingOpts
    so_uf_opts = DynFlags -> UnfoldingOpts
    unfoldingOpts DynFlags
    dflags
       , so_co_opts :: OptCoercionOpts
    so_co_opts = DynFlags -> OptCoercionOpts
    initOptCoercionOpts DynFlags
    dflags
       , so_eta_red :: Bool
    so_eta_red = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_DoEtaReduction DynFlags
    dflags
       , so_inline :: Bool
    so_inline  = Bool
    True
       }

    -- | Instruct the interpreter evaluation to break...
    data EvalStep
      -- | ... at every breakpoint tick
      = EvalStepSingle
      -- | ... after any evaluation to WHNF
      -- (See Note [Debugger: Step-out])
      | EvalStepOut
      -- | ... only on explicit breakpoints
      | EvalStepNone

    -- | Extract GHCi options from DynFlags and step
    initEvalOpts :: DynFlags -> EvalStep -> EvalOpts
    initEvalOpts :: DynFlags -> EvalStep -> EvalOpts
    initEvalOpts DynFlags
    dflags EvalStep
    step =
      EvalOpts
        { useSandboxThread :: Bool
    useSandboxThread = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_GhciSandbox DynFlags
    dflags
        , singleStep :: Bool
    singleStep       = Bool
    singleStep
        , stepOut :: Bool
    stepOut          = Bool
    stepOut
        , breakOnException :: Bool
    breakOnException = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_BreakOnException DynFlags
    dflags
        , breakOnError :: Bool
    breakOnError     = GeneralFlag -> DynFlags -> Bool
    gopt GeneralFlag
    Opt_BreakOnError DynFlags
    dflags
        }
      where
        (Bool
    singleStep, Bool
    stepOut) = case EvalStep
    step of
          EvalStep
    EvalStepSingle -> (Bool
    True,  Bool
    False)
          EvalStep
    EvalStepOut    -> (Bool
    False, Bool
    True)
          EvalStep
    EvalStepNone   -> (Bool
    False, Bool
    False)