3 ms·
I used to think that same thing I recently found a very smart fellow who has been writing translations of a small Scala "expression interpreter" with monads an
by gavinray 5y ago
I used to think that same thing
I recently found a very smart fellow who has been writing translations of a small Scala "expression interpreter" with monads and what.
But in Java. I kid you not.
He wrote it in JDK 8 Java (pretty far from Scala)
Then updated with JDK 15 features Java (getting closer)
I made a rough pass at JDK17 Java
using records and ADTs (sealed types) with pattern match "switch" and the net result is an almost verbatim translation.
https://github.com/Randgalt/expressive-java/issues/1 https://github.com/Randgalt/expressive-java/issues/1
There is one ugly line which JDK18 will fix, "destructuring in pattern captures/match".
See "Deconstruction Patterns" at bottom of page here:
https://openjdk.java.net/jeps/405 https://openjdk.java.net/jeps/405
- zactato 5y agoI don't think that JEP is part of JDK18 yet.