SlideShare a Scribd company logo
1 of 20
Download to read offline
Coeffects:A calculus of context-dependent computation 
Tomas Petricek, Dominic Orchard and Alan Mycroft 
University of Cambridge 
{name.surname}@cl.cam.ac.uk|@tomaspetricek| @dorchard
Γ⊢푒:휏
Properties of computations 
Effect systems 
Effects on environment 
Modeled using monads 
Coeffect systems 
Requirements on environment 
Modeled using comonads 
Γ⊢푒:휏&흈 
Γ@풓⊢푒:휏
View from the extreme left 
Variable related 
Liveness 
Bounded linear logic 
Data-flow programming 
Provenance 
Environment related 
Implicit parameters 
Type classes 
Distributed computing 
Platform versioning
Variable related
Coeffect calculus for bounded reuse 
Coeffect annotations 
track number of variable uses 
vectorof variable annotations + function annotation 
richer structure than effect systems 
푦:int@1⊢휆푥→푦+푥+푥∶푖푛푡→ퟐ 푖푛푡
Coeffect calculus for bounded reuse 
structural rules = contraction + weakening + exchange 푥:휏@1⊢푥:휏 (푣푎푟) Γ,푥:휏1,푦:휏1@푅×푟,푠⊢푒∶휏2Γ,푧:휏1@푅×푟+푠⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) Γ,푥:휏1@푅×푠⊢푒:휏2Γ@푅⊢휆푥.푒∶휏1→푠 휏2(푎푏푠)
Coeffect calculus with historical values 
Γ,푥:휏1,푦:휏1@푅×푟,푠⊢푒∶휏2Γ,푧:휏1@푅×max(푟,푠)⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) 
푦:int@1⊢휆푥→푥+prev푥+푦∶푖푛푡→1 푖푛푡
Environment related
Coeffect calculus for implicit parameters 
Tracking implicit parameters 
Non-determinism can be fixed by annotation 
@{?zone}⊢휆()→?time+?zone∶푢푛푖푡 {?zone} 푡푖푚푒 
time} @{?time,?zone}⊢휆()→?time+?zone∶푢푛푖푡→∅ 푡푖푚푒
Coeffect calculus for implicit parameters 
Tracking implicit parameters 
Annotation does not mirror context structure 
Not the same as reader monadΓ,푥:휏1@푟∪푠⊢푒:휏2Γ@푟⊢휆푥.푒∶휏1→푠 휏2
What is in the paper?
Unified system 
Coeffect scalar structure (⊗,⊕,use,ign,≤) 
Generalized semiringstructure 
Individual variable or function annotations 
Shape-indexed coeffect(⨲,,⊥) 
Context splittingand merging 
Per-variable or whole-context 
⨲
Semantics using indexed comonads 
Monadic semanticsComonadic semantics 
It is not as simple 
휆-calculus is asymmetric (many to one) 
per-variable orwhole-context? Γ@푹⊢푒:휏:푪푹Γ→휏Γ⊢푒:휏&흈:Γ→푴흈휏
Why coeffects matter? 
generalize interesting systems 
liveness, data-flow, implicit parameters, type classes 
comonadsare cool 
model both per-variable and whole-context 
indexed 
{tomas.petricek, dominic.orchard, alan.mycroft}@cl.cam.ac.uk @tomaspetricek|@dorchard| #coeffects
EOF
Coeffect type system 푥:휏@use⊢푥:휏 (푣푎푟) Γ1@푅⊢푒1∶휏1→푡 휏2Γ2@푆⊢푒2∶휏1Γ1,Γ2@푅⨲푡⊗푆⊢푒1푒2:휏2(푎푝푝) Γ,푥:휏1@푅푠⊢푒:휏2Γ@푅⊢휆푥.푒∶휏1→푠 휏2(푎푏푠) 
⨲ Γ,푥:휏1,푦:휏1@푅푟,푠⊢푒∶휏2Γ,푧:휏1@푅⨲푟⊕푠⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) 
⨲
Effectsystems vs. coeffect systems 
More powerful lambda abstraction 
Richer structure 
Sequential ⊗vs. point-wise ⊕composition 
Vectors over variable context Γ,푥:휏1@푟∪푠⊢푒:휏2Γ@푟⊢휆푥.푒∶휏1→푠 휏2Γ,푥:휏1⊢푒:휏2&휎 Γ⊢휆푥.푒∶휏1→휎 휏2&∅
EOF
Why coeffects matter? 
generalize interesting systems 
liveness, data-flow, implicit parameters, type classes 
comonadsare cool 
model both per-variable and whole-context 
indexed 
{tomas.petricek, dominic.orchard, alan.mycroft}@cl.cam.ac.uk @tomaspetricek|@dorchard| #coeffects

