SlideShare a Scribd company logo
Presented By:
Humera Ahmad
Kuldeepak Gupta
Software Consultant
Knoldus Inc
Deep Dive into Monads
and Cats Lib
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
Our Agenda
Introduction to Scala Cats
01
Type Class Components
02
Semigroups
03
Monoids
04
05 Monads
Introduction to
Scala Cats
LEARN NOW
c
Scala Cats
● A Library that provides the abstraction
for functional programming in scala.
● Goal is to provide a foundation for an
ecosystem of pure, typeful libraries to
support functional programming in
Scala applications.
● The name is a playful shortening of the
term category, from “Category Theory”
LEARN NOW
● Fast - It provides lightweight fibers for
asynchronous, highly concurrent applications
● Reliable - Keeps your application up and
running under high resource contention.
● Ecosystem - Provides a thriving ecosystem of
streaming frameworks, database layers, HTTP
Servers and much more!
● Community - Cats Effect is OS software
maintained by Typelevel community.
Type Class
Components
Type Class Components
Type Class Type Class Use Type Class Instance
Interface Objects Interface Syntax
LEARN NOW
c
Type Class
● Type classes are a pattern in
programming originating in HASKELL.
● The intent is to extend the existing
libraries with new functionality.
● Also, don’t need to use traditional
inheritance, and also without altering
the original library source code.
● API represented by trait with atleast
one type parameter.
LEARN NOW
c
Type Class
Instances
● Used to provide an implementation of
the type class for a specific type.
● Instances are defined by creating
concrete implementations of the type
class and tagging them with the implicit
keywords.
● These instances are also known as
implicit values.
LEARN NOW
c
Type Class
Use
● Simplest way of creating an interface
that uses a type class is to place in a
singleton object.
○ To use the object, just import any type
class instance.
● Alternative to Singleton objects, use
extension methods to extend existing
types with interface methods
○ To use syntax, import it alongside the
instances for the types needed.
Semigroups
LEARN NOW
c
Semigroups
● In mathematics, It is an algebraic
structure consisting of a set together
with an associative binary operation
● A generic type with a binary operation
and satisfying associativity.
Example
trait Semigroup[T] {
def combine(x: T, y: T): T
}
Monoids
LEARN NOW
c
Monoids
● An algebraic structure with a single
associative binary operation and an
identity element.
● Let’s make it easier: It allows us to add
or combine values. Working with lists,
adding values or concatenating strings.
Example
trait Monoid[T] extends Semigroup[T] {
def empty: T
}
Monads
LEARN NOW
c
Monad
● Common abstraction in Scala
● An abstraction that allows us to
represent sequences of operations
within the context such as a List, an
Option, Future, etc.
● Definition of Monad:
trait Monad[F[_]] {
def unit[A](val: A): F[A]
def flatMap[A, B](value: F[A])(func: A => F[B]): F[B]
}
Demonstration
Thank You !

More Related Content

PDF
Getting started with scala cats
PDF
Diving Into Scala Cats - Semigroups and Monoids
PDF
Programming in Scala - Lecture One
PPTX
Summer Training Project On Python Programming
ODP
Design Patterns Part1
PPTX
Untitled presentation about object oriented.pptx
PPTX
Class and Objects in python programming.pptx
PDF
Translating Apereo Software: A Case Study using Sakai and Transifex
Getting started with scala cats
Diving Into Scala Cats - Semigroups and Monoids
Programming in Scala - Lecture One
Summer Training Project On Python Programming
Design Patterns Part1
Untitled presentation about object oriented.pptx
Class and Objects in python programming.pptx
Translating Apereo Software: A Case Study using Sakai and Transifex

Similar to Deep Dive into Monads and Cats Lib (20)

