Currently, the syntax for creating a sealed class for an ADT is this:
sealed class Shape {
class Circle(val radius: Double) : Shape()
class Rect(val width: Double, val height: Double) : Shape()
}
To me, this feels repetitive and doesn’t encourage making new types, whereas these types should probably be the foundation for building apps in a functional style.
Would you consider adding some syntactic sugar to make this look cleaner/simpler? Perhaps it would be possible to reuse the “enum class” syntax:
enum class Shape {
Circle(val radius: Double),
Rect(val width: Double, val height: Double),
}
Thanks for considering. I’m new to Kotlin but it looks really exciting.