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

+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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 

Recently uploaded (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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
 
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 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
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
 
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 ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+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...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
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 ...
 
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
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

{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