A leaner `Tuple` runtime with type proofs and auto...
# arrow-meta
r
A leaner
Tuple
runtime with type proofs and automatic conversions coming up in Arrow Meta
👍 1
d
Why not this way?
Copy code
inline fun <A, B> tupled(a: A, b: B): Tupel2<A, B> =
  Tupled(arrayOf(name, age)).widen()

fun Person.tupled(): Tuple2<String, Int> = tupled(name, age)
r
That's an option and Person.tupled can also be inlined
d
Copy code
@tupled
data class Person(val name: String, val age: Int)
could generate:
Copy code
typealias TupleForPerson = Tupel2<String, Int>

@proof(conversion = true)
inline fun Person.tupled(): TupleForPerson =   tupled(name, age)

@proof(conversion = true)
inline fun TupleForPerson.person(): Person {
  val (name, age) = this
  return Person(name, age)
}
r
yes, that is our plan in arrow.generic and other places, the proofs are automatically generated for all data classes
🙂 1