Hei Hei !! I recently bumped to arrow 1.1.2. And I...
# arrow
s
Hei Hei !! I recently bumped to arrow 1.1.2. And I was wondering the rationale behind deprecating ResultEffect. I’ve been using it in my tests a lot. ResultEffect.bind() helps a lot in providing prerequisites my tests need to assert on something. For example inserting rows in databases. Most of my operations are effectful, so I have to wrap them either in either or eagerEffect. With ResultEffect I didn’t need to use these computation blocks. Take a look at this simple test example :
Copy code
import arrow.core.computations.ResultEffect.bind

@Test
fun `encrypt produces new encryption for given text and should be decrypted back `() {
    val text = "Some sensitive data :partying_face: 2020-06-27T19:11:44.095Z @#$%^&*(&^%$#@! åååå πø˜˜¶∞¢"
    val textByteArray: ByteArray = text.toByteArray()

    val firstEncryption: ByteArray = Crypto.encrypt(securityKey, textByteArray).bind()
    val secondEncryption: ByteArray = Crypto.encrypt(securityKey, textByteArray).bind()

    firstEncryption shouldNotBe secondEncryption

    val firstDecryption: ByteArray = Crypto.decrypt(securityKey, firstEncryption).bind()
    val secondDecryption: ByteArray = Crypto.decrypt(securityKey, secondEncryption).bind()

    firstDecryption shouldBe textByteArray
    secondDecryption shouldBe textByteArray
    String(firstDecryption) shouldBe text
    String(secondDecryption) shouldBe text
}
Is there some alternative, or am I forced to migrate my hundreds of tests 😅
s
Hey @Satyam Agarwal, It just moved to a different package, https://github.com/arrow-kt/arrow/blob/main/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/continuations/result.kt. What you were doing here was simply
getOrThrow
so you can safely refactor to
getOrThrow
or add the proper
arrow.core.continuations.result { }
wrapper around your tests to achieve the
bind
syntax.
It's not actually been removed, but
arrow.core.computations.ResultEffect.bind
was importable but unsafe outside of
result { }
. So we fixed the "unsafe" part
s
Right. Thanks a lot 🙂
s
What Crypto library are you using there @Satyam Agarwal?
I'm using this for a project, https://github.com/patrickfav/bcrypt. But I'd actually really love to have an MPP library, or SCrypt.
s
to make undeterministic SHA256 AEAD tokens
and deterministic HMAC512 tags
s
Ah, I see. Looks like that library could be easily be wrapped by Kotlin MPP 🤔
s
ye, they have language based implementations
👍 1
s