-
Notifications
You must be signed in to change notification settings - Fork 6
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
Scoped effects is broken #5
Comments
Maybe-solution: Instead of mapping each effect to a handler, map each effect to a reference to a handler. Obviously we cannot use Therefore what we need is an immutable table that is passed around along with the Additionally this allows |
Regression:
|
@arybczak I've experimented with the fix mentioned in the previous comment and got considerable regression (also put above). Its performance in microbenchmarks is now close to At the same time, if this regression is fundamental, it further shows that |
Well, it turns out that it wasn't a fundamental problem. It was because:
data Eff es a = Eff (Rec es -> Mem -> IO a) performs way worse than: data Eff es a = Eff ((Rec es, Mem) -> IO a) Both of these are addressed in 65be66e. The regression now is small and acceptable in my opinion. |
Turns out
cleff
suffers the same problem aseff
(though I'm not sure if the cause is the same):Cause:
SomeAction
will use the environment at that time.local
will make a new environment in which direct calls toask
will refer to the new value correctlyask
. They still use the environment they captured.effectful
does not have this problem because itsReader
actually uses a thread-local mutable variable.cleff
can't be thread-local hence cannot do the same to fix the problem. I also don't know how we can retroactively change an environment captured in the past (maybe we can't).This also shows that
cleff
interpretation machanism has flaws. I'm not sure if this library is worth continuing planning for release or anything; it will likely stay at an experimental state. I will try to investigate this issue but this is likely to be fundamental to this approach.Investigation:
polysemy
also have this problem? If not, how does it solve that? If we adapt the same thing will we need to give up other things?(cc @arybczak)
Edit: maybe use
IntMap
as the underlying implementation ofRec
. Access is as good as constant time and modify is constant as well. This may give rise to some solutions.The text was updated successfully, but these errors were encountered: