Hello all :wave: I am trying to define a typeclass...
# arrow
n
Hello all 👋 I am trying to define a typeclass, I have the following
Copy code
data class Bank(val account: ErrorBox<Account>)
    data class Account(val balance: Int, val name: String)

    @JsonDeserialize(using = ErrorBoxDeserializer::class)
    class ErrorBox<T>(var failure: Throwable?, var value: T?)
and in my ErrorBoxDeserializer if the json is valid, I return a value otherwise an error. How would you do in order to give monad super powers to ErrorBox? it would be great if it could behave just like Either
r
Hi Nicolas! Assuming your ErrorBox is similar to option and you want to learn how to give those super powers you can use this file as baseline https://github.com/arrow-kt/arrow-core/blob/master/arrow-core/src/main/kotlin/arrow/core/extensions/option.kt
you may not need all extension or even you may not be able to satisfy them but the most important ones would be Monad and Fx that enables computation blocks over your type and will let you flatMap etc.
r
These extension need to be in a separate module if you are already using @higherkind since the processors for extensions and kinds at the moment in Arrow are codependent but this will change in the future
n
I am trying to do it with Either
Will have a look at those extensions too 👍 Thanks a lot
👍 1