SlideShare a Scribd company logo
Presented By: Mansi Babbar
Getting Started with
Scala Cats
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Mute
Please keep your window on mute
Avoid Disturbance
Avoid leaving your window
unmuted after asking a question
Agenda
What is Cats?
03 What are Implicits?
04 Implementation - The Cat Show
What are Type Classes?02
01
Meet Cats
● An abstraction for functional programming in
the Scala programming language.
● Cats contain a large variety of tools for
functional programming majorly in form of
type classes which we can apply to the
existing Scala types.
What is Cats?
Type Classes
What are Type Classes?
● Type classes are a pattern in
programming originating in Haskell.
● Allow us to extend existing libraries
with new functionality, without using
traditional inheritance, and also without
altering the original library source code.
Type Class Components
Type Class :
● An API or interface that represents some functionality.
● Represented by a trait with at least one type parameter.
Type Class Components
Type Class Instances :
● Provide implementations of the type class for specific types.
● In Scala, we define instances by creating concrete implementations of the
type class and tagging them with the implicit keyword:
Type Class Components
Type Class Use :
● Any functionality which requires a type class instance to work.
● In Scala, this means any method that accepts instances of the type class as
implicit parameters.
● Cats provide utilities which make type classes a little bit easier to use, and
you may sometimes see these patterns in other libraries also.
● Type class can be used by creating Interface Objects.
Type Class Components
Interface Objects :
The simplest way of creating an interface that uses a type class is to place
methods in a singleton object:
Type Class Components
Interface Objects :
To use this object, we have to import any type class instances we care about
and then call the relevant method:
Type Class Components
Implicits
What are Implicits?
● Working with implicit values and the implicit
parameters.
● Placing the instances in a companion object to
the type class has a very special significance in
Scala because it actually plays into something
called implicit scope.
What is Implicit Scope?
● Compiler will search for the candidate type class instances by type.
● Places where the compiler will search for the candidate instances is known as the
implicit scope.
● It applies at the call site which is the point where we call a method with an
implicit parameter.
● Definitions will only be included in implicit scope if they are tagged with the
implicit keyword.
● Compiler will fail with an ambiguous implicit values error if it sees multiple
candidate definitions.
What is Implicit Scope?
For example, in the following expression it will look for an instance of type
JsonWriter[String]:
What is Implicit Scope?
Type class instances packaging can be done as:
● by placing them in an object such as JsonWriterInstances
● by placing them in a trait
● by placing them in the companion object of the type class
Demo: The Cat Show
References
● https://typelevel.org/cats/
● http://underscore.io/books/scala-with-cats/
● https://www.scalawithcats.com/dist/scala-with-
cats.html
● https://github.com/typelevel/cats
● https://medium.com/@terezk_a/haskell-in-elm-
terms-type-classes-415f1612b335
Thank You :)

More Related Content

PPTX
Concurrent Applications with F# Agents
PPTX
Virtual function and abstract class
PPTX
JavaScripts internals #1
PDF
Pattern matching in Scala
PPTX
Python error handling
PPT
Framework Design Guidelines
PPTX
Introduction To Vavr: A Functional Java Library
PDF
Getting advanced in scala
Concurrent Applications with F# Agents
Virtual function and abstract class
JavaScripts internals #1
Pattern matching in Scala
Python error handling
Framework Design Guidelines
Introduction To Vavr: A Functional Java Library
Getting advanced in scala

What's hot (20)

PDF
Javascript classes and scoping
PDF
JDT Embraces Lambda Expressions - EclipseCon North America 2014
PPTX
An Introduction to ANTLR
PPTX
AngularConf2015
PDF
From Java to Kotlin
PDF
Eclipse and Java 8 - Eclipse Day India 2013
PDF
Introduction to Akka Clusters
PDF
Eclipse Tips & Tricks - EclipseCon North America 2014
PPTX
Gdg dev fest 2107 to kotlin, with love
KEY
Testing gone-right
PDF
Rootcon X - Reverse Engineering Swift Applications
PDF
Swift Tutorial Part 2. The complete guide for Swift programming language
PPTX
Scala - the good, the bad and the very ugly
PDF
Wahckon[2] - iOS Runtime Hacking Crash Course
PPTX
Tech breakfast 18
PDF
Lock-free algorithms for Kotlin Coroutines
PDF
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
PPTX
PDF
Functional programming with Xtend
PDF
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
Javascript classes and scoping
JDT Embraces Lambda Expressions - EclipseCon North America 2014
An Introduction to ANTLR
AngularConf2015
From Java to Kotlin
Eclipse and Java 8 - Eclipse Day India 2013
Introduction to Akka Clusters
Eclipse Tips & Tricks - EclipseCon North America 2014
Gdg dev fest 2107 to kotlin, with love
Testing gone-right
Rootcon X - Reverse Engineering Swift Applications
Swift Tutorial Part 2. The complete guide for Swift programming language
Scala - the good, the bad and the very ugly
Wahckon[2] - iOS Runtime Hacking Crash Course
Tech breakfast 18
Lock-free algorithms for Kotlin Coroutines
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Functional programming with Xtend
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
Ad

Similar to Getting started with scala cats (20)

