``` sealed class Fix<F> data class MkFix<...
# announcements
i
Copy code
sealed class Fix<F>
data class MkFix<F> (val x: F<Fix<F>>): Fix<F>()
this is possible?
a
Your data class doesn’t need declare the generic parameter for
F
and just use it as is. e.g.:
Copy code
sealed class Fix<F>
data class MkFix<F> (val x: F): Fix<F>()
i
@Amirul Zin no, it’s a recursive type
a
Have you tried my code?
i
sorry, I can’t access my laptop now
a
It’s the same as List<T>. e.g you can simply have:
Copy code
List<List<List<List<T>>>>
Since T is generic, so even T itself can be another parametrized generic.
m
You can do this to constrain the
F
type to `Fix<F>`:
Copy code
sealed class Fix<F>
data class MkFix<F : Fix<F>> (val x: F): Fix<F>()
👍 5
i
and what values would have this type?
k
class Foo: Fix<Foo>()
i
and what it can be used for?
s
This is not possible. You can't have a type
F<A>
where
F
itself is a generic type parameter. Higher kind types are not possible on Kotlin.