module Simulation.Aivika.GPSS.Block.Link
(linkBlock) where
import Simulation.Aivika
import Simulation.Aivika.GPSS.Block
linkBlock :: (a -> Process (Either (Block a ()) Bool))
-> Block a a
linkBlock :: forall a. (a -> Process (Either (Block a ()) Bool)) -> Block a a
linkBlock a -> Process (Either (Block a ()) Bool)
f =
Block { blockProcess :: a -> Process a
blockProcess = \a
a ->
do Either (Block a ()) Bool
x <- a -> Process (Either (Block a ()) Bool)
f a
a
case Either (Block a ()) Bool
x of
Left Block a ()
transfer ->
forall a. Process () -> Process a
transferProcess forall a b. (a -> b) -> a -> b
$
forall a b. Block a b -> a -> Process b
blockProcess Block a ()
transfer a
a
Right Bool
False ->
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
Right Bool
True ->
do Process ()
passivateProcess
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
}