SlideShare a Scribd company logo
1 of 13
Download to read offline
SCALA
CODESPACE
COURSES
CO/CONTR &
CATEGORY THEORY
FUNCTION[-A, +B]
f: A => B
g: B => C
F[+A] : if A’ <: A then F[‘A] <: F[A]
A’ <: A => if a: A’ then a:A
A
A’
F[- A] : if A’ <: A then F[A] <: F[A’]
FUNCTION[-A, +B]
f: A => B
g: B => C
F[+A] : if A’ <: A then F[‘A] <: F[A]
A’ <: A => if a: A’ then a:A
A
A’
F[- A] : if A’ <: A then F[A] <: F[A’]
‘T
T
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g
Liskov Principle: Expr[T], T’ < T => Expr[T’]
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g
Liskov Principle: Expr[T], T’ < T => Expr[T’]
f’ < f; f’ |> g
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g
Liskov Principle: Expr[T], T’ < T => Expr[T’]
f’ < f; f’ |> g f’ : A’ => B’
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f’ g
f’ < f; f’ |> g f’ : A => B’ Let B’ :> B
Problem: g is not defined on B’ - B
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f’ g
f’ < f; f’ |> g f’ : A => B’ Let B’ :< B
Function[.. , +B]
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g’
g’ < g; f |> g’ g’ : B’ => C Let B’ :< B
Function[.. , +B]
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g’
g’ < g; f |> g’ g’ : B’ => C Let B’ :< B
Problem: g’ is not defined on B - B’
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g’
g’ < g; f |> g’ g’ : B’ => C Let B’ :> B
Function[-A , +B]
FUNCTION[-A, +B]
f: A => B
g: B => C
f andThen g
g(f(x))
f |> g
A B С
f g’
Function[-A , +B] :
application of Liskov substitution principle
// Barbara Liskov, CLU Language ~ 1974
-A — IN, +A - OUT
Object — bundle of methods (functions)
- (in) — any input ; + (out) — any output

More Related Content

What's hot

Feb 22. Exercise 6
Feb 22. Exercise 6Feb 22. Exercise 6
Feb 22. Exercise 6
ste ve
 
Fundamentos de programación
Fundamentos de programaciónFundamentos de programación
Fundamentos de programación
Diego Garcia
 

What's hot (20)

Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
 
Feb 22. Exercise 6
Feb 22. Exercise 6Feb 22. Exercise 6
Feb 22. Exercise 6
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
Programming meeting #4
Programming meeting #4Programming meeting #4
Programming meeting #4
 
Fundamentos de programación
Fundamentos de programaciónFundamentos de programación
Fundamentos de programación
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
 
Queue
QueueQueue
Queue
 
5.stack
5.stack5.stack
5.stack
 
Worst
WorstWorst
Worst
 
Ejercicio 6
Ejercicio 6Ejercicio 6
Ejercicio 6
 
Functional programming in Swift
Functional programming in SwiftFunctional programming in Swift
Functional programming in Swift
 
Derivadas
DerivadasDerivadas
Derivadas
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
20 days-of-2d-cad-exercises-part-i
20 days-of-2d-cad-exercises-part-i20 days-of-2d-cad-exercises-part-i
20 days-of-2d-cad-exercises-part-i
 
Let us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solutionLet us c (by yashvant kanetkar) chapter 1 solution
Let us c (by yashvant kanetkar) chapter 1 solution
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Data Visualization — Le funzionalità matematiche di Sage per la visualizzazio...
Data Visualization — Le funzionalità matematiche di Sage per la visualizzazio...Data Visualization — Le funzionalità matematiche di Sage per la visualizzazio...
Data Visualization — Le funzionalità matematiche di Sage per la visualizzazio...
 
Monoids
MonoidsMonoids
Monoids
 
Prelim exam algebra
Prelim exam   algebraPrelim exam   algebra
Prelim exam algebra
 

Similar to {co/contr} variance from LSP

07122555 0937185627
07122555 093718562707122555 0937185627
07122555 0937185627
faisupak
 
Lab Data Trial License -- for use to evaluate programs for possi.docx
Lab Data Trial License -- for use to evaluate programs for possi.docxLab Data Trial License -- for use to evaluate programs for possi.docx
Lab Data Trial License -- for use to evaluate programs for possi.docx
ssuser47f0be
 
Tutorial mathematical equation
Tutorial mathematical equationTutorial mathematical equation
Tutorial mathematical equation
kmasz kamal
 