PDF
Introduction to Kotlin - Android KTX
KEY
Programming with Python: Week 1
PDF
Python Programming - VI. Classes and Objects
PPT
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
PPTX
Gof design patterns
PDF
Design Patterns Illustrated
PDF
Python for katana
PDF
ITFT - Oops
PPTX
Creational Design Patterns.pptx
PPTX
Design Patterns In Scala
PPTX
Java interfaces
PDF
Orthogonality: A Strategy for Reusable Code
PPTX
My Presentation ITPdcjsdicjscisuchc.pptx
PPTX
My Presentation ITPsdhjccjh cjhj (1).pptx
PPTX
introduction to object orinted programming through java
PPTX
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
PPTX
OOPsConceptspythonenineeringcomputerscienceand engineering.pptx
PPTX
Introduction to Design Patterns
PPTX
Oop.pptx
PPTX
object oriented programming examples
Introduction to Kotlin - Android KTX
Programming with Python: Week 1
Python Programming - VI. Classes and Objects
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Gof design patterns
Design Patterns Illustrated
Python for katana
ITFT - Oops
Creational Design Patterns.pptx
Design Patterns In Scala
Java interfaces
Orthogonality: A Strategy for Reusable Code
My Presentation ITPdcjsdicjscisuchc.pptx
My Presentation ITPsdhjccjh cjhj (1).pptx
introduction to object orinted programming through java
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
OOPsConceptspythonenineeringcomputerscienceand engineering.pptx
Introduction to Design Patterns
Oop.pptx
object oriented programming examples
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.
Ad

Recently uploaded (20)

PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Encapsulation theory and applications.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
August Patch Tuesday
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
A comparative study of natural language inference in Swahili using monolingua...
Getting Started with Data Integration: FME Form 101
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25-Week II
WOOl fibre morphology and structure.pdf for textiles
Encapsulation theory and applications.pdf
1 - Historical Antecedents, Social Consideration.pdf
Web App vs Mobile App What Should You Build First.pdf
Group 1 Presentation -Planning and Decision Making .pptx
SOPHOS-XG Firewall Administrator PPT.pptx
TLE Review Electricity (Electricity).pptx
Hindi spoken digit analysis for native and non-native speakers
Heart disease approach using modified random forest and particle swarm optimi...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Digital-Transformation-Roadmap-for-Companies.pptx
August Patch Tuesday

Deep Dive into Monads and Cats Lib

  • 1. Presented By: Humera Ahmad Kuldeepak Gupta Software Consultant Knoldus Inc Deep Dive into Monads and Cats Lib
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time! Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. Our Agenda Introduction to Scala Cats 01 Type Class Components 02 Semigroups 03 Monoids 04 05 Monads
  • 5. LEARN NOW c Scala Cats ● A Library that provides the abstraction for functional programming in scala. ● Goal is to provide a foundation for an ecosystem of pure, typeful libraries to support functional programming in Scala applications. ● The name is a playful shortening of the term category, from “Category Theory”
  • 6. LEARN NOW ● Fast - It provides lightweight fibers for asynchronous, highly concurrent applications ● Reliable - Keeps your application up and running under high resource contention. ● Ecosystem - Provides a thriving ecosystem of streaming frameworks, database layers, HTTP Servers and much more! ● Community - Cats Effect is OS software maintained by Typelevel community.
  • 8. Type Class Components Type Class Type Class Use Type Class Instance Interface Objects Interface Syntax
  • 9. LEARN NOW c Type Class ● Type classes are a pattern in programming originating in HASKELL. ● The intent is to extend the existing libraries with new functionality. ● Also, don’t need to use traditional inheritance, and also without altering the original library source code. ● API represented by trait with atleast one type parameter.
  • 10. LEARN NOW c Type Class Instances ● Used to provide an implementation of the type class for a specific type. ● Instances are defined by creating concrete implementations of the type class and tagging them with the implicit keywords. ● These instances are also known as implicit values.
  • 11. LEARN NOW c Type Class Use ● Simplest way of creating an interface that uses a type class is to place in a singleton object. ○ To use the object, just import any type class instance. ● Alternative to Singleton objects, use extension methods to extend existing types with interface methods ○ To use syntax, import it alongside the instances for the types needed.
  • 13. LEARN NOW c Semigroups ● In mathematics, It is an algebraic structure consisting of a set together with an associative binary operation ● A generic type with a binary operation and satisfying associativity. Example trait Semigroup[T] { def combine(x: T, y: T): T }
  • 15. LEARN NOW c Monoids ● An algebraic structure with a single associative binary operation and an identity element. ● Let’s make it easier: It allows us to add or combine values. Working with lists, adding values or concatenating strings. Example trait Monoid[T] extends Semigroup[T] { def empty: T }
  • 17. LEARN NOW c Monad ● Common abstraction in Scala ● An abstraction that allows us to represent sequences of operations within the context such as a List, an Option, Future, etc. ● Definition of Monad: trait Monad[F[_]] { def unit[A](val: A): F[A] def flatMap[A, B](value: F[A])(func: A => F[B]): F[B] }