is there `import arrow.core.memoize` for `suspend ...
# arrow
m
is there
import arrow.core.memoize
for
suspend fun
?
m
oooh I see, only pure functions. thanks for the instant response 😄
y
Would it not be valid to memoise a pure function that happens to use
suspend
to do its work on
<http://Dispatchers.IO|Dispatchers.IO>
though? or is it the case that for such a function, one should perhaps separate it into 2 functions, one pure and one
suspend
with the latter calling a memoised version of the former and doing
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
?
s
one should perhaps separate it into 2 functions, one pure and one
suspend
with the latter calling a memoised version of the former and doing
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
?
Yes, that would be the general pattern since dispatching is also considered an impure operation in FP. In practice I am curious if these function really provide any value though which is my original answer to the question was also to be use a proper
Cache
abstraction. I've never used
memoise
in Kotlin.