PDF
Deep Dive into Monads and Cats Lib
PPTX
Introduction to Scala Type Classes Presentation
PPT
Scala Days San Francisco
PDF
Diving Into Scala Cats - Semigroups and Monoids
PDF
Understanding Implicits in Scala
PDF
What To Leave Implicit
PDF
Martin Odersky - Evolution of Scala
PPTX
What To Leave Implicit
PDF
Under the hood of scala implicits (kl10tch 10.03.2015)
PDF
Scala Implicits - Not to be feared
PDF
Under the hood of scala implicits (Scala eXchange 2014)
PDF
Software Engineering Thailand: Programming with Scala
PPTX
Introduction to Type Level Programming
PPTX
Scala 3 Is Coming: Martin Odersky Shares What To Know
PDF
Simplicitly
PPTX
Why Scala is the better Java
PDF
Scala Type Classes: Basics and More
PDF
Scala oo
PDF
The Scala Programming Language
PDF
Scala Sjug 09
Deep Dive into Monads and Cats Lib
Introduction to Scala Type Classes Presentation
Scala Days San Francisco
Diving Into Scala Cats - Semigroups and Monoids
Understanding Implicits in Scala
What To Leave Implicit
Martin Odersky - Evolution of Scala
What To Leave Implicit
Under the hood of scala implicits (kl10tch 10.03.2015)
Scala Implicits - Not to be feared
Under the hood of scala implicits (Scala eXchange 2014)
Software Engineering Thailand: Programming with Scala
Introduction to Type Level Programming
Scala 3 Is Coming: Martin Odersky Shares What To Know
Simplicitly
Why Scala is the better Java
Scala Type Classes: Basics and More
Scala oo
The Scala Programming Language
Scala Sjug 09
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.

Recently uploaded (20)

PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
A Presentation on Artificial Intelligence
PDF
August Patch Tuesday
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Tartificialntelligence_presentation.pptx
PPTX
A Presentation on Touch Screen Technology
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Encapsulation theory and applications.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
1. Introduction to Computer Programming.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
A Presentation on Artificial Intelligence
August Patch Tuesday
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A novel scalable deep ensemble learning framework for big data classification...
Chapter 5: Probability Theory and Statistics
Tartificialntelligence_presentation.pptx
A Presentation on Touch Screen Technology
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
cloud_computing_Infrastucture_as_cloud_p
Encapsulation theory and applications.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
OMC Textile Division Presentation 2021.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
1. Introduction to Computer Programming.pptx

Getting started with scala cats

  • 1. Presented By: Mansi Babbar Getting Started with Scala Cats
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Respect Knolx session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Mute Please keep your window on mute Avoid Disturbance Avoid leaving your window unmuted after asking a question
  • 3. Agenda What is Cats? 03 What are Implicits? 04 Implementation - The Cat Show What are Type Classes?02 01
  • 5. ● An abstraction for functional programming in the Scala programming language. ● Cats contain a large variety of tools for functional programming majorly in form of type classes which we can apply to the existing Scala types. What is Cats?
  • 7. What are Type Classes? ● Type classes are a pattern in programming originating in Haskell. ● Allow us to extend existing libraries with new functionality, without using traditional inheritance, and also without altering the original library source code.
  • 9. Type Class : ● An API or interface that represents some functionality. ● Represented by a trait with at least one type parameter. Type Class Components
  • 10. Type Class Instances : ● Provide implementations of the type class for specific types. ● In Scala, we define instances by creating concrete implementations of the type class and tagging them with the implicit keyword: Type Class Components
  • 11. Type Class Use : ● Any functionality which requires a type class instance to work. ● In Scala, this means any method that accepts instances of the type class as implicit parameters. ● Cats provide utilities which make type classes a little bit easier to use, and you may sometimes see these patterns in other libraries also. ● Type class can be used by creating Interface Objects. Type Class Components
  • 12. Interface Objects : The simplest way of creating an interface that uses a type class is to place methods in a singleton object: Type Class Components
  • 13. Interface Objects : To use this object, we have to import any type class instances we care about and then call the relevant method: Type Class Components
  • 15. What are Implicits? ● Working with implicit values and the implicit parameters. ● Placing the instances in a companion object to the type class has a very special significance in Scala because it actually plays into something called implicit scope.
  • 16. What is Implicit Scope? ● Compiler will search for the candidate type class instances by type. ● Places where the compiler will search for the candidate instances is known as the implicit scope. ● It applies at the call site which is the point where we call a method with an implicit parameter. ● Definitions will only be included in implicit scope if they are tagged with the implicit keyword. ● Compiler will fail with an ambiguous implicit values error if it sees multiple candidate definitions.
  • 17. What is Implicit Scope? For example, in the following expression it will look for an instance of type JsonWriter[String]:
  • 18. What is Implicit Scope? Type class instances packaging can be done as: ● by placing them in an object such as JsonWriterInstances ● by placing them in a trait ● by placing them in the companion object of the type class
  • 20. References ● https://typelevel.org/cats/ ● http://underscore.io/books/scala-with-cats/ ● https://www.scalawithcats.com/dist/scala-with- cats.html ● https://github.com/typelevel/cats ● https://medium.com/@terezk_a/haskell-in-elm- terms-type-classes-415f1612b335