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?
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.
Activity
armanbilge commentedon Jul 7, 2022
I'm not sure. I feel like whether
Concurrent[Resource]makes sense is being conflated with whethermemoizecan be implemented generically.I don't remember seeing laws for
memoize, but it seems like some could be written in terms ofRef. Namely, that the effect in question is run at most once, since that is whatmemoizeis fundamentally about AFAICT.So long as it is possible for
Resourceto implement saidmemoizelawfully, then I'd sayConcurrent[Resource]makes fine sense.djspiewak commentedon Oct 29, 2022
Arman went and fixed this because that's what he does