From
http://happstack.com/docs/crashcourse/HappstackState.html
When I run the server, the peek counter increases by
- 1 when I peek
- 2 when I do not peek
The relevant code in question is:
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)
]
However, when I modify it to
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)
]
The counter increases by
- 0 when I peek
- 1 when I non-peek
Is that the intended behaviour? It feels as if the second monad in msum is "leaking" even when I do a peek.