Hi, Consider such a case: I'm making a client program. There is a process, client and server exchange some information in a strict order. So I do (persudo code): exchange = do sendHello readMsg >>= expect hello processHelloReply sendWhatsyourname readMsg >>= expect name processNameReply
And expect is something like: expect c f (cmd, msg) = if c == cmd then f msg else fail "unexpected" This is OK until this situation: The server may send some special command, for example DEBUG, DISCONNECT. This breaks the process above. So I think I could throw the unexpected command to outer function to handle. Something like: main = do connect catch exchange $ \e -> do case e of UnexpectedCMD DEBUG -> -- ignore process UnexpectedCMD DISCONNECT -> -- disconnect process _ -> -- something really wrong Well, with Control.Exception, I do not know how to make this done. And with something like Data.Either, I got more problem like: 36| Couldn't match expected type `Control.Monad.Trans.State.Lazy.StateT 37| InternalState IO b' 38| with actual type `Either (Int8, ByteString) b1' 39| Expected type: (Int8, ByteString) 40| -> Control.Monad.Trans.State.Lazy.StateT InternalState IO b 41| Actual type: (Int8, ByteString) -> Either (Int8, ByteString) b1 -- 竹密岂妨流水过 山高哪阻野云飞 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe