Tomasz Krakowiak
04/22/2021, 9:51 AMelizarov
04/26/2021, 7:59 AMTomasz Krakowiak
04/26/2021, 3:39 PMpublic interface Store<in Query, out QueryResult<Q : Query>, in Mutation> {
fun <Q : Query>query(q : Q) : QueryResult<Q>
// ...
}
public class PropertyStore<Value>(
private var value: Value
) : Store<GetValue<Value>, <GetValue<Value>> => Value, SetValue<Value>> {
// ...
}
public class ListStore<Element>(/*...*/) : Store<ListQuery<Any?>, <ListQuery<Result>> => Result<Element>, ListMutation<Element>> {
// ...
}
sealed class ListQuery<out Result<E : Element>>
object ListSize : ListQuery<Int>
class ListGet : ListQuery<<E>=>E>(val index : Int)
another alternative for me to model it properly would be https://youtrack.jetbrains.com/issue/KT-33262 - and creating base class for Query<Result>
.typealias Converter<In, Out, Nullability<X>:X?> = (Nullability<In>) : Nullability<Out>
typealias NullableConverter<In, Out> = Converter<In, Out, <X>=>X?>
typealias NonNullConverter<In, Out> = Converter<In, Out, <X>=>X>