jstolarek / slicer

Companion code for paper "Imperative Functional Programs that Explain their Work", Wilmer Ricciotti, Jan Stolarek, Roly Perera and James Cheney, ICFP 2017, Oxford, UK
http://dl.acm.org/citation.cfm?id=3110258
GNU General Public License v3.0
6 stars 0 forks source link

Implement resugaring #20

Closed jstolarek closed 7 years ago

jstolarek commented 7 years ago

I've rewritten the Resugar module - please review whether this is what we wanted. The most important changes are obviously in that module. The rest is fallout, except for three minor refactorings.

Fixes #10

rolyp commented 7 years ago

Ok, this looks good to me and should be a good foundation for (eventually) switching to the other approach. (The "other" approach being resugaring with respect the original sugared program.) Thanks for doing this!

For future reference, here's a note on the other approach. Our current round-tripping strategy imposes various ad hoc restrictions on the source language (e.g. "raw" anonymous sums of products won't round-trip properly; you have to use data types) and also relies on some ad hoc annotations (e.g. type names to recover data types). These go away if you resugar with respect to the original program, relying on the fact that desugaring is deterministic. (Essentially you run the desugaring and resugaring simultaneously.)

This is feasible in our setting because we're only interested in resugaring slices of programs that we desugared. De/re-sugaring in this situation is a special case of bidirectional computation where the only changes allowed to the "view" (the desugared program) are to erase parts of it. In that restricted setting, the bidirectional computation problem is easy and we need not concern ourselves with the more open-ended problem of generating a "canonical" sugared version of an arbitrary program in the desugared language.

So, we'll be able to round-trip precisely even without ad hoc restrictions on the source language: e.g. we'll be able to allow the user to freely mix data types and anonymous types, or nested lambdas and "multi-argument" functions, and have the round-trip preserve their syntactic choices.

On 7 February 2017 at 19:44, Jan Stolarek notifications@github.com wrote:

I've rewritten the Resugar module - please review whether this is what we wanted. The most important changes are obviously in that module. The rest is fallout, except for three minor refactorings.

Fixes #10 https://github.com/jstolarek/slicer/issues/10

You can view, comment on, or merge this pull request online at:

https://github.com/jstolarek/slicer/pull/20 Commit Summary

  • Reimplement resugaring
  • Refactor TcDecl
  • Remove redundant Maybes
  • Rename name field to dataName

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jstolarek/slicer/pull/20, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHY8uJm9wcC9R5LVU_3AVPl8rkuaOBfks5raMmzgaJpZM4L58fe .

jamescheney commented 7 years ago

Sorry I did not have time to respond earlier. I did look over the code and am happy with it (though can't claim to have looked over everything carefully). I've also deleted the branch.