module Simulation.Aivika.Trans.GPSS.Block
(Block(..),
GeneratorBlock(..),
withinBlock,
traceBlock) where
import Control.Monad
import Control.Monad.Trans
import qualified Control.Category as C
import Simulation.Aivika.Trans
data Block m a b =
Block { blockProcess :: a -> Process m b
}
newtype GeneratorBlock m a =
GeneratorBlock { runGeneratorBlock :: Block m a () -> Process m ()
}
instance MonadDES m => C.Category (Block m) where
id = Block { blockProcess = return }
x . y = Block { blockProcess = \a -> do { b <- blockProcess y a; blockProcess x b } }
withinBlock :: MonadDES m
=> Process m ()
-> Block m a a
withinBlock m =
Block { blockProcess = \a -> m >> return a }
traceBlock :: MonadDES m => String -> Block m a b -> Block m a b
traceBlock message x =
Block { blockProcess = \a -> traceProcess message (blockProcess x a) }