arrow-kt / arrow-core

Λrrow Core is part of Λrrow, a functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
81 stars 30 forks source link

Invariant kinds #230

Closed sd-yip closed 3 years ago

sd-yip commented 4 years ago

What version are you currently using?

0.10.5

What would you like to see?

val intListFactory: KleisliOf<Int, ForListK, Int> = Kleisli { a: Int ->
  listOf(2 * a).k()
}
val anyListFactory: KleisliOf<Any, ForListK, Any> = intListFactory // Should raise a compile-time error here

anyListFactory.fix().run("hello") // ClassCastException is thrown instead

I suggest removing the out modifiers from these locations:

  1. https://github.com/arrow-kt/arrow-core/blob/62fc8359b2e451e7568a92df2a575407f744a008/arrow-annotations/src/main/java/arrow/hks.kt#L21
  2. https://github.com/arrow-kt/arrow-meta/blob/d427ec9cb3fb457eedc9ab9d2c917dd0140d298f/prelude/src/main/kotlin/arrow/kinds/kinds.kt#L53
nomisRev commented 3 years ago

Hey @sd-yip,

We're deprecating Kind in 0.12.0 and removing it all together in 0.13.0 to work towards a MPP 1.0.0 version. Thanks for reporting this issue!