diff --git a/slides.md b/slides.md index fdfcbb8..bd48389 100644 --- a/slides.md +++ b/slides.md @@ -380,9 +380,7 @@ ```java sealed interface List { - record NonEmpty(T head, List tail) implements List {} - record Empty() implements List {} } ``` @@ -450,9 +448,7 @@ ```java sealed interface Tree { - record Node(T value, Tree left, Tree right) implements Tree { } - record Leaf(T value) implements Tree {} } ``` @@ -463,9 +459,7 @@ ```java sealed interface Optional { - record Empty() implements Optional { } - record Present(T value) implements Optional {} } ``` @@ -476,7 +470,6 @@ ```java sealed interface Optional { - default Optional map(Function mapper) { return switch (this) { case Present(var value) -> new Present<>(mapper.apply(value)); @@ -492,7 +485,6 @@ ```java sealed interface Optional { - default Optional filter(Predicate filter) { return switch (this) { case Present(var value) when filter.test(value) -> this; @@ -509,7 +501,6 @@ ```java sealed interface Optional { - default R fold(Supplier onEmpty, Function onPresent) { return switch (this) { case Present(var value) -> onPresent.apply(value); @@ -525,9 +516,7 @@ ```java sealed interface Either { - record Left(L left) implements Either { } - record Right(R right) implements Either {} } ``` @@ -604,11 +593,9 @@ # ADTs: DSLs ```java -sealed interface Expr { - static void main() { - sum(val(1), val(2)).print(); - times(diff(val(10), val(8)), val(2)).print(); - } +static void main() { + sum(val(1), val(2)).print(); + times(diff(val(10), val(8)), val(2)).print(); } ``` @@ -953,6 +940,8 @@ # Links - [Data Oriented Programmig](https://www.infoq.com/articles/data-oriented-programming-java/) Brian Goetz +- [Why ADTs are important?](https://www.youtube.com/watch?v=LkqTLJK2API) +- [Java 23: Restoring the Balance with Primitive Patterns](https://nipafx.dev/inside-java-newscast-66/)