Submit Search
Upload
Java 8: Lambdas, Monads and Java Collections - 12.05.2015 @JInkubator
•
1 like
•
637 views
Grzegorz Piwowarek
Follow
This presentation focuses on proper use of new Java 8 features.
Read less
Read more
Technology
Report
Share
Report
Share
1 of 62
Download now
Download to read offline
Recommended
Chapter 4 - Classes in Java
Chapter 4 - Classes in Java
Khirulnizam Abd Rahman
Chapter 3 Arrays in Java
Chapter 3 Arrays in Java
Khirulnizam Abd Rahman
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!
John De Goes
Chapter 2 Java Methods
Chapter 2 Java Methods
Khirulnizam Abd Rahman
Humble introduction to category theory in haskell
Humble introduction to category theory in haskell
Jongsoo Lee
Chapter 2 Method in Java OOP
Chapter 2 Method in Java OOP
Khirulnizam Abd Rahman
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)
stasimus
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
John De Goes
Recommended
Chapter 4 - Classes in Java
Chapter 4 - Classes in Java
Khirulnizam Abd Rahman
Chapter 3 Arrays in Java
Chapter 3 Arrays in Java
Khirulnizam Abd Rahman
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!
John De Goes
Chapter 2 Java Methods
Chapter 2 Java Methods
Khirulnizam Abd Rahman
Humble introduction to category theory in haskell
Humble introduction to category theory in haskell
Jongsoo Lee
Chapter 2 Method in Java OOP
Chapter 2 Method in Java OOP
Khirulnizam Abd Rahman
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)
stasimus
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
John De Goes
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
John De Goes
Java cheatsheet
Java cheatsheet
Anass SABANI
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
Halogen: Past, Present, and Future
Halogen: Past, Present, and Future
John De Goes
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
greenwop
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Chris Richardson
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
John De Goes
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
stasimus
One Monad to Rule Them All
One Monad to Rule Them All
John De Goes
13 Strings and Text Processing
13 Strings and Text Processing
Intro C# Book
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
Mario Fusco
The java language cheat sheet
The java language cheat sheet
anand_study
Scala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
John De Goes
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
Mario Fusco
A taste of Functional Programming
A taste of Functional Programming
Jordan Open Source Association
OOP v3
OOP v3
Sunil OS
Monadic Java
Monadic Java
Mario Fusco
Python Cheat Sheet
Python Cheat Sheet
Muthu Vinayagam
Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8
JavaDayUA
The Road To Monad Transformers
The Road To Monad Transformers
Pawel Lisewski
F sharp - an overview
F sharp - an overview
Christoph Santschi
More Related Content
What's hot
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
John De Goes
Java cheatsheet
Java cheatsheet
Anass SABANI
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
Halogen: Past, Present, and Future
Halogen: Past, Present, and Future
John De Goes
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
greenwop
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Chris Richardson
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
John De Goes
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
stasimus
One Monad to Rule Them All
One Monad to Rule Them All
John De Goes
13 Strings and Text Processing
13 Strings and Text Processing
Intro C# Book
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
Mario Fusco
The java language cheat sheet
The java language cheat sheet
anand_study
Scala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
John De Goes
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
Mario Fusco
A taste of Functional Programming
A taste of Functional Programming
Jordan Open Source Association
OOP v3
OOP v3
Sunil OS
Monadic Java
Monadic Java
Mario Fusco
Python Cheat Sheet
Python Cheat Sheet
Muthu Vinayagam
Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8
JavaDayUA
What's hot
(20)
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
Java cheatsheet
Java cheatsheet
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Halogen: Past, Present, and Future
Halogen: Past, Present, and Future
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
One Monad to Rule Them All
One Monad to Rule Them All
13 Strings and Text Processing
13 Strings and Text Processing
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
The java language cheat sheet
The java language cheat sheet
Scala - where objects and functions meet
Scala - where objects and functions meet
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
A taste of Functional Programming
A taste of Functional Programming
OOP v3
OOP v3
Monadic Java
Monadic Java
Python Cheat Sheet
Python Cheat Sheet
Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8
Similar to Java 8: Lambdas, Monads and Java Collections - 12.05.2015 @JInkubator
The Road To Monad Transformers
The Road To Monad Transformers
Pawel Lisewski
F sharp - an overview
F sharp - an overview
Christoph Santschi
Monads in Swift
Monads in Swift
Vincent Pradeilles
Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)
Jens Ravens
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin
Introduction to Matlab.pdf
Introduction to Matlab.pdf
ssuser43b38e
Programming python quick intro for schools
Programming python quick intro for schools
Dan Bowen
Kyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Flavio W. Brasil
Legacy lambda code
Legacy lambda code
Peter Lawrey
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
Ruby Meditation
Dnipro conf
Dnipro conf
BotondOrbn
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
InfluxData
Advanced Swift Generics
Advanced Swift Generics
Max Sokolov
Monad
Monad
Konstantin (Konst) __
MP in Clojure
MP in Clojure
Kent Ohashi
Types Working for You, Not Against You
Types Working for You, Not Against You
C4Media
[JuraSIC! Meetup] Mateusz Stasch - Monady w .NET
[JuraSIC! Meetup] Mateusz Stasch - Monady w .NET
Future Processing
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
Randa Elanwar
Python-The programming Language
Python-The programming Language
Rohan Gupta
Similar to Java 8: Lambdas, Monads and Java Collections - 12.05.2015 @JInkubator
(20)
The Road To Monad Transformers
The Road To Monad Transformers
F sharp - an overview
F sharp - an overview
Monads in Swift
Monads in Swift
Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Introduction to Matlab.pdf
Introduction to Matlab.pdf
Programming python quick intro for schools
Programming python quick intro for schools
Kyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Legacy lambda code
Legacy lambda code
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
Dnipro conf
Dnipro conf
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Anais Dotis-Georgiou & Faith Chikwekwe [InfluxData] | Top 10 Hurdles for Flux...
Advanced Swift Generics
Advanced Swift Generics
Monad
Monad
MP in Clojure
MP in Clojure
Types Working for You, Not Against You
Types Working for You, Not Against You
[JuraSIC! Meetup] Mateusz Stasch - Monady w .NET
[JuraSIC! Meetup] Mateusz Stasch - Monady w .NET
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
Python-The programming Language
Python-The programming Language
Recently uploaded
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
apidays
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
apidays
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
Sandro Moreira
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
danishmna97
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
apidays
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Deepika Singh
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
UiPathCommunity
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
rafiqahmad00786416
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Orbitshub
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Product Anonymous
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Zilliz
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
DianaGray10
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Andrey Devyatkin
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
MIND CTI
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
jfdjdjcjdnsjd
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Rustici Software
Recently uploaded
(20)
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Java 8: Lambdas, Monads and Java Collections - 12.05.2015 @JInkubator
1.
JAVA 8LAMBDAS, MONADS
&& JAVA COLLECTIONS Grzegorz Piwowarek
2.
GRZEGORZ PIWOWAREK @PIVOVARIT
3.
GRZEGORZ PIWOWAREK @PIVOVARIT visionsoftondal.com
4.
Plan: -lambda expressions -java.util.function -monads -Optional -Stream
5.
lambda expressions (...) ->
statement - Anonymous function
6.
lambda expressions x ->
x + 1
7.
lambda expressions x ->
x + 1 - No type information
8.
lambda expressions x ->
x + 1 () -> 42 () -> {return 42;} (x, y) -> {} () -> {}
9.
method references
10.
java.util.function
11.
java.util.function
12.
java.util.function
13.
Function<T, R>, BiFunction<T,U,R> Consumer<T>
extends Function<T,Void> Supplier<T> extends Function<Void, T> Predicate<T> extends Function<T, Boolean> UnaryOperator<T> extends Function<T, T> BinaryOperator<T> extends BiFunction<T,T,T>
14.
Function<T, R>, BiFunction<T,U,R> Consumer<T>
extends Function<T,Void> Supplier<T> extends Function<Void, T> Predicate<T> extends Function<T, Boolean> UnaryOperator<T> extends Function<T, T> BinaryOperator<T> extends BiFunction<T,T,T>
15.
Function<T, R>, BiFunction<T,U,R> Consumer<T>
extends Function<T,Void> Supplier<T> extends Function<Void, T> Predicate<T> extends Function<T, Boolean> UnaryOperator<T> extends Function<T, T> BinaryOperator<T> extends BiFunction<T,T,T>
16.
Function<T, R>, BiFunction<T,U,R> Consumer<T>
extends Function<T,Void> Supplier<T> extends Function<Void, T> Predicate<T> extends Function<T, Boolean> UnaryOperator<T> extends Function<T, T> BinaryOperator<T> extends BiFunction<T,T,T>
17.
Function<T, R>, BiFunction<T,U,R> Consumer<T>
extends Function<T,Void> Supplier<T> extends Function<Void, T> Predicate<T> extends Function<T, Boolean> UnaryOperator<T> extends Function<T, T> BinaryOperator<T> extends BiFunction<T,T,T>
18.
MONAD
19.
20.
GOOGLE IMAGES...
21.
...
22.
MONAD Design pattern
23.
MONAD Design pattern http://got-steam.com/
24.
Why bother? : Boilerplate
-1 Readability +1 Complexity -1 Responsibility -1
25.
type: M<T> "unit": T
-> M<T> "bind": M<T> bind(T -> M<U>) = M<U> MONAD "bind": M<T> bind(T -> U)= M<U>
26.
type: M<T> "unit": T
-> M<T> "bind": M<T> bind(T -> M<U>) = M<U> MONAD "bind": M<T> bind(T -> U)= M<U>
27.
"bind": M<T> bind(T
-> U)= M<U> What if U: M<?> ?
28.
"bind": M<T> bind(T
-> U)= M<U> What if U: M<?> ? http://www.ivanaborovnjak.com/project/box-in-a-box/
29.
"bind": M<T> bind(T
-> U)= M<U> What if U: M<?> ? http://www.ivanaborovnjak.com/project/box-in-a-box/
30.
Monads in Java
8 Optional Stream CompletableFuture
31.
Monads in Java
8 Optional Stream CompletableFuture
32.
Optional Encapsulation of operations on
optional values
33.
Optional type: M<T> "unit": T
-> M<T> "bind": M<T> bind(T -> M<U>) = M<U>
34.
Optional type: Optional<T> "unit": T
-> M<T> "bind": M<T> bind(T -> M<U>) = M<U>
35.
Optional type: Optional<T> "unit": Optional.ofNullable(),
Optional.of() "bind": M<T> bind(T -> M<U>) = M<U>
36.
Optional type: Optional<T> "unit": Optional.ofNullable(),
Optional.of() "bind": Optional.flatMap()
37.
Filtering an Optional .filter(Predicate<T>)
38.
Unwrapping an Optional .get() .orElse(T
default) .orElseGet(Supplier<T>) .orElseThrow(Supplier<Ex>) .ifPresent(Consumer<T>)
39.
Java 7 style
40.
Java 8 style
41.
Java 8 style
- flatMap
42.
Java 7,5 style
;)
43.
Java 7,5 style
;)
44.
Stream Encapsulation of operations on
multiple items
45.
Stream type: Stream<T> "unit": Stream.of(),
Arrays.stream(), Collection.stream() "bind": Stream.flatMap()
46.
Stream lazy-initialized nonreusable
47.
Java7
48.
Java8
49.
Stream && Optional
50.
intermediate operations .map() .flatMap() .filter() .peek()
51.
intermediate operations .map() .flatMap() .filter() .peek() Stream not
consumed: does not print anything
52.
Consuming Stream .forEach(Consumer<T>) .collect() .reduce(BinaryOperator<T>) .allMatch(), anyMatch(),
noneMatch() .findFirst(), findAny() .count() .toArray()
53.
Stream.reduce()
54.
Collectors .toList(), toMap(), toSet(),
toCollection() .minBy(), maxBy() .joining() .partitioningBy() ...and many others
55.
Collectors.toList()
56.
Collectors.toMap()
57.
Collectors.joining()
58.
Stream in APIs BufferedReader.lines() Files.newDirectoryStream() Random.ints() ...
59.
you want more?
60.
https://github.com/ jasongoodwin/better-java-monads
61.
Thank You!
62.
REFERENCES: -MONADIC JAVA BY
MARIO FUSCO -WHAT'S WRONG WITH JAVA 8 BY PIERRE-YVES SAUMONT -WWW.ORACLE.COM
Download now