1
http://happstack.com/docs/crashcourse/HappstackState.html
當我運行的服務器,通過
- 1偷看計數器增加時,我偷看
- 2時,我不偷看
有問題的代碼是:
handlers :: ServerPart Response
handlers =
msum [ dir "peek" $ do c <- query PeekCounter
ok $ toResponse $ "peeked at the count and saw: " ++ show (unCounter c)
, do c <- update (AddCounter 1)
ok $ toResponse $ "New count is: " ++ show (unCounter c)
]
然而,當我通過
- 0它修改爲
handlers :: ServerPart Response handlers = msum [ dir "peek" $ do c <- query PeekCounter ok $ toResponse $ "peeked at the count and saw: " ++ show (unCounter c) , do ok $ toResponse $ "Stop here." , do c <- update (AddCounter 1) ok $ toResponse $ "New count is: " ++ show (unCounter c) ]
的計數器增加,當我偷看
- 1時,我不偷看
是那預期的行爲?感覺好像msum中的第二個monad即使在我偷看時也是「漏」了出來。