import Control.EventDriven -- import Control.Talk import Control.Monad.State import Control.Monad.Tools -- main :: IO () main = do let itk = initEvent 0 cmdbind doWhile itk $ \tk -> do cmd <- getLine mtk <- putEvent ( \c -> print c >> return c ) tk cmd case mtk of Just ntk -> return ( ntk, True ) _ -> return ( tk, False ) -- print $ getEventValue rtk cmdbind, twomode :: String -> EventMonad String Int () cmdbind "succ" = modify (+1) cmdbind "quit" = removeContainer >> return () cmdbind "two" = bind twomode cmdbind "test" = bind testmode cmdbind "id" = put 111 cmdbind "id2" = put 222 cmdbind _ = return () twomode "id" = put 22 twomode "id2" = runEvent "id" >> delegate -- twomode _ = delegate -- twomode _ = modify (+1) >> delegate -- twomode _ = put 21 >> delegate twomode _ = put 8 >> delegate >> modify (+1) -- twomode _ = delegate >> modify (+1) testmode "test" = bind testmode2 testmode "id" = return 3 >> delegate >> modify (+ 1) testmode "hoge" = put 123 testmode "unbind" = unbind testmode _ = delegate testmode2 "id" = put 2 testmode2 "unbind" = unbind testmode2 _ = delegate