Latest / Strachey Lectures / Strachey Lecture: Bidirectional Computation is Effectful
Transcript
- 0:00Hello. My name is Jeremy Gibbons,
- 0:02and I'm going to tell you a bit about bi directional computation and why it's effect for why you can think of it as a computational effect.
- 0:10This is a reconstruction of a talk I gave at the Summit on Advances in Programming Languages in May 2015.
- 0:19BI directional transformations do with the problem of keeping two or more bits of data in sync with each other.
- 0:26Think about the so-called View Update problem in databases with a complicated source and a simplified view that
- 0:33you might want to update the round tripping laws if you view and then immediately update with that same view,
- 0:40nothing should change.
- 0:41And conversely, if you update with a new view and then view the current state, you should receive the view you first thought of.
- 0:51Now let's make it symmetric with multiple views, none of which need have the full picture peer to peer rather than master slave.
- 1:00There are many applications. It's a particular concern in model driven development,
- 1:04where a complex system is modelled from multiple complementary perspectives, which all have to be kept consistent.
- 1:13For simplicity. Imagine two views A and B onto a common source, each of which you want to be able to get and to put.
- 1:21There's evidently something stateful going on. Having put an A, you want to get it back again.
- 1:27And similarly for be. That suggests thinking about it in terms of the State Monad.
- 1:34But of course, the A and the B are not independent of each other like two memory cells would be.
- 1:39The whole point of the exercise is that when you update A, it influences B, formerly the put operations on each side.
- 1:47Do not compute with any operation on the other side, they are entangled.
- 1:54But now we've introduced one class of effects state. We might as well consider others too.
- 2:00In Haskell, we would implement not using the State Monad Transformer, which combines the State Monad with another underlying monad of effects.
- 2:09For example, a partial B X could raise a controlled exception if it is unable to restore consistency using the maybe monad.
- 2:17Parameter Rise X could depend on some global configuration settings or other contextual information using the reader monad.
- 2:25This is important enough to determine situations in which there may be multiple sensible ways of restoring consistency.
- 2:32The user may indicate out of band their preference for how to resolve that choice.
- 2:39And on deterministic b x when putting on the left a new a prime that isn't already consistent with
- 2:44the current B could not deterministically select amongst all those V prime consistent with a prime.
- 2:51This can be captured using the set or list monads.
- 2:56An interactive voice might ask the user or another external oracle for help in restoring consistency using the IO Monad.
- 3:04It might also learn keeping track of the questions it asks so as not to ask the same question again.
- 3:10Combining IO with more state. And so on.
- 3:16This work is a means to an end for us and not an end in itself.
- 3:20We are particularly interested in approaches modelling not just that two views are consistent
- 3:26but also how they are so in particular in complex scenarios like model driven development.
- 3:32When the data items are models, which are collections of model elements,
- 3:36developer tools have to keep track of how model elements correspond to each other.
- 3:41They typically maintain some witness structure, for example, a collection of triples in the form.
- 3:46This element is in this relation to that element. That too would be part of the maintained state.
- 3:54Our grand plan and the raison d'etre of the grant that is funding this work is to study the principle of least change.
- 4:02The round tripping laws we saw at the beginning constrains some operation sequences to be know ops
- 4:07but say nothing about the sequences that do have to make changes in order to restore consistency.
- 4:13In these cases, one often expects the least consistency restoring change to be made.
- 4:18This is an outstanding problem in the VCs community. This change seems desirable, but no one really knows precisely what it should mean.
- 4:29So in conclusion, the bi directional transformations are inherently stateful, and in fact that state is a kind of entangled state.
- 4:39Having introduced state as one effect, we might as well consider other effects too.
- 4:44It turns out that the conditions for preserving well behaved this are rather subtle.
- 4:48I haven't had time to show you that here. This is joint work with Faris, Abu Saleh, James Chaney, James macKinnon and Peter Stevens.
- 4:58And we have a paper notions of bi directional computation and entangled state monads.
- 5:04The Mathematics of Program Construction 2015. The work has been supported by the UK FCC grant a series of lease change for the ex.