Working through <https://pragprog.com/book/swdddf/...
# arrow
m
Working through https://pragprog.com/book/swdddf/domain-modeling-made-functional, but attempting to use Kotlin, and Arrow to accomplish it. For function types, the best I've come up with is either a
typealias CheckProductCodeExists = (ProductCode) -> Boolean
or
Copy code
interface CheckAddressExists {
    suspend fun run(address: UnvalidatedAddress): Either<AddressValidationError, CheckedAddress>
}
Neither is as elegant as defining a type for a function, and then being able to 'implement' it like one can in F#. And if a function needs F#'s
async
, then it has to be defined as an interface, as
suspend
can only be put on a function. Is there another way to tackle this with something in Arrow? Typeclasses doesn't feel like the right answer here, as I'm likely only creating one function and likely only on one type.