Charles Stanhope

Charles Stanhope at

"Coeffects are Tomas Petricek's PhD research project. They are a programming language abstraction for understanding how programs access the context or environment in which they execute.

The context may be resources on your mobile phone (battery, GPS location or a network printer), IoT devices in a physical neighborhood or historical stock prices. By understanding the neighborhood or history, a context-aware programming language can catch bugs earlier and run more efficiently."

Petricek created a web page with interactive demonstrations of his work. Here's a blog post explaining his approach to the web page. Interesting work with an interesting way of spreading the ideas. I just wish I had more time in the day.

Claes Wallin (韋嘉誠) likes this.

Claes Wallin (韋嘉誠) shared this.

I was wondering if this was actually novel until I got to the part of http://tomasp.net/blog/2014/why-coeffects-matter/ where it says "coeffects correspond to comonads".

I have not yet grokked comonads, but I have seen at least some of what he's using contexts for done with plain old type classes (including monads). For example,

sendResult :: UsesNetwork m => Result -> m Bool

queryDatabase :: Database m => Query -> m Result

answerQuery :: (UsesNetwork m, Database m) => Query -> m Bool
answerQuery q = queryDatabase q >>= sendResult

The type class constraint on sendResult guarantees that, however it's implemented, the only action it can take is network traffic, and the constraint on queryDatabase guarantees that the only action it can take is database access.

joeyh at 2016-04-13T22:43:45Z

Claes Wallin (韋嘉誠), Charles Stanhope likes this.