This can be done using arrows. What I want is something that looks closed, but can be opened up again. I've been here before. Then I used existential types. Having an open representation doesn't seem to be necessary as long as state traces are made available. So maybe the first thing to do is to compile to traces?