https://kotlinlang.org logo
Title
m

Marko Novakovic

03/10/2023, 11:21 AM
is there
import arrow.core.memoize
for
suspend fun
?
m

Marko Novakovic

03/10/2023, 11:22 AM
oooh I see, only pure functions. thanks for the instant response 😄
y

Youssef Shoaib [MOD]

03/12/2023, 9:34 AM
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

simon.vergauwen

03/12/2023, 10:02 AM
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.