raulraja
08/02/2017, 2:44 PMimplicit
like system for Kotlin based on global instances. In order to support implicits for generic types and emulated higher kinds in Kategory (https://github.com/kategory) we need to know when a call site requests an implicit making it's generic representation concrete. For example:
@implicit fun provideIntList(): List<Int> = listOf(1,2,3)
inline fun <reified A> la(@implicit l: List<A>): List<A> = l
val lint: List<Int> = la<Int>()
la<Int>()
should compile because there is a global implicit provideIntList(): List<Int>
available in the global scope. If we can support this case with generics we can encode Typeclasses in Kotlin which is currently not possible without reified generics and runtime lookups.