Similar to {co/contr} variance from LSP (17)

Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
 
Taking your side effects aside
Taking your side effects asideTaking your side effects aside
Taking your side effects aside
 
Circular queues
Circular queuesCircular queues
Circular queues
 
Fields in cryptography
Fields in cryptographyFields in cryptography
Fields in cryptography
 
07122555 0937185627
07122555 093718562707122555 0937185627
07122555 0937185627
 
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
 
Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)
 
Lab Data Trial License -- for use to evaluate programs for possi.docx
Lab Data Trial License -- for use to evaluate programs for possi.docxLab Data Trial License -- for use to evaluate programs for possi.docx
Lab Data Trial License -- for use to evaluate programs for possi.docx
 
matrices
matricesmatrices
matrices
 
number-theory
number-theorynumber-theory
number-theory
 
201506 CSE340 Lecture 15
201506 CSE340 Lecture 15201506 CSE340 Lecture 15
201506 CSE340 Lecture 15
 
Monad and Algebraic Design in Functional Programming
Monad and Algebraic Design in Functional ProgrammingMonad and Algebraic Design in Functional Programming
Monad and Algebraic Design in Functional Programming
 
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEEIntroductory part of function for class 12th JEE
Introductory part of function for class 12th JEE
 
Tutorial mathematical equation
Tutorial mathematical equationTutorial mathematical equation
Tutorial mathematical equation
 
Week 5
Week 5Week 5
Week 5
 
Integers_part_3.pptx
Integers_part_3.pptxIntegers_part_3.pptx
Integers_part_3.pptx
 
Real problem2 p
Real problem2 pReal problem2 p
Real problem2 p
 

More from Ruslan Shevchenko

Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 

More from Ruslan Shevchenko (20)

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
 
Svitla talks 2021_03_25
Svitla talks 2021_03_25Svitla talks 2021_03_25
Svitla talks 2021_03_25
 
Akka / Lts behavior
Akka / Lts behaviorAkka / Lts behavior
Akka / Lts behavior
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
 
Scala / Technology evolution
Scala  / Technology evolutionScala  / Technology evolution
Scala / Technology evolution
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
IDLs
IDLsIDLs
IDLs
 
R ext world/ useR! Kiev
R ext world/ useR!  KievR ext world/ useR!  Kiev
R ext world/ useR! Kiev
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
Behind OOD: domain modelling in post-OO world.
Behind OOD:  domain modelling in post-OO world.Behind OOD:  domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
+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
 

Recently uploaded (20)

Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%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
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
+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...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 

{co/contr} variance from LSP

  • 2. FUNCTION[-A, +B] f: A => B g: B => C F[+A] : if A’ <: A then F[‘A] <: F[A] A’ <: A => if a: A’ then a:A A A’ F[- A] : if A’ <: A then F[A] <: F[A’]
  • 3. FUNCTION[-A, +B] f: A => B g: B => C F[+A] : if A’ <: A then F[‘A] <: F[A] A’ <: A => if a: A’ then a:A A A’ F[- A] : if A’ <: A then F[A] <: F[A’] ‘T T
  • 4. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g Liskov Principle: Expr[T], T’ < T => Expr[T’]
  • 5. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g Liskov Principle: Expr[T], T’ < T => Expr[T’] f’ < f; f’ |> g
  • 6. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g Liskov Principle: Expr[T], T’ < T => Expr[T’] f’ < f; f’ |> g f’ : A’ => B’
  • 7. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f’ g f’ < f; f’ |> g f’ : A => B’ Let B’ :> B Problem: g is not defined on B’ - B
  • 8. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f’ g f’ < f; f’ |> g f’ : A => B’ Let B’ :< B Function[.. , +B]
  • 9. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g’ g’ < g; f |> g’ g’ : B’ => C Let B’ :< B Function[.. , +B]
  • 10. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g’ g’ < g; f |> g’ g’ : B’ => C Let B’ :< B Problem: g’ is not defined on B - B’
  • 11. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g’ g’ < g; f |> g’ g’ : B’ => C Let B’ :> B Function[-A , +B]
  • 12. FUNCTION[-A, +B] f: A => B g: B => C f andThen g g(f(x)) f |> g A B С f g’ Function[-A , +B] : application of Liskov substitution principle // Barbara Liskov, CLU Language ~ 1974
  • 13. -A — IN, +A - OUT Object — bundle of methods (functions) - (in) — any input ; + (out) — any output