@@ -44,23 +44,23 @@ import Control.Distributed.Process.Serializable (Serializable)
4444import Control.Monad.Fix (MonadFix )
4545import Control.Monad.IO.Class (MonadIO )
4646import qualified Control.Monad.State.Strict as ST
47- ( MonadState
48- , StateT
49- , get
50- , modify
51- , lift
52- , runStateT
53- )
47+ ( MonadState
48+ , StateT
49+ , get
50+ , modify
51+ , lift
52+ , runStateT
53+ )
5454-- import Data.Binary (Binary)
5555import Data.Maybe (fromJust , isJust )
5656import Data.Sequence
57- ( Seq
58- , ViewR (.. )
59- , (<|)
60- , (|>)
61- , viewr
62- )
63- import qualified Data.Sequence as Q (empty , null )
57+ ( Seq
58+ , ViewR (.. )
59+ , (<|)
60+ , (|>)
61+ , viewr
62+ )
63+ import qualified Data.Sequence as Q (null )
6464import Data.Typeable (Typeable , typeOf )
6565import Data.Tuple (swap , uncurry )
6666-- import GHC.Generics
@@ -194,19 +194,19 @@ apply st msg step
194194 | Yield sn sd <- step = do
195195 P. liftIO $ putStrLn " Yield s d"
196196 return $ Just $ st { stName = sn, stData = sd }
197- | Await evt act <- step = do
197+ | Await evt act' <- step = do
198198 let ev = decodeToEvent evt msg
199199 P. liftIO $ putStrLn $ (show evt) ++ " decoded: " ++ (show $ isJust ev)
200- if isJust (ev) then apply st msg act
200+ if isJust (ev) then apply st msg act'
201201 else (P. liftIO $ putStrLn $ " Cannot decode " ++ (show (evt, msg))) >> return Nothing
202- | Always fsm <- step = do
202+ | Always fsm <- step = do
203203 P. liftIO $ putStrLn " Always..."
204204 runFSM st (handleMessage msg fsm) >>= mstash
205- | Perhaps eqn act <- step = do
205+ | Perhaps eqn act' <- step = do
206206 P. liftIO $ putStrLn $ " Perhaps " ++ (show eqn) ++ " in " ++ (show $ stName st)
207- if eqn == (stName st) then runFSM st act >>= stash
207+ if eqn == (stName st) then runFSM st act' >>= stash
208208 else (P. liftIO $ putStrLn " Perhaps Not..." ) >> return Nothing
209- | Matching chk fsm <- step = do
209+ | Matching chk fsm <- step = do
210210 P. liftIO $ putStrLn " Matching..."
211211 runFSM st (handleMessageIf msg chk fsm) >>= mstash
212212 | Sequence ac1 ac2 <- step = do s <- apply st msg ac1
@@ -219,10 +219,11 @@ apply st msg step
219219 else (P. liftIO $ putStrLn " try br 2" ) >> apply st msg al2
220220 | Reply rply <- step = do
221221 let ev = Eval $ do fSt <- processState
222- MP. lift $ do
223- P. liftIO $ putStrLn $ " Replying from " ++ (show fSt)
224- (r, s) <- runFSM fSt rply
225- (stReply fSt) $ wrapMessage r
222+ s' <- MP. lift $ do P. liftIO $ putStrLn $ " Replying from " ++ (show fSt)
223+ (r, s) <- runFSM fSt rply
224+ (stReply s) $ wrapMessage r
225+ return s
226+ setProcessState s'
226227 -- (_, st') <- runFSM st (addTransition ev)
227228 return $ enqueue st (Just ev)
228229 | otherwise = error $ baseErr ++ " .Internal.Types.apply:InvalidStep"
0 commit comments