I just learned about Kotlin's `where`, and that so...
# arrow
c
I just learned about Kotlin's
where
, and that sounds so much perfect for combining typeclasses https://kotlinlang.org/docs/reference/generics.html#upper-bounds
👍 1
b
Yeah I'm using it in my project arch
Copy code
suspend fun <T, R, M> T.fetchMapping(): M where T : Repository<R>, T : Mapper<R, M> = load().mapToValue()

class FetchUserUseCase(
  private val repository: Repository<User>,
  private val mapper: Mapper<UserPayload, User>
) : Repository<User> by repository, Mapper<UserPayload, User> by mapper

...

fetchUserUseCase.fetchMapping()
😄
c
Wow, I really like the ‘creating impossible types' thing. When reading KEEP-87, I always thought there would need to be a specific syntax for it, I didn't notice Kotlin already has one 😅