<@U65FK6QNB> I think you can use ByteBuffer from J...
# functional
r
@jimn I think you can use ByteBuffer from Java with Kotlin. If you need to wrap any ops or define typeclasses for it you can do it with Kategory. The only issues is that typeclasses are currently looked up at runtime via reified generics and default method values in this way: Say you have a typeclass such as:
Copy code
interface ByteBufferOps<A> {
    fun fromByteBuffer(b: ByteBuffer): A
    fun toByteBuffer(a: A): ByteBuffer
}
And you can declare instances like:
Copy code
import kategory.*
object PersonToByteBuffer : ByteBufferOps<Person>, GlobalInstance<ByteBufferOps<Person>> {
    fun fromByteBuffer(b: ByteBuffer): Person = TODO()
    fun toByteBuffer(a: Person): ByteBuffer = TODO()
}

inline fun <reified A> byteBufferOps(): ByteBufferOps<A> = instance(InstanceParametrizedType(ByteBufferOps::class.java, listOf(A::class.java)))
then you can declare abstract polymorphic programs like so:
Copy code
inline fun <reified A> serialize(a: A, BO: ByteBufferOps<A> = byteBufferOps()) = BO.toByteBuffer(a)
and when you are ready to make them concrete:
Copy code
serialize(person)