Tomas Petricek's blog

Writing about practical F# coding and programming language research

Coeffects playground: Interactive essay based on my PhD thesis

In my PhD thesis, I worked on integrating contextual information into a type system of functional programming languages. For example, say your mobile application accesses something from the environment such as GPS sensor or your Facebook friends. With coeffects, this could be a part of the type. Rather than having type string -> Person, the type of a function would also include resources and would be string -{ gps, fb }-> Person. I wrote longer introduction to coeffects on this blog before.

As one might expect, the PhD thesis is more theoretical and it looks at other kinds of contextual information (e.g. past values in stream-based data-flow programming) and it identifies abstract coeffect algebra that captures the essence of contextual information that can be nicely tracked in a functional language.

I always thought that the most interesting thing about the thesis is that it gives people a nice way to think about context in a unified way. Sadly, the very theoretical presentation in the thesis makes this quite hard for those who are not doing programming language theory.

To make it a bit easier to explore the ideas behind coeffects, I wrote a coeffect playground that runs in a web browser and lets you learn about coeffects, play with two example context-aware languages, run a couple of demos and learn more about how the theory works. Go check it out now or continue below to learn more about some interesting internals!

Published: Tuesday, 12 April 2016, 3:33 PM
Tags: coeffects, research, functional programming, programming languages
Read the complete article

Recent articles from my blog

Happy New Year 2016 around the World

Wednesday, 30 December 2015, 6:09 PM

This year, my #FsAdvent contribution ended up on December 31.To celebrate the beginning of the New Year 2016, I built an interactive web application that visualizes 'Happy New Year' tweets across the globe. It uses a range of interesting F# libraries including F# Data Toolbox for calling Twitter, web server and F# agents.

Philosophy of science books every computer scientist should read

Thursday, 10 December 2015, 12:42 PM

When I tell my fellow computer scientists or software developers that I'm interested in philosophy of science, they first look a bit confused, then we have a really interesting discussion about it and then they ask me for some interesting books they could read about it. So, I thought I should turn my answer into a blog post!

F# + ML |> MVP Summit Talks

Wednesday, 18 November 2015, 2:03 AM

I was fortunate enough to make it to the Microsoft MVP summit this year. I didn't learn anything secret (and even if I did, I wouldn't tell you!) but one thing Idid learn is that there is a lot of interest in data science and machine learning. What was less expected and more exciting was that there was also a lot of interest in F#!

The Gamma: Simple code behind interactive articles

Monday, 28 September 2015, 5:07 PM

Computer programming may not be the new literacy, but it is finding its way intomany areas of modern society. In particular, data journalism turns traditional news reports from a mix of text and images into something that is much closer to a computer program.By treating articles as programs, we can make data journalism more transparent, reproducible and interactive. This is what I've been working on recently, so check out the prototype!

Find older blog articles here


I'm an open-source developer and computer scientist who enjoys combining theory and practice. On the practical side, I write about F#, run trainings and provide consulting via fsharpWorks. On the theory side, I work on various programming language topics.

Trainings and consulting

I'm a frequent speaker at F# and .NET events, founding member of the F# Foundation author of C# and F# book and a StackOverflow fanatic. I have been Microsoft C# MVP since 2004 and used F# since early Microsoft Research versions.

Have you seen the F# testimonials and are you thinking how your company can also benefit from the safety, correctness, efficiency and faster time-to-market provided by F#?

Research & teaching

I'm interested in a wide range of topics in programming languages, ranging from category theory, comonads, reactive and distributed programming to scientific computing and working with data.

I like working on topics inspired by practical problems. I created a web framework for F# that inspired commercial projects like WebSharper and my experimental F# extensions can be tested live on

When the time permits, I enjoy traveling. The calendar shows a new picture each month. See 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 and the first photos of 2016.