から
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 の 2 番目のモナドが「漏れている」ように感じます。