От
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)
]
Однако, когда я изменяю его на
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)
]
Счетчик увеличивается на
- 0 когда я смотрю
- 1 когда я не заглядываю
Это предполагаемое поведение? Такое ощущение, что вторая монада в msum «протекает», даже когда я смотрю.