More Related Content

What's hot (7)

prie.ppt
prie.pptprie.ppt
prie.ppt
 
Gray-Box Models for Performance Assessment of Spark Applications
Gray-Box Models for Performance Assessment of Spark ApplicationsGray-Box Models for Performance Assessment of Spark Applications
Gray-Box Models for Performance Assessment of Spark Applications
 
ReapAbstractbyDenzelakosa
ReapAbstractbyDenzelakosaReapAbstractbyDenzelakosa
ReapAbstractbyDenzelakosa
 
Starting work with R
Starting work with RStarting work with R
Starting work with R
 
Diversity Filtering
Diversity FilteringDiversity Filtering
Diversity Filtering
 
Potters wheel
Potters wheelPotters wheel
Potters wheel
 
2013 Limacon Memo
2013 Limacon Memo2013 Limacon Memo
2013 Limacon Memo
 

Similar to Coeffects: A Calculus of Context-Dependent Computation

Arnav Major project for graph theory. ppt.pptx
Arnav Major project for graph theory. ppt.pptxArnav Major project for graph theory. ppt.pptx
Arnav Major project for graph theory. ppt.pptx
ssuser7e6271
 
Approaches to online quantile estimation
Approaches to online quantile estimationApproaches to online quantile estimation
Approaches to online quantile estimation
Data Con LA
 
RelationalAlgebra-RelationalCalculus-SQL.pdf
RelationalAlgebra-RelationalCalculus-SQL.pdfRelationalAlgebra-RelationalCalculus-SQL.pdf
RelationalAlgebra-RelationalCalculus-SQL.pdf
10GUPTASOUMYARAMPRAK
 

Similar to Coeffects: A Calculus of Context-Dependent Computation (20)

THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
 
THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
THE LEFT AND RIGHT BLOCK POLE PLACEMENT COMPARISON STUDY: APPLICATION TO FLIG...
 
Advanced Functional Programming in Scala
Advanced Functional Programming in ScalaAdvanced Functional Programming in Scala
Advanced Functional Programming in Scala
 
PyData Miami 2019, Quantum Generalized Linear Models
PyData Miami 2019, Quantum Generalized Linear ModelsPyData Miami 2019, Quantum Generalized Linear Models
PyData Miami 2019, Quantum Generalized Linear Models
 
Investigation of auto-oscilational regimes of the system by dynamic nonlinear...
Investigation of auto-oscilational regimes of the system by dynamic nonlinear...Investigation of auto-oscilational regimes of the system by dynamic nonlinear...
Investigation of auto-oscilational regimes of the system by dynamic nonlinear...
 
Query trees
Query treesQuery trees
Query trees
 
Arnav Major project for graph theory. ppt.pptx
Arnav Major project for graph theory. ppt.pptxArnav Major project for graph theory. ppt.pptx
Arnav Major project for graph theory. ppt.pptx
 
Informatics systems
Informatics systemsInformatics systems
Informatics systems
 
Design Patterns for Efficient Graph Algorithms in MapReduce__HadoopSummit2010
Design Patterns for Efficient Graph Algorithms in MapReduce__HadoopSummit2010Design Patterns for Efficient Graph Algorithms in MapReduce__HadoopSummit2010
Design Patterns for Efficient Graph Algorithms in MapReduce__HadoopSummit2010
 
Approaches to online quantile estimation
Approaches to online quantile estimationApproaches to online quantile estimation
Approaches to online quantile estimation
 
High-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECLHigh-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECL
 
Unit 3
Unit 3Unit 3
Unit 3
 
Toward a Recommendation System for focusing Testing
Toward a Recommendation System for focusing TestingToward a Recommendation System for focusing Testing
Toward a Recommendation System for focusing Testing
 
