-
I'm trying to create an effect that can cache a single value. The use case is a dynamic algorithm where we can skip a lot of work by caching the output for the largest input we've seen so far. My thought is that this could be an effect like this;
which would resume with the value if given or the cached value if the key matched or nothing. I tried to implement the handler like this;
but the compiler is giving me an error that I'm having trouble parsing.
Can I get some help understanding this error message? is there something obviously wrong about the implementation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think the problem is that you declare the handler to return
To fix this you should avoid using a local variable here and use a |
Beta Was this translation helpful? Give feedback.
I think the problem is that you declare the handler to return
()
without any effect and then resume in your handler by giving anoptional<double>
(the return type of the operation should match the value you give to resume). Furthermore you use a local variable that was declared outside of our handler which gives you thelocal<_h>
effect and for some reason the compiler also gives you aexn
effect. I think you can read this from the error message: