You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current API is a bit cursed.
I'd really like to have an ability to treat Schemas as usual data classes.
At least, when I'm constructing or changing them.
For instance, compiler plugin can generate constructor functions, copy functions, etc.
object Player : Schema<Player>() {
val Name = "name" let string
val Surname = "surname" let string
val Score = "score".mut(i32, default = 0)
// Can be generated by compiler plugin
operator fun invoke(
name: String,
surname: String,
score: Int? = null
): StructSnapshot<Player> = Player { p ->
p[Name] = "John"
p[Surname] = "Galt"
score?.let { p[Score] = it }
}
}
// Can be generated by compiler plugin
fun StructSnapshot<Player>.copy(
name: String? = null,
surname: String? = null,
score: Int? = null
): StructSnapshot<Player> = copy { p ->
name?.let { p[Name] = name }
surname?.let { p[Surname] = surname }
score?.let { p[Score] = score }
}
The text was updated successfully, but these errors were encountered:
Current API is a bit cursed.
I'd really like to have an ability to treat Schemas as usual data classes.
At least, when I'm constructing or changing them.
For instance, compiler plugin can generate constructor functions, copy functions, etc.
The text was updated successfully, but these errors were encountered: