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