Allowing cases of an enum to stand alongside cases of another type in a switch expression?

David Alayachew davidalayachew at gmail.com
Mon Oct 17 21:00:10 UTC 2022


Hello Brian,

Thank you for your response! That clarifies everything for me now. I'm very
happy to hear that enums are on their way into the new world of
pattern-matching for Java.

> data List t = Nil | Cons t (List t)

This example is very helpful. I see exactly what you mean about NIL being
an enum-like object. And I also see what you mean progress wise too. We are
not quite there yet with NIL, but I am tempted to say that Cons has
functional parity with Java Records. That really goes to show just how far
Java has traveled in so short a time.

It's also hilarious because it was while studying Haskell and Scala's
typeclasses/pattern matching that I noticed this discrepancy and made a
post.

Another commenter on a previous thread [1] suggested I look into Scala's
type classes to better understand how they can solve the problem I had.
They had originally suggested Scala, but when studying the concept further,
my research brought me to Haskell too. I am still trying to wrap my brain
around how those 2 concepts work, but I can definitely see that there is a
lot of value and utility in both.

Thank you for your help and reassurance!
David Alayachew

[1] https://mail.openjdk.org/pipermail/amber-dev/2022-September/007459.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20221017/875ca650/attachment.htm>


More information about the amber-dev mailing list