{-# LANGUAGE TemplateHaskell #-}
module PMS.Infra.ProcSpawn.DM.Type where
import Control.Monad.Logger
import Control.Monad.Reader
import Control.Monad.Except
import Control.Lens
import Data.Default
import Data.Aeson.TH
import qualified Control.Concurrent.STM as STM
import qualified System.Process as S
import qualified GHC.IO.Handle as S
import qualified PMS.Domain.Model.DM.Type as DM
import qualified PMS.Domain.Model.DM.TH as DM
data ProcData = ProcData {
ProcData -> Handle
_wHdLProcData :: S.Handle
, ProcData -> Handle
_rHdlProcData :: S.Handle
, ProcData -> Handle
_eHdlProcData :: S.Handle
, ProcData -> ProcessHandle
_pHdlProcData :: S.ProcessHandle
}
makeLenses ''ProcData
data AppData = AppData {
AppData -> TMVar (Maybe ProcData)
_processAppData :: STM.TMVar (Maybe ProcData)
, AppData -> TMVar ()
_lockAppData :: STM.TMVar ()
, AppData -> JsonRpcRequest
_jsonrpcAppData :: DM.JsonRpcRequest
}
makeLenses ''AppData
defaultAppData :: IO AppData
defaultAppData :: IO AppData
defaultAppData = do
TMVar (Maybe ProcData)
mgrVar <- Maybe ProcData -> IO (TMVar (Maybe ProcData))
forall a. a -> IO (TMVar a)
STM.newTMVarIO Maybe ProcData
forall a. Maybe a
Nothing
TMVar ()
lock <- () -> IO (TMVar ())
forall a. a -> IO (TMVar a)
STM.newTMVarIO ()
AppData -> IO AppData
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return AppData {
_processAppData :: TMVar (Maybe ProcData)
_processAppData = TMVar (Maybe ProcData)
mgrVar
, _lockAppData :: TMVar ()
_lockAppData = TMVar ()
lock
, _jsonrpcAppData :: JsonRpcRequest
_jsonrpcAppData = JsonRpcRequest
forall a. Default a => a
def
}
type AppContext = ReaderT AppData (ReaderT DM.DomainData (ExceptT DM.ErrorData (LoggingT IO)))
type IOTask = IO
data ProcStringToolParams =
ProcStringToolParams {
ProcStringToolParams -> String
_argumentsProcStringToolParams :: String
} deriving (Int -> ProcStringToolParams -> ShowS
[ProcStringToolParams] -> ShowS
ProcStringToolParams -> String
(Int -> ProcStringToolParams -> ShowS)
-> (ProcStringToolParams -> String)
-> ([ProcStringToolParams] -> ShowS)
-> Show ProcStringToolParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProcStringToolParams -> ShowS
showsPrec :: Int -> ProcStringToolParams -> ShowS
$cshow :: ProcStringToolParams -> String
show :: ProcStringToolParams -> String
$cshowList :: [ProcStringToolParams] -> ShowS
showList :: [ProcStringToolParams] -> ShowS
Show, ReadPrec [ProcStringToolParams]
ReadPrec ProcStringToolParams
Int -> ReadS ProcStringToolParams
ReadS [ProcStringToolParams]
(Int -> ReadS ProcStringToolParams)
-> ReadS [ProcStringToolParams]
-> ReadPrec ProcStringToolParams
-> ReadPrec [ProcStringToolParams]
-> Read ProcStringToolParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ProcStringToolParams
readsPrec :: Int -> ReadS ProcStringToolParams
$creadList :: ReadS [ProcStringToolParams]
readList :: ReadS [ProcStringToolParams]
$creadPrec :: ReadPrec ProcStringToolParams
readPrec :: ReadPrec ProcStringToolParams
$creadListPrec :: ReadPrec [ProcStringToolParams]
readListPrec :: ReadPrec [ProcStringToolParams]
Read, ProcStringToolParams -> ProcStringToolParams -> Bool
(ProcStringToolParams -> ProcStringToolParams -> Bool)
-> (ProcStringToolParams -> ProcStringToolParams -> Bool)
-> Eq ProcStringToolParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProcStringToolParams -> ProcStringToolParams -> Bool
== :: ProcStringToolParams -> ProcStringToolParams -> Bool
$c/= :: ProcStringToolParams -> ProcStringToolParams -> Bool
/= :: ProcStringToolParams -> ProcStringToolParams -> Bool
Eq)
$(deriveJSON defaultOptions {fieldLabelModifier = DM.dropDataName "ProcStringToolParams", omitNothingFields = True} ''ProcStringToolParams)
makeLenses ''ProcStringToolParams
instance Default ProcStringToolParams where
def :: ProcStringToolParams
def = ProcStringToolParams {
_argumentsProcStringToolParams :: String
_argumentsProcStringToolParams = String
forall a. Default a => a
def
}
data ProcCommandToolParams =
ProcCommandToolParams {
ProcCommandToolParams -> String
_commandProcCommandToolParams :: String
, ProcCommandToolParams -> Maybe [String]
_argumentsProcCommandToolParams :: Maybe [String]
} deriving (Int -> ProcCommandToolParams -> ShowS
[ProcCommandToolParams] -> ShowS
ProcCommandToolParams -> String
(Int -> ProcCommandToolParams -> ShowS)
-> (ProcCommandToolParams -> String)
-> ([ProcCommandToolParams] -> ShowS)
-> Show ProcCommandToolParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProcCommandToolParams -> ShowS
showsPrec :: Int -> ProcCommandToolParams -> ShowS
$cshow :: ProcCommandToolParams -> String
show :: ProcCommandToolParams -> String
$cshowList :: [ProcCommandToolParams] -> ShowS
showList :: [ProcCommandToolParams] -> ShowS
Show, ReadPrec [ProcCommandToolParams]
ReadPrec ProcCommandToolParams
Int -> ReadS ProcCommandToolParams
ReadS [ProcCommandToolParams]
(Int -> ReadS ProcCommandToolParams)
-> ReadS [ProcCommandToolParams]
-> ReadPrec ProcCommandToolParams
-> ReadPrec [ProcCommandToolParams]
-> Read ProcCommandToolParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ProcCommandToolParams
readsPrec :: Int -> ReadS ProcCommandToolParams
$creadList :: ReadS [ProcCommandToolParams]
readList :: ReadS [ProcCommandToolParams]
$creadPrec :: ReadPrec ProcCommandToolParams
readPrec :: ReadPrec ProcCommandToolParams
$creadListPrec :: ReadPrec [ProcCommandToolParams]
readListPrec :: ReadPrec [ProcCommandToolParams]
Read, ProcCommandToolParams -> ProcCommandToolParams -> Bool
(ProcCommandToolParams -> ProcCommandToolParams -> Bool)
-> (ProcCommandToolParams -> ProcCommandToolParams -> Bool)
-> Eq ProcCommandToolParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProcCommandToolParams -> ProcCommandToolParams -> Bool
== :: ProcCommandToolParams -> ProcCommandToolParams -> Bool
$c/= :: ProcCommandToolParams -> ProcCommandToolParams -> Bool
/= :: ProcCommandToolParams -> ProcCommandToolParams -> Bool
Eq)
$(deriveJSON defaultOptions {fieldLabelModifier = DM.dropDataName "ProcCommandToolParams", omitNothingFields = True} ''ProcCommandToolParams)
makeLenses ''ProcCommandToolParams
instance Default ProcCommandToolParams where
def :: ProcCommandToolParams
def = ProcCommandToolParams {
_commandProcCommandToolParams :: String
_commandProcCommandToolParams = String
forall a. Default a => a
def
, _argumentsProcCommandToolParams :: Maybe [String]
_argumentsProcCommandToolParams = Maybe [String]
forall a. Default a => a
def
}
data ProcStringArrayToolParams =
ProcStringArrayToolParams {
ProcStringArrayToolParams -> [String]
_argumentsProcStringArrayToolParams :: [String]
} deriving (Int -> ProcStringArrayToolParams -> ShowS
[ProcStringArrayToolParams] -> ShowS
ProcStringArrayToolParams -> String
(Int -> ProcStringArrayToolParams -> ShowS)
-> (ProcStringArrayToolParams -> String)
-> ([ProcStringArrayToolParams] -> ShowS)
-> Show ProcStringArrayToolParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProcStringArrayToolParams -> ShowS
showsPrec :: Int -> ProcStringArrayToolParams -> ShowS
$cshow :: ProcStringArrayToolParams -> String
show :: ProcStringArrayToolParams -> String
$cshowList :: [ProcStringArrayToolParams] -> ShowS
showList :: [ProcStringArrayToolParams] -> ShowS
Show, ReadPrec [ProcStringArrayToolParams]
ReadPrec ProcStringArrayToolParams
Int -> ReadS ProcStringArrayToolParams
ReadS [ProcStringArrayToolParams]
(Int -> ReadS ProcStringArrayToolParams)
-> ReadS [ProcStringArrayToolParams]
-> ReadPrec ProcStringArrayToolParams
-> ReadPrec [ProcStringArrayToolParams]
-> Read ProcStringArrayToolParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ProcStringArrayToolParams
readsPrec :: Int -> ReadS ProcStringArrayToolParams
$creadList :: ReadS [ProcStringArrayToolParams]
readList :: ReadS [ProcStringArrayToolParams]
$creadPrec :: ReadPrec ProcStringArrayToolParams
readPrec :: ReadPrec ProcStringArrayToolParams
$creadListPrec :: ReadPrec [ProcStringArrayToolParams]
readListPrec :: ReadPrec [ProcStringArrayToolParams]
Read, ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool
(ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool)
-> (ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool)
-> Eq ProcStringArrayToolParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool
== :: ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool
$c/= :: ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool
/= :: ProcStringArrayToolParams -> ProcStringArrayToolParams -> Bool
Eq)
$(deriveJSON defaultOptions {fieldLabelModifier = DM.dropDataName "ProcStringArrayToolParams", omitNothingFields = True} ''ProcStringArrayToolParams)
makeLenses ''ProcStringArrayToolParams
instance Default ProcStringArrayToolParams where
def :: ProcStringArrayToolParams
def = ProcStringArrayToolParams {
_argumentsProcStringArrayToolParams :: [String]
_argumentsProcStringArrayToolParams = [String]
forall a. Default a => a
def
}