Jgrass-NewAge: Kriging component
Jgrass-NewAge: Kriging componentJgrass-NewAge: Kriging component
Jgrass-NewAge: Kriging component
 
15.sp.dictionary_draft.pdf
15.sp.dictionary_draft.pdf15.sp.dictionary_draft.pdf
15.sp.dictionary_draft.pdf
 
Economia01
Economia01Economia01
Economia01
 
Economia01
Economia01Economia01
Economia01
 
RelationalAlgebra-RelationalCalculus-SQL.pdf
RelationalAlgebra-RelationalCalculus-SQL.pdfRelationalAlgebra-RelationalCalculus-SQL.pdf
RelationalAlgebra-RelationalCalculus-SQL.pdf
 
Unit1 pg math model
Unit1 pg math modelUnit1 pg math model
Unit1 pg math model
 
Structural Dynamic Reanalysis of Beam Elements Using Regression Method
Structural Dynamic Reanalysis of Beam Elements Using Regression MethodStructural Dynamic Reanalysis of Beam Elements Using Regression Method
Structural Dynamic Reanalysis of Beam Elements Using Regression Method
 

More from Tomas Petricek

Queries in general purpose languages
Queries in general purpose languagesQueries in general purpose languages
Queries in general purpose languages
Tomas Petricek
 

More from Tomas Petricek (19)

Domain Specific Languages: The Functional Way
Domain Specific Languages: The Functional WayDomain Specific Languages: The Functional Way
Domain Specific Languages: The Functional Way
 
F# Data: Making structured data first class citizens
F# Data: Making structured data first class citizensF# Data: Making structured data first class citizens
F# Data: Making structured data first class citizens
 
Doing data science with F# (BuildStuff)
Doing data science with F# (BuildStuff)Doing data science with F# (BuildStuff)
Doing data science with F# (BuildStuff)
 
Doing data science with F#
Doing data science with F#Doing data science with F#
Doing data science with F#
 
F# and Financial Data Making Data Analysis Simple
F# and Financial Data Making Data Analysis SimpleF# and Financial Data Making Data Analysis Simple
F# and Financial Data Making Data Analysis Simple
 
Creating Domain Specific Languages in F#
Creating Domain Specific Languages in F#Creating Domain Specific Languages in F#
Creating Domain Specific Languages in F#
 
How F# Learned to Stop Worrying and Love the Data
How F# Learned to Stop Worrying and Love the DataHow F# Learned to Stop Worrying and Love the Data
How F# Learned to Stop Worrying and Love the Data
 
Information-rich programming in F# (ML Workshop 2012)
Information-rich programming in F# (ML Workshop 2012)Information-rich programming in F# (ML Workshop 2012)
Information-rich programming in F# (ML Workshop 2012)
 
F# Type Providers in Depth
F# Type Providers in DepthF# Type Providers in Depth
F# Type Providers in Depth
 
Asynchronous programming in F# (QCon 2012)
Asynchronous programming in F# (QCon 2012)Asynchronous programming in F# (QCon 2012)
Asynchronous programming in F# (QCon 2012)
 
Queries in general purpose languages
Queries in general purpose languagesQueries in general purpose languages
Queries in general purpose languages
 
Docase notation for Haskell
Docase notation for HaskellDocase notation for Haskell
Docase notation for Haskell
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
 
F# on the Server-Side
F# on the Server-SideF# on the Server-Side
F# on the Server-Side
 
F# Tutorial @ QCon
F# Tutorial @ QConF# Tutorial @ QCon
F# Tutorial @ QCon
 
Teaching F#
Teaching F#Teaching F#
Teaching F#
 
F# in MonoDevelop
F# in MonoDevelopF# in MonoDevelop
F# in MonoDevelop
 
Academia
AcademiaAcademia
Academia
 
