-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listen
and pass
breaks on error or with concurrency
#100
Comments
I gather that the problem that you are highlighting is solely on the What behaviour would you expect in case or errors? |
Sorry - I was mainly thinking about the situation for I'm not entirely sure with the semantics in the case of using a transformer stack, but I can imagine something like this going wrong: data M a = M { runM :: ExceptT () (State String) a }
deriving (Functor, Applicative, Monad, Mtl.MonadState String, Mtl.MonadError ())
deriving (HasSink "log" String, WriterLog "log" String)
via SinkLog (MonadState M)
deriving (HasThrow "err" ())
via MonadError m
f :: (Either () String, String)
f = runState (runExceptT $ runM $ tell "a" *> listen (tell "b" *> throw () *> tell "c")) ""
-- Expected: (Left (), "ab")
-- Actual: (Left (), "b") disclaimer - I don't have my machine near me, and i haven't tested this. Feel free to ignore before I get home and do some experiment. |
which is not atomic.
This issue about |
We could, presumably, implement That being said, I suppose that |
Hmm, I might be misreading, but I don't see how. The following kind of interleaving is the issue I'm referring to, where
Can we? |
(Guessing) For |
On
It probably depends how But maybe we should focus on the behaviour with exception first. |
My impression is that I believe we discussed a potential
Agreed. Coming back to |
What about introducing |
They are methods of An advantage of a dedicated class would be that atomicity could be specified on the class, such that all instances must fulfill it. Meaning, all code using |
The current definitions of
listen
andpass
are:There is no error recovery at all, and by temporarily "repurposing" the mutable state, other threads end up not writing to where they should be writing.
The concurrency problem may not be worth fixing (in some sense), but at least it deserves a warning in the docs; having no error recovery is arguably a larger problem.
The text was updated successfully, but these errors were encountered: