SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Functors,Applicatives and MonadsFunctors,Applicatives and Monads
Pallavi Singh
Software Consultant
Knoldus Software LLP
Objectives:
 Functors
 Applicatives
 Monads
 Demo
Objectives:
 Functors
 Applicatives
 Monads
 Demo
Problem :
We have a simple value
We apply a function to it
Lets extend it ,
the value can be in a context,
Now when we apply a function
to this value,we get results
depending on the context.
Problem :
We have a simple value
We apply a function to it
Lets extend it ,
the value can be in a context,
Now when we apply a function
to this value,we get results
depending on the context.
Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Functors
When a value is wrapped in a context, you
can’t apply a normal function to the value.
We need a map. The map knows how to
apply functions to values that are wrapped in
a context.
Functors
When a value is wrapped in a context, you
can’t apply a normal function to the value.
We need a map. The map knows how to
apply functions to values that are wrapped in
a context.
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Functors
Definition : Functor is a type class. A Functor is
any data type that defines how map applies to it.
Speaking in-formally you apply a function to a
wrapped value using map. The map knows how to
apply the function.
Functors
Definition : Functor is a type class. A Functor is
any data type that defines how map applies to it.
Speaking in-formally you apply a function to a
wrapped value using map. The map knows how to
apply the function.
Functors
We have a Constructor C[_] and two types A and B,we
want to apply functions of type C[A]=>C[B], so we need
adequate transformations
( A=>B ) => ( C[A]=>C[B] )
And we need to define a map
def map[A,B](A=>B):(F[A]=>F[B] )
Functors
We have a Constructor C[_] and two types A and B,we
want to apply functions of type C[A]=>C[B], so we need
adequate transformations
( A=>B ) => ( C[A]=>C[B] )
And we need to define a map
def map[A,B](A=>B):(F[A]=>F[B] )
Functors
Example: Options , Streams
Object OptionFunctor extends Functor[Option] {
def map[A, B](f: A B): Option[A] Option[B] = option option map f⇒ ⇒ ⇒
}
Functors
Example: Options , Streams
Object OptionFunctor extends Functor[Option] {
def map[A, B](f: A B): Option[A] Option[B] = option option map f⇒ ⇒ ⇒
}
Problem :
Given a function
what happens when you apply a function to
another function , we have another function.
Functions are functors too ! A map on a function is
function composition.
Problem :
Given a function
what happens when you apply a function to
another function , we have another function.
Functions are functors too ! A map on a function is
function composition.
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Problem :
We have a value wrapped in context
And functions are wrapped in a context too!
Problem :
We have a value wrapped in context
And functions are wrapped in a context too!
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Applicatives
When a value and function both are wrapped in a
context. We can’t apply it as we apply a simple function.
We need an apply. It knows how to apply a function
wrapped in a context to a value wrapped in a context.
56rt67
Applicatives
When a value and function both are wrapped in a
context. We can’t apply it as we apply a simple function.
We need an apply. It knows how to apply a function
wrapped in a context to a value wrapped in a context.
56rt67
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Applicatives
Def : Applicative is typeclass. Applicative is any data type
that defines how apply applies to it.
Apply takes a functor that has a function in it and another
functor and extracts that function from the first functor
and then maps it over the second one.
Speaking in-formally you apply a function wrapped in
context to a value wrapped in context.
Applicatives
Def : Applicative is typeclass. Applicative is any data type
that defines how apply applies to it.
Apply takes a functor that has a function in it and another
functor and extracts that function from the first functor
and then maps it over the second one.
Speaking in-formally you apply a function wrapped in
context to a value wrapped in context.
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Applicatives
We have a Constructor C[_] and two types A and B, we
want to apply functions of type C[A]=>C[B],so we need
adequate transformations
(C[A=>B] ) => ( C[A]=>C[B] )
And we need to define a apply
def apply[A,B](F[A=>B]):(F[A]=>F[B] )
Applicatives
We have a Constructor C[_] and two types A and B, we
want to apply functions of type C[A]=>C[B],so we need
adequate transformations
(C[A=>B] ) => ( C[A]=>C[B] )
And we need to define a apply
def apply[A,B](F[A=>B]):(F[A]=>F[B] )
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Problem :
Given a function
what happens if we feed it a
wrapped value?
Problem :
Given a function
what happens if we feed it a
wrapped value?
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Monads
Monads apply a
function that
returns a
wrapped value to
a wrapped value.
Monads
Monads apply a
function that
returns a
wrapped value to
a wrapped value.
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Image Source :
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
Monads
Definition: Monad is a type class. A monad is a
data type that implements the flatMap.
Speaking in-formally you apply a function that
returns a wrapped value, to a wrapped value.
Monads
Definition: Monad is a type class. A monad is a
data type that implements the flatMap.
Speaking in-formally you apply a function that
returns a wrapped value, to a wrapped value.
Monads
We have a Constructor C[_] and two types A and
B,we want to apply functions of type C[A]=>C[B],
so we need adequate transformations
( A=>C[B] ) => ( C[A]=>C[B] )
And we need to define a flatMap
def flatMap[A,B](A=>F[B]):(F[A]=>F[B] )
Monads
We have a Constructor C[_] and two types A and
B,we want to apply functions of type C[A]=>C[B],
so we need adequate transformations
( A=>C[B] ) => ( C[A]=>C[B] )
And we need to define a flatMap
def flatMap[A,B](A=>F[B]):(F[A]=>F[B] )
Monads
Example: List , Set , Option and Future all
are Monads
Future is a wrapper over some asynchronous operation.
Once the future has been completed you can do
whatever it is you need to do with its result.
Monads
Example: List , Set , Option and Future all
are Monads
Future is a wrapper over some asynchronous operation.
Once the future has been completed you can do
whatever it is you need to do with its result.
Difference b/w Monad and Monoids ?
Monoid : Given a type T, a binary operation Op:(T,T)=>T
and instance Zero:T then the triple(T, Op , Zero) is called
a Monoid if it has the following properties: Neutral
Element and Associativity.
Monad instance simply wraps the value of type A within
the given context and expose a certain set of methods to
operate on them,
Monoid instance already knows how to combine these
values of type A within the given context.
Difference b/w Monad and Monoids ?
Monoid : Given a type T, a binary operation Op:(T,T)=>T
and instance Zero:T then the triple(T, Op , Zero) is called
a Monoid if it has the following properties: Neutral
Element and Associativity.
Monad instance simply wraps the value of type A within
the given context and expose a certain set of methods to
operate on them,
Monoid instance already knows how to combine these
values of type A within the given context.
Are Monads powerful than
Applicatives?
Applicatives and monads both model running
computations in sequence. But Monads are more
powerful because with applicatives you can sequence the
computations, but monads allow you to sequence
computations with the additional property that the result
of subsequent computations can depend on the result of
previous computation.
Are Monads powerful than
Applicatives?
Applicatives and monads both model running
computations in sequence. But Monads are more
powerful because with applicatives you can sequence the
computations, but monads allow you to sequence
computations with the additional property that the result
of subsequent computations can depend on the result of
previous computation.
Demo
https://github.com/knoldus/functors-applicatives-monads
Demo
https://github.com/knoldus/functors-applicatives-monads
QuestionsQuestions
References
 http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
 http://www.smartjava.org/content/scalaz-features-everyday-usage-part-1-typeclasses-
and-scala-extensions
 http://eed3si9n.com/learning-scalaz/Applicative.html
 https://thedet.wordpress.com/2013/02/11/functors-in-images/
 https://thedet.wordpress.com/2012/05/20/functors-monads-applicatives-playing-with-
map-functor/
References
 http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
 http://www.smartjava.org/content/scalaz-features-everyday-usage-part-1-typeclasses-
and-scala-extensions
 http://eed3si9n.com/learning-scalaz/Applicative.html
 https://thedet.wordpress.com/2013/02/11/functors-in-images/
 https://thedet.wordpress.com/2012/05/20/functors-monads-applicatives-playing-with-
map-functor/
Thank YouThank You

Weitere ähnliche Inhalte

Was ist angesagt?

The Functional Programmer's Toolkit (NDC London 2019)
The Functional Programmer's Toolkit (NDC London 2019)The Functional Programmer's Toolkit (NDC London 2019)
The Functional Programmer's Toolkit (NDC London 2019)Scott Wlaschin
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Scott Wlaschin
 
Towards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureTowards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureCodelyTV
 
Writer Monad for logging execution of functions
Writer Monad for logging execution of functionsWriter Monad for logging execution of functions
Writer Monad for logging execution of functionsPhilip Schwarz
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOJorge Vásquez
 
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018John De Goes
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Philip Schwarz
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaJorge Vásquez
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsPhilip Schwarz
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps Hitesh-Java
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of CompositionScott Wlaschin
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Jorge Vásquez
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaVladimir Kostyukov
 
Python oop - class 2 (inheritance)
Python   oop - class 2 (inheritance)Python   oop - class 2 (inheritance)
Python oop - class 2 (inheritance)Aleksander Fabijan
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Scott Wlaschin
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...Philip Schwarz
 

Was ist angesagt? (20)

The Functional Programmer's Toolkit (NDC London 2019)
The Functional Programmer's Toolkit (NDC London 2019)The Functional Programmer's Toolkit (NDC London 2019)
The Functional Programmer's Toolkit (NDC London 2019)
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)
 
Towards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal ArchitectureTowards Functional Programming through Hexagonal Architecture
Towards Functional Programming through Hexagonal Architecture
 
Writer Monad for logging execution of functions
Writer Monad for logging execution of functionsWriter Monad for logging execution of functions
Writer Monad for logging execution of functions
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018Blazing Fast, Pure Effects without Monads — LambdaConf 2018
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of Composition
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in Scala
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
This pointer
This pointerThis pointer
This pointer
 
Python oop - class 2 (inheritance)
Python   oop - class 2 (inheritance)Python   oop - class 2 (inheritance)
Python oop - class 2 (inheritance)
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...
 

Andere mochten auch

Domain-driven design
Domain-driven designDomain-driven design
Domain-driven designKnoldus Inc.
 
Go for the Money - JSR 354
Go for the Money - JSR 354Go for the Money - JSR 354
Go for the Money - JSR 354Anatole Tresch
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in ScalaJan Krag
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JSKnoldus Inc.
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async LibraryKnoldus Inc.
 
Getting Started With AureliaJs
Getting Started With AureliaJsGetting Started With AureliaJs
Getting Started With AureliaJsKnoldus Inc.
 
String interpolation
String interpolationString interpolation
String interpolationKnoldus Inc.
 
Mailchimp and Mandrill - The ‘Hominidae’ kingdom
Mailchimp and Mandrill - The ‘Hominidae’ kingdomMailchimp and Mandrill - The ‘Hominidae’ kingdom
Mailchimp and Mandrill - The ‘Hominidae’ kingdomKnoldus Inc.
 
Realm Mobile Database - An Introduction
Realm Mobile Database - An IntroductionRealm Mobile Database - An Introduction
Realm Mobile Database - An IntroductionKnoldus Inc.
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaKnoldus Inc.
 
An Introduction to Quill
An Introduction to QuillAn Introduction to Quill
An Introduction to QuillKnoldus Inc.
 
Introduction to Scala Macros
Introduction to Scala MacrosIntroduction to Scala Macros
Introduction to Scala MacrosKnoldus Inc.
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8Knoldus Inc.
 
Mandrill Templates
Mandrill TemplatesMandrill Templates
Mandrill TemplatesKnoldus Inc.
 
Introduction to Knockout Js
Introduction to Knockout JsIntroduction to Knockout Js
Introduction to Knockout JsKnoldus Inc.
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testingKnoldus Inc.
 
Effective way to code in Scala
Effective way to code in ScalaEffective way to code in Scala
Effective way to code in ScalaKnoldus Inc.
 
Introduction to ScalaZ
Introduction to ScalaZIntroduction to ScalaZ
Introduction to ScalaZKnoldus Inc.
 

Andere mochten auch (20)

Domain-driven design
Domain-driven designDomain-driven design
Domain-driven design
 
Go for the Money - JSR 354
Go for the Money - JSR 354Go for the Money - JSR 354
Go for the Money - JSR 354
 
Introduction to Option monad in Scala
Introduction to Option monad in ScalaIntroduction to Option monad in Scala
Introduction to Option monad in Scala
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
 
Akka streams
Akka streamsAkka streams
Akka streams
 
Getting Started With AureliaJs
Getting Started With AureliaJsGetting Started With AureliaJs
Getting Started With AureliaJs
 
String interpolation
String interpolationString interpolation
String interpolation
 
Mailchimp and Mandrill - The ‘Hominidae’ kingdom
Mailchimp and Mandrill - The ‘Hominidae’ kingdomMailchimp and Mandrill - The ‘Hominidae’ kingdom
Mailchimp and Mandrill - The ‘Hominidae’ kingdom
 
Realm Mobile Database - An Introduction
Realm Mobile Database - An IntroductionRealm Mobile Database - An Introduction
Realm Mobile Database - An Introduction
 
Kanban
KanbanKanban
Kanban
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for Scala
 
An Introduction to Quill
An Introduction to QuillAn Introduction to Quill
An Introduction to Quill
 
Introduction to Scala Macros
Introduction to Scala MacrosIntroduction to Scala Macros
Introduction to Scala Macros
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Mandrill Templates
Mandrill TemplatesMandrill Templates
Mandrill Templates
 
Introduction to Knockout Js
Introduction to Knockout JsIntroduction to Knockout Js
Introduction to Knockout Js
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
Effective way to code in Scala
Effective way to code in ScalaEffective way to code in Scala
Effective way to code in Scala
 
Introduction to ScalaZ
Introduction to ScalaZIntroduction to ScalaZ
Introduction to ScalaZ
 

Ähnlich wie Functors, Applicatives and Monads In Scala

C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]Rome468
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures topu93
 
Presentation on c programing satcture
Presentation on c programing satcture Presentation on c programing satcture
Presentation on c programing satcture topu93
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdfprasnt1
 
How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1Taisuke Oe
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++Mohamed Essam
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorialsakreyi
 
How to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksHow to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksKaty Slemon
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaManoj Kumar kothagulla
 
Tcs NQTExam technical questions
Tcs NQTExam technical questionsTcs NQTExam technical questions
Tcs NQTExam technical questionsAniketBhandare2
 
Introduction to C++ Programming
Introduction to C++ ProgrammingIntroduction to C++ Programming
Introduction to C++ ProgrammingPreeti Kashyap
 
C questions
C questionsC questions
C questionsparm112
 
Book management system
Book management systemBook management system
Book management systemSHARDA SHARAN
 
Architectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsArchitectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsDebasish Ghosh
 

Ähnlich wie Functors, Applicatives and Monads In Scala (20)

C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
 
Presentation on c programing satcture
Presentation on c programing satcture Presentation on c programing satcture
Presentation on c programing satcture
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
 
How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1How to start functional programming (in Scala): Day1
How to start functional programming (in Scala): Day1
 
C++ interview question
C++ interview questionC++ interview question
C++ interview question
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
C++
C++C++
C++
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 
How to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksHow to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooks
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kella
 
Tcs NQTExam technical questions
Tcs NQTExam technical questionsTcs NQTExam technical questions
Tcs NQTExam technical questions
 
Introduction to C++ Programming
Introduction to C++ ProgrammingIntroduction to C++ Programming
Introduction to C++ Programming
 
C questions
C questionsC questions
C questions
 
Book management system
Book management systemBook management system
Book management system
 
Oo ps exam answer2
Oo ps exam answer2Oo ps exam answer2
Oo ps exam answer2
 
Architectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain ModelsArchitectural Patterns in Building Modular Domain Models
Architectural Patterns in Building Modular Domain Models
 