Concurrent programming with Agents
Concurrent programming with AgentsConcurrent programming with Agents
Concurrent programming with Agents
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Coeffects: A Calculus of Context-Dependent Computation

  • 1. Coeffects:A calculus of context-dependent computation Tomas Petricek, Dominic Orchard and Alan Mycroft University of Cambridge {name.surname}@cl.cam.ac.uk|@tomaspetricek| @dorchard
  • 3. Properties of computations Effect systems Effects on environment Modeled using monads Coeffect systems Requirements on environment Modeled using comonads Γ⊢푒:휏&흈 Γ@풓⊢푒:휏
  • 4. View from the extreme left Variable related Liveness Bounded linear logic Data-flow programming Provenance Environment related Implicit parameters Type classes Distributed computing Platform versioning
  • 6. Coeffect calculus for bounded reuse Coeffect annotations track number of variable uses vectorof variable annotations + function annotation richer structure than effect systems 푦:int@1⊢휆푥→푦+푥+푥∶푖푛푡→ퟐ 푖푛푡
  • 7. Coeffect calculus for bounded reuse structural rules = contraction + weakening + exchange 푥:휏@1⊢푥:휏 (푣푎푟) Γ,푥:휏1,푦:휏1@푅×푟,푠⊢푒∶휏2Γ,푧:휏1@푅×푟+푠⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) Γ,푥:휏1@푅×푠⊢푒:휏2Γ@푅⊢휆푥.푒∶휏1→푠 휏2(푎푏푠)
  • 8. Coeffect calculus with historical values Γ,푥:휏1,푦:휏1@푅×푟,푠⊢푒∶휏2Γ,푧:휏1@푅×max(푟,푠)⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) 푦:int@1⊢휆푥→푥+prev푥+푦∶푖푛푡→1 푖푛푡
  • 10. Coeffect calculus for implicit parameters Tracking implicit parameters Non-determinism can be fixed by annotation @{?zone}⊢휆()→?time+?zone∶푢푛푖푡 {?zone} 푡푖푚푒 time} @{?time,?zone}⊢휆()→?time+?zone∶푢푛푖푡→∅ 푡푖푚푒
  • 11. Coeffect calculus for implicit parameters Tracking implicit parameters Annotation does not mirror context structure Not the same as reader monadΓ,푥:휏1@푟∪푠⊢푒:휏2Γ@푟⊢휆푥.푒∶휏1→푠 휏2
  • 12. What is in the paper?
  • 13. Unified system Coeffect scalar structure (⊗,⊕,use,ign,≤) Generalized semiringstructure Individual variable or function annotations Shape-indexed coeffect(⨲,,⊥) Context splittingand merging Per-variable or whole-context ⨲
  • 14. Semantics using indexed comonads Monadic semanticsComonadic semantics It is not as simple 휆-calculus is asymmetric (many to one) per-variable orwhole-context? Γ@푹⊢푒:휏:푪푹Γ→휏Γ⊢푒:휏&흈:Γ→푴흈휏
  • 15. Why coeffects matter? generalize interesting systems liveness, data-flow, implicit parameters, type classes comonadsare cool model both per-variable and whole-context indexed {tomas.petricek, dominic.orchard, alan.mycroft}@cl.cam.ac.uk @tomaspetricek|@dorchard| #coeffects
  • 16. EOF
  • 17. Coeffect type system 푥:휏@use⊢푥:휏 (푣푎푟) Γ1@푅⊢푒1∶휏1→푡 휏2Γ2@푆⊢푒2∶휏1Γ1,Γ2@푅⨲푡⊗푆⊢푒1푒2:휏2(푎푝푝) Γ,푥:휏1@푅푠⊢푒:휏2Γ@푅⊢휆푥.푒∶휏1→푠 휏2(푎푏푠) ⨲ Γ,푥:휏1,푦:휏1@푅푟,푠⊢푒∶휏2Γ,푧:휏1@푅⨲푟⊕푠⊢푒푥←푧,푦←푧:휏2(푐표푛푡푟) ⨲
  • 18. Effectsystems vs. coeffect systems More powerful lambda abstraction Richer structure Sequential ⊗vs. point-wise ⊕composition Vectors over variable context Γ,푥:휏1@푟∪푠⊢푒:휏2Γ@푟⊢휆푥.푒∶휏1→푠 휏2Γ,푥:휏1⊢푒:휏2&휎 Γ⊢휆푥.푒∶휏1→휎 휏2&∅
  • 19. EOF
  • 20. Why coeffects matter? generalize interesting systems liveness, data-flow, implicit parameters, type classes comonadsare cool model both per-variable and whole-context indexed {tomas.petricek, dominic.orchard, alan.mycroft}@cl.cam.ac.uk @tomaspetricek|@dorchard| #coeffects