2 ms·
Does Kotlin have algebraic types? Possibly via sealed traits or the like, similar to Scala?
by leshow 9y ago
Does Kotlin have algebraic types? Possibly via sealed traits or the like, similar to Scala?
- dcow 9y agoKotlin has sealed classes. It also has built in generic Pair and Triple containers. But no it doesn't really have algebraic types as you see in Haskell. For example, you can't build a linked list by `cons`ing Ints and Strings and then take the dot product with another Int-String list. It still relies on generics in that regard although it does make improvements with reified types (generics that are retained at runtime for use in type checking `is`--kotlin `instanceof`) and variance indicators.