SlideShare una empresa de Scribd logo
1 de 30
Parametricity
Shyamendra Solanki
Key Idea: Generalize Abstractions
 Generalize an abstraction because removing non-essential information
clarifies its independent meaning.
 Reuse is Accidental.
Parametricity: Definition
 parametricity is an abstract uniformity property enjoyed by parametrically
polymorphic functions, which captures the intuition that all instances of a
polymorphic function act the same way.
Types are documentation
 Parametricity is an efficient and reliable tool to assist code-readability to
assist non-trivial software in a team environment.
 A function is specified by its parametric type and its tests.
 Parametric Type: proof-positive
 Test: proof-negative
Observe the types
 def add10(n: Int): Int
What does the function do?
 def add10(n: Int): Int
What does the function do?
 def add10(n: Int): Int
 Theorem: it returns one of the 2^32 values of int.
 Otherwise, it would not have compiled.
What does the function do?
 def function(elements: List[Int]): List[Int]
What does the function do?
 def function(elements: List[Int]): List[Int]
 The number of potential implementations is HUGE.
 -> It can return list of prime numbers.
 -> It can add 17 to every 11th element.
 -> It can return empty list.
 -> It can concatenate list with itself.
What does the function do?
 def function(elements: List[Int]): List[Int]
 What if we make it polymorphic?
What does the function do?
 def function(elements: List[Int]): List[Int]
 i.e. Abstract over type of list.
What does the function do?
 def function[A](elements: List[A]): List[A]
 Theorem:
 Every element in output list comes from input list.
 Otherwise, it would not have compiled.
What does the function do?
 def function[A](elements: List[A]): List[A]
 Theorem:
 Every element in output list comes from input list.
 Otherwise, it would not have compiled.
 By adding freedom in types, we have constrained the implementations.
Parametricity works on language subset
 These things break parametricity:
 Null
 Exception
 isInstanceOf
 asInstanceOf
 Side effects
 toString, hashCode, equals
 Notify/wait
 classOf
 recursion
Observe the types
 def irrelevant[A, B](in: List[A]): List[B]
Observe the types
 def irrelevant[A, B](in: A): B
Observe the types
 def irrelevant[A](a: A): A
Observe the types
 def irrelevant[A](a: A): (A, A, A, A)
Observe the types
 def irrelevant[A](a, A: b: A): A
Observe the types
 def irrelevant[A](abcd:(A, A, A, A)): A
Observe the types
 def irrelevant[A](a: String, b: A): A
Observe the types
 def irrelevant[A, B](la: List[A], lb: List[B]): Option[A]
Observe the types
 def irrelevant[A, B](f: A => B, i: Int): A => (B, B)
Observe the types
 def irrelevant[A, B, C](f: A => B, g: B => C, a: A): C
Observe the types
 def irrelevant[A](maybe: Option[A]): List[A]
Observe the types
 def irrelevant[A](elements: List[A]): Int
Observe the types
 def irrelevant[A, B: Monoid](f: A => B, elements: List[A]): B
Observe the types
 def irrelevant[A, B, F: Monad](fa: F[A], fb: F[B]): F[B]
Observe the types
 def irrelevant[A, B, F: Functor](fab: F[A => B], a: A): F[B]
Types are documentation
 Use them to your advantage.

Más contenido relacionado

La actualidad más candente (20)

Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
Nullable type in C#
Nullable type in C#Nullable type in C#
Nullable type in C#
 
Python basic operators
Python   basic operatorsPython   basic operators
Python basic operators
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7
 
Java basic operators
Java basic operatorsJava basic operators
Java basic operators
 
Ch02
Ch02Ch02
Ch02
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Typeclass
TypeclassTypeclass
Typeclass
 
Comparable vs comparator
Comparable vs comparatorComparable vs comparator
Comparable vs comparator
 
Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)Programming course slides c++ (Prof Mansoor Bhatti)
Programming course slides c++ (Prof Mansoor Bhatti)
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
 
Operators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NETOperators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NET
 
8 if
8 if8 if
8 if
 
C# operators
C# operatorsC# operators
C# operators
 
Ch06
Ch06Ch06
Ch06
 
C# chap 4
C# chap 4C# chap 4
C# chap 4
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
5.functions
5.functions5.functions
5.functions
 

Similar a Parametricity

Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Alexander Podkhalyuzin
 
Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Alexander Podkhalyuzin
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharpDaniele Pozzobon
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... FunctionsMichal Bigos
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Twoamiable_indian
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Bryan O'Sullivan
 
Complicated declarations in c
Complicated declarations in cComplicated declarations in c
Complicated declarations in cRahul Budholiya
 
What Referential Transparency can do for you
What Referential Transparency can do for youWhat Referential Transparency can do for you
What Referential Transparency can do for youLuka Jacobowitz
 
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
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Sheik Uduman Ali
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxlemonchoos
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III TermAndrew Raj
 
Write a complete C programme to implement the following sorting algor.docx
 Write a complete C programme to implement the following sorting algor.docx Write a complete C programme to implement the following sorting algor.docx
Write a complete C programme to implement the following sorting algor.docxajoy21
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golangwww.ixxo.io
 
