Closed pablisco closed 2 years ago
I somehow like that it's very clear right now from the types that you need to provide blocks to either the copyMap
arguments or the mutable copy
. What would you like to do here?
This is more for external dependencies. For instance, we could have:
@GenerateCopy
typealias ProcessPair<A, B> = Pair<A, B>
So then we can generate the relevant pairing for those.
Another alternative could be to add something like:
@GenerateCopy
private val typesToGenerate = listOf(Pair::class, ExternalDependency::class)
The only problem with this last one is that we can't define types with reified generics.
That could be another use case for typealias
as the user could ask us to provide concrete copy implementations where the type's parameters are defined.
If we have this:
data class class User(val name: String)
val pairOfUsers = Pair(User("Alice"), User("Bob"))
We can't do this:
pairOfUsers.copy {
first.name += " In Flames"
second.name += "'s Burgers"
}
The user could signal us to generate these like:
@GenerateCopy
typealias UserPair = Pair<User, User>
This is probably not the best example. Hopefully, it's clear what I mean. :sweat_smile:
Maybe we could have both?
The next step would be to be able to generate copy functions for a whole dependency. But we need the Gradle plugin to inspect the dependencies and process from there.
I'm having a go at this
When we have types that are out of out control we could annotate typealias to generate the relevant copy or transform functions.