Mehr von Knoldus Inc.

Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxKnoldus Inc.
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingKnoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionKnoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxKnoldus Inc.
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptxKnoldus Inc.
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfKnoldus Inc.
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingKnoldus Inc.
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesKnoldus Inc.
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxKnoldus Inc.
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxKnoldus Inc.
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxKnoldus Inc.
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxKnoldus Inc.
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxKnoldus Inc.
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationKnoldus Inc.
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationKnoldus Inc.
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIsKnoldus Inc.
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II PresentationKnoldus Inc.
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAKnoldus Inc.
 

Mehr von Knoldus Inc. (20)

Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRA
 

Kürzlich hochgeladen

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 

Kürzlich hochgeladen (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 

Functors, Applicatives and Monads In Scala

  • 1. Functors,Applicatives and MonadsFunctors,Applicatives and Monads Pallavi Singh Software Consultant Knoldus Software LLP
  • 2. Objectives:  Functors  Applicatives  Monads  Demo Objectives:  Functors  Applicatives  Monads  Demo
  • 3. Problem : We have a simple value We apply a function to it Lets extend it , the value can be in a context, Now when we apply a function to this value,we get results depending on the context. Problem : We have a simple value We apply a function to it Lets extend it , the value can be in a context, Now when we apply a function to this value,we get results depending on the context. Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 4. Functors When a value is wrapped in a context, you can’t apply a normal function to the value. We need a map. The map knows how to apply functions to values that are wrapped in a context. Functors When a value is wrapped in a context, you can’t apply a normal function to the value. We need a map. The map knows how to apply functions to values that are wrapped in a context. Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 5. Functors Definition : Functor is a type class. A Functor is any data type that defines how map applies to it. Speaking in-formally you apply a function to a wrapped value using map. The map knows how to apply the function. Functors Definition : Functor is a type class. A Functor is any data type that defines how map applies to it. Speaking in-formally you apply a function to a wrapped value using map. The map knows how to apply the function.
  • 6. Functors We have a Constructor C[_] and two types A and B,we want to apply functions of type C[A]=>C[B], so we need adequate transformations ( A=>B ) => ( C[A]=>C[B] ) And we need to define a map def map[A,B](A=>B):(F[A]=>F[B] ) Functors We have a Constructor C[_] and two types A and B,we want to apply functions of type C[A]=>C[B], so we need adequate transformations ( A=>B ) => ( C[A]=>C[B] ) And we need to define a map def map[A,B](A=>B):(F[A]=>F[B] )
  • 7. Functors Example: Options , Streams Object OptionFunctor extends Functor[Option] { def map[A, B](f: A B): Option[A] Option[B] = option option map f⇒ ⇒ ⇒ } Functors Example: Options , Streams Object OptionFunctor extends Functor[Option] { def map[A, B](f: A B): Option[A] Option[B] = option option map f⇒ ⇒ ⇒ }
  • 8. Problem : Given a function what happens when you apply a function to another function , we have another function. Functions are functors too ! A map on a function is function composition. Problem : Given a function what happens when you apply a function to another function , we have another function. Functions are functors too ! A map on a function is function composition. Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 9. Problem : We have a value wrapped in context And functions are wrapped in a context too! Problem : We have a value wrapped in context And functions are wrapped in a context too! Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 10. Applicatives When a value and function both are wrapped in a context. We can’t apply it as we apply a simple function. We need an apply. It knows how to apply a function wrapped in a context to a value wrapped in a context. 56rt67 Applicatives When a value and function both are wrapped in a context. We can’t apply it as we apply a simple function. We need an apply. It knows how to apply a function wrapped in a context to a value wrapped in a context. 56rt67 Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 11. Applicatives Def : Applicative is typeclass. Applicative is any data type that defines how apply applies to it. Apply takes a functor that has a function in it and another functor and extracts that function from the first functor and then maps it over the second one. Speaking in-formally you apply a function wrapped in context to a value wrapped in context. Applicatives Def : Applicative is typeclass. Applicative is any data type that defines how apply applies to it. Apply takes a functor that has a function in it and another functor and extracts that function from the first functor and then maps it over the second one. Speaking in-formally you apply a function wrapped in context to a value wrapped in context. Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 12. Applicatives We have a Constructor C[_] and two types A and B, we want to apply functions of type C[A]=>C[B],so we need adequate transformations (C[A=>B] ) => ( C[A]=>C[B] ) And we need to define a apply def apply[A,B](F[A=>B]):(F[A]=>F[B] ) Applicatives We have a Constructor C[_] and two types A and B, we want to apply functions of type C[A]=>C[B],so we need adequate transformations (C[A=>B] ) => ( C[A]=>C[B] ) And we need to define a apply def apply[A,B](F[A=>B]):(F[A]=>F[B] ) Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 13. Problem : Given a function what happens if we feed it a wrapped value? Problem : Given a function what happens if we feed it a wrapped value? Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 14. Monads Monads apply a function that returns a wrapped value to a wrapped value. Monads Monads apply a function that returns a wrapped value to a wrapped value. Image Source : http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
  • 16. Monads Definition: Monad is a type class. A monad is a data type that implements the flatMap. Speaking in-formally you apply a function that returns a wrapped value, to a wrapped value. Monads Definition: Monad is a type class. A monad is a data type that implements the flatMap. Speaking in-formally you apply a function that returns a wrapped value, to a wrapped value.
  • 17. Monads We have a Constructor C[_] and two types A and B,we want to apply functions of type C[A]=>C[B], so we need adequate transformations ( A=>C[B] ) => ( C[A]=>C[B] ) And we need to define a flatMap def flatMap[A,B](A=>F[B]):(F[A]=>F[B] ) Monads We have a Constructor C[_] and two types A and B,we want to apply functions of type C[A]=>C[B], so we need adequate transformations ( A=>C[B] ) => ( C[A]=>C[B] ) And we need to define a flatMap def flatMap[A,B](A=>F[B]):(F[A]=>F[B] )
  • 18. Monads Example: List , Set , Option and Future all are Monads Future is a wrapper over some asynchronous operation. Once the future has been completed you can do whatever it is you need to do with its result. Monads Example: List , Set , Option and Future all are Monads Future is a wrapper over some asynchronous operation. Once the future has been completed you can do whatever it is you need to do with its result.
  • 19. Difference b/w Monad and Monoids ? Monoid : Given a type T, a binary operation Op:(T,T)=>T and instance Zero:T then the triple(T, Op , Zero) is called a Monoid if it has the following properties: Neutral Element and Associativity. Monad instance simply wraps the value of type A within the given context and expose a certain set of methods to operate on them, Monoid instance already knows how to combine these values of type A within the given context. Difference b/w Monad and Monoids ? Monoid : Given a type T, a binary operation Op:(T,T)=>T and instance Zero:T then the triple(T, Op , Zero) is called a Monoid if it has the following properties: Neutral Element and Associativity. Monad instance simply wraps the value of type A within the given context and expose a certain set of methods to operate on them, Monoid instance already knows how to combine these values of type A within the given context.
  • 20. Are Monads powerful than Applicatives? Applicatives and monads both model running computations in sequence. But Monads are more powerful because with applicatives you can sequence the computations, but monads allow you to sequence computations with the additional property that the result of subsequent computations can depend on the result of previous computation. Are Monads powerful than Applicatives? Applicatives and monads both model running computations in sequence. But Monads are more powerful because with applicatives you can sequence the computations, but monads allow you to sequence computations with the additional property that the result of subsequent computations can depend on the result of previous computation.
  • 23. References  http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html  http://www.smartjava.org/content/scalaz-features-everyday-usage-part-1-typeclasses- and-scala-extensions  http://eed3si9n.com/learning-scalaz/Applicative.html  https://thedet.wordpress.com/2013/02/11/functors-in-images/  https://thedet.wordpress.com/2012/05/20/functors-monads-applicatives-playing-with- map-functor/ References  http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html  http://www.smartjava.org/content/scalaz-features-everyday-usage-part-1-typeclasses- and-scala-extensions  http://eed3si9n.com/learning-scalaz/Applicative.html  https://thedet.wordpress.com/2013/02/11/functors-in-images/  https://thedet.wordpress.com/2012/05/20/functors-monads-applicatives-playing-with- map-functor/