{-# LANGUAGE GADTs #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Haskell.Debug.Adapter.State.Shutdown where

import Control.Monad.IO.Class
import Control.Monad.Except
import qualified System.Log.Logger as L

import Haskell.Debug.Adapter.Type
import Haskell.Debug.Adapter.Utility
import Haskell.Debug.Adapter.Constant


-- |
--
instance AppStateIF ShutdownStateData where
  -- |
  --
  entryAction :: AppState ShutdownStateData -> AppContext ()
entryAction AppState ShutdownStateData
ShutdownState = do
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ ErrMsg -> ErrMsg -> IO ()
L.debugM ErrMsg
_LOG_APP ErrMsg
"ShutdownState entryAction called."

    Event -> AppContext ()
addEvent Event
CriticalExitEvent

    forall (m :: * -> *) a. Monad m => a -> m a
return ()


  -- |
  --
  exitAction :: AppState ShutdownStateData -> AppContext ()
exitAction AppState ShutdownStateData
ShutdownState = do
    let msg :: ErrMsg
msg = ErrMsg
"ShutdownState exitAction must not be called."
    forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError ErrMsg
msg


  -- |
  --
  doActivity :: AppState ShutdownStateData
-> WrapRequest -> AppContext (Maybe StateTransit)
doActivity AppState ShutdownStateData
ShutdownState WrapRequest
_ = do
    let msg :: ErrMsg
msg = ErrMsg
"ShutdownState does not support any request."
    ErrMsg -> ErrMsg -> AppContext ()
infoEV ErrMsg
_LOG_APP ErrMsg
msg
    forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing