You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second use will end up accessing the resource after the finalizers have already run. It's not entirely clear what the ideal semantic here, but this seems… not great. One possible answer would be that the memoization needs to be re-run once the first use happens, but there's no way to do this generically, since memoize is implemented as a generic combinator on Concurrent.
This in turn raises an interesting question: is this an early indication that Concurrent[Resource] just doesn't make sense? Are there other such examples? Can we quantify the "weirdness" in terms of laws?
The text was updated successfully, but these errors were encountered:
is this an early indication that Concurrent[Resource] just doesn't make sense
I'm not sure. I feel like whether Concurrent[Resource] makes sense is being conflated with whether memoize can be implemented generically.
I don't remember seeing laws for memoize, but it seems like some could be written in terms of Ref. Namely, that the effect in question is run at most once, since that is what memoize is fundamentally about AFAICT.
So long as it is possible for Resource to implement said memoize lawfully, then I'd say Concurrent[Resource] makes fine sense.
Or rather, it's weird if you
use
the results. For example:The second
use
will end up accessing the resource after the finalizers have already run. It's not entirely clear what the ideal semantic here, but this seems… not great. One possible answer would be that the memoization needs to be re-run once the firstuse
happens, but there's no way to do this generically, sincememoize
is implemented as a generic combinator onConcurrent
.This in turn raises an interesting question: is this an early indication that
Concurrent[Resource]
just doesn't make sense? Are there other such examples? Can we quantify the "weirdness" in terms of laws?The text was updated successfully, but these errors were encountered: