Closed jstolarek closed 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
- M src/Language/Slicer/Absyn.hs https://github.com/jstolarek/slicer/pull/20/files#diff-0 (28)
- M src/Language/Slicer/Core.hs https://github.com/jstolarek/slicer/pull/20/files#diff-1 (202)
- M src/Language/Slicer/Desugar.hs https://github.com/jstolarek/slicer/pull/20/files#diff-2 (28)
- M src/Language/Slicer/Env.hs https://github.com/jstolarek/slicer/pull/20/files#diff-3 (44)
- M src/Language/Slicer/Error.hs https://github.com/jstolarek/slicer/pull/20/files#diff-4 (7)
- M src/Language/Slicer/Eval.hs https://github.com/jstolarek/slicer/pull/20/files#diff-5 (8)
- M src/Language/Slicer/Main.hs https://github.com/jstolarek/slicer/pull/20/files#diff-6 (11)
- M src/Language/Slicer/Monad/Desugar.hs https://github.com/jstolarek/slicer/pull/20/files#diff-7 (8)
- M src/Language/Slicer/Monad/Eval.hs https://github.com/jstolarek/slicer/pull/20/files#diff-8 (7)
- M src/Language/Slicer/Parser.hs https://github.com/jstolarek/slicer/pull/20/files#diff-9 (9)
- M src/Language/Slicer/Primitives.hs https://github.com/jstolarek/slicer/pull/20/files#diff-10 (22)
- M src/Language/Slicer/Repl.hs https://github.com/jstolarek/slicer/pull/20/files#diff-11 (9)
- M src/Language/Slicer/Resugar.hs https://github.com/jstolarek/slicer/pull/20/files#diff-12 (580)
- M src/Language/Slicer/Slice.hs https://github.com/jstolarek/slicer/pull/20/files#diff-13 (16)
- M src/Language/Slicer/Visualize.hs https://github.com/jstolarek/slicer/pull/20/files#diff-14 (16)
- M tests/golden-templates/mergesort.golden https://github.com/jstolarek/slicer/pull/20/files#diff-15 (7)
- M tests/golden-templates/reverse-eval.golden https://github.com/jstolarek/slicer/pull/20/files#diff-16 (202)
- M tests/golden-templates/reverse-slice-profile.golden https://github.com/jstolarek/slicer/pull/20/files#diff-17 (202)
- M tests/golden-templates/reverse-slice-profile2.golden https://github.com/jstolarek/slicer/pull/20/files#diff-18 (202)
- M tests/golden-templates/reverse-slice.golden https://github.com/jstolarek/slicer/pull/20/files#diff-19 (202)
- M tests/golden-templates/reverse-trace-profile.golden https://github.com/jstolarek/slicer/pull/20/files#diff-20 (202)
- M tests/golden-templates/reverse-trace-profile2.golden https://github.com/jstolarek/slicer/pull/20/files#diff-21 (202)
- M tests/golden-templates/reverse-trace.golden https://github.com/jstolarek/slicer/pull/20/files#diff-22 (202)
- M tests/golden-templates/reverse.golden https://github.com/jstolarek/slicer/pull/20/files#diff-23 (2)
- M tests/golden-templates/sort-bug-2.golden https://github.com/jstolarek/slicer/pull/20/files#diff-24 (7)
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 .
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.
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