Scalapeno18 - Thinking Less with Scala
Scalapeno18 - Thinking Less with ScalaScalapeno18 - Thinking Less with Scala
Scalapeno18 - Thinking Less with ScalaDaniel Sebban
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
Python’s filter() function An Introduction to Iterable Filtering
Python’s filter() function An Introduction to Iterable FilteringPython’s filter() function An Introduction to Iterable Filtering
Python’s filter() function An Introduction to Iterable FilteringInexture Solutions
 

Similar a Parametricity (20)

Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)
 
Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharp
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
Introduction to Python - Part Two
Introduction to Python - Part TwoIntroduction to Python - Part Two
Introduction to Python - Part Two
 
Real World Haskell: Lecture 3
Real World Haskell: Lecture 3Real World Haskell: Lecture 3
Real World Haskell: Lecture 3
 
Complicated declarations in c
Complicated declarations in cComplicated declarations in c
Complicated declarations in c
 
What Referential Transparency can do for you
What Referential Transparency can do for youWhat Referential Transparency can do for you
What Referential Transparency can do for you
 
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
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
 
IMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptxIMP PPT- Python programming fundamentals.pptx
IMP PPT- Python programming fundamentals.pptx
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
 
Write a complete C programme to implement the following sorting algor.docx
 Write a complete C programme to implement the following sorting algor.docx Write a complete C programme to implement the following sorting algor.docx
Write a complete C programme to implement the following sorting algor.docx
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
Scalapeno18 - Thinking Less with Scala
Scalapeno18 - Thinking Less with ScalaScalapeno18 - Thinking Less with Scala
Scalapeno18 - Thinking Less with Scala
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Python’s filter() function An Introduction to Iterable Filtering
Python’s filter() function An Introduction to Iterable FilteringPython’s filter() function An Introduction to Iterable Filtering
Python’s filter() function An Introduction to Iterable Filtering
 
Typeclasses
TypeclassesTypeclasses
Typeclasses
 

Último

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Último (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Parametricity

  • 2. Key Idea: Generalize Abstractions  Generalize an abstraction because removing non-essential information clarifies its independent meaning.  Reuse is Accidental.
  • 3. Parametricity: Definition  parametricity is an abstract uniformity property enjoyed by parametrically polymorphic functions, which captures the intuition that all instances of a polymorphic function act the same way.
  • 4. Types are documentation  Parametricity is an efficient and reliable tool to assist code-readability to assist non-trivial software in a team environment.  A function is specified by its parametric type and its tests.  Parametric Type: proof-positive  Test: proof-negative
  • 5. Observe the types  def add10(n: Int): Int
  • 6. What does the function do?  def add10(n: Int): Int
  • 7. What does the function do?  def add10(n: Int): Int  Theorem: it returns one of the 2^32 values of int.  Otherwise, it would not have compiled.
  • 8. What does the function do?  def function(elements: List[Int]): List[Int]
  • 9. What does the function do?  def function(elements: List[Int]): List[Int]  The number of potential implementations is HUGE.  -> It can return list of prime numbers.  -> It can add 17 to every 11th element.  -> It can return empty list.  -> It can concatenate list with itself.
  • 10. What does the function do?  def function(elements: List[Int]): List[Int]  What if we make it polymorphic?
  • 11. What does the function do?  def function(elements: List[Int]): List[Int]  i.e. Abstract over type of list.
  • 12. What does the function do?  def function[A](elements: List[A]): List[A]  Theorem:  Every element in output list comes from input list.  Otherwise, it would not have compiled.
  • 13. What does the function do?  def function[A](elements: List[A]): List[A]  Theorem:  Every element in output list comes from input list.  Otherwise, it would not have compiled.  By adding freedom in types, we have constrained the implementations.
  • 14. Parametricity works on language subset  These things break parametricity:  Null  Exception  isInstanceOf  asInstanceOf  Side effects  toString, hashCode, equals  Notify/wait  classOf  recursion
  • 15. Observe the types  def irrelevant[A, B](in: List[A]): List[B]
  • 16. Observe the types  def irrelevant[A, B](in: A): B
  • 17. Observe the types  def irrelevant[A](a: A): A
  • 18. Observe the types  def irrelevant[A](a: A): (A, A, A, A)
  • 19. Observe the types  def irrelevant[A](a, A: b: A): A
  • 20. Observe the types  def irrelevant[A](abcd:(A, A, A, A)): A
  • 21. Observe the types  def irrelevant[A](a: String, b: A): A
  • 22. Observe the types  def irrelevant[A, B](la: List[A], lb: List[B]): Option[A]
  • 23. Observe the types  def irrelevant[A, B](f: A => B, i: Int): A => (B, B)
  • 24. Observe the types  def irrelevant[A, B, C](f: A => B, g: B => C, a: A): C
  • 25. Observe the types  def irrelevant[A](maybe: Option[A]): List[A]
  • 26. Observe the types  def irrelevant[A](elements: List[A]): Int
  • 27. Observe the types  def irrelevant[A, B: Monoid](f: A => B, elements: List[A]): B
  • 28. Observe the types  def irrelevant[A, B, F: Monad](fa: F[A], fb: F[B]): F[B]
  • 29. Observe the types  def irrelevant[A, B, F: Functor](fab: F[A => B], a: A): F[B]
  • 30. Types are documentation  Use them to your advantage.