Can it be considered a pure function?

70 Views Asked by At

I'm currently designing a functional application and stuck with a concept of referential transparency. I have the following trait

trait RemoteStringStorage[F[_]]{
    def getAndDeleteOnSuccess(f: String => F[Unit]): F[Unit]
}

What the getAndDeleteOnSuccess is supposed to do is to extract a String from some remote storage and apply f: String => F[Unit] (which is pure) to it. In case of success the String should be deleted from the storage. I cannot split the method to multiple methods since I use Storage-specific API that can perform such operation atomically.

The question is if such function is pure. Or is there any reason to define the trait as

trait RemoteStringStorage[F[_]]{
    def getAndDeleteOnSuccess(f: F[String => F[Unit]]): F[Unit]
}

?

0

There are 0 best solutions below