resugaring lifting evaluation sequences through syntactic
play

Resugaring: Lifting Evaluation Sequences through Syntactic Sugar - PowerPoint PPT Presentation

Resugaring: Lifting Evaluation Sequences through Syntactic Sugar Justin Pombrio, Shriram Krishnamurthi Brown University Syntactic Sugar 2 Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) 3 Syntactic Sugar desugar x


  1. Resugaring: Lifting Evaluation Sequences through Syntactic Sugar Justin Pombrio, Shriram Krishnamurthi Brown University

  2. Syntactic Sugar 2

  3. Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) 3

  4. Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) desugar [ x * x | x < - l s t ] m a p ( \ x - > x * x ) l s t 4

  5. Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) desugar [ x * x | x < - l s t ] m a p ( \ x - > x * x ) l s t desugar x o r y l e t t = x i n i f t t h e n t e l s e y 5

  6. Surface language (what you write) Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) desugar [ x * x | x < - l s t ] m a p ( \ x - > x * x ) l s t desugar x o r y l e t t = x i n i f t t h e n t e l s e y 6

  7. Surface language Core language (what you write) (what runs) Syntactic Sugar desugar x + 2 x . _ _ a d d _ _ ( 2 ) desugar [ x * x | x < - l s t ] m a p ( \ x - > x * x ) l s t desugar x o r y l e t t = x i n i f t t h e n t e l s e y 7

  8. Big surface language desugar Small core 8

  9. Big surface language desugar Small core 9

  10. Big surface language desugar Code analyzer Small Refactoring engine core Evaluator 10

  11. Big surface language desugar Code analyzer Small Refactoring engine core Evaluator 11

  12. Big surface language desugar Code analyzer Small Refactoring engine core Evaluator Evaluator 12

  13. Surface Core n o t ( t r u e ) o r t r u e 13

  14. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e 14

  15. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f f a l s e t h e n f a l s e e l s e t r u e t r u e 15

  16. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e f a l s e o r t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f f a l s e t h e n f a l s e e l s e t r u e t r u e t r u e 16

  17. Confection core eval seq → surface eval seq 17

  18. 18

  19. 92 steps 19

  20. 92 steps 7 steps 20

  21. Surface Core n o t ( t r u e ) o r t r u e Resugaring: Running sugar in reverse 21

  22. Surface Core n o t ( t r u e ) o r t r u e f a l s e o r t r u e t r u e Resugaring: Running sugar in reverse 22

  23. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e f a l s e o r t r u e t r u e Resugaring: Running sugar in reverse 23

  24. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e f a l s e o r t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f f a l s e t h e n f a l s e e l s e t r u e t r u e t r u e Resugaring: Running sugar in reverse 24

  25. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n resugar i f t t h e n t e l s e t r u e f a l s e o r t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f f a l s e t h e n f a l s e e l s e t r u e t r u e t r u e Resugaring: Running sugar in reverse 25

  26. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n resugar i f t t h e n t e l s e t r u e resugar f a l s e o r t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f f a l s e t h e n f a l s e e l s e t r u e t r u e t r u e Resugaring: Running sugar in reverse 26

  27. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n resugar i f t t h e n t e l s e t r u e resugar f a l s e o r t r u e l e t t = f a l s e i n i f t t h e n t e l s e t r u e resugar i f f a l s e t h e n f a l s e e l s e t r u e t r u e t r u e Resugaring: Running sugar in reverse 27

  28. THREE KEY PROPERTIES OF RESUGARING 28

  29. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar l e t t = f a l s e i n i f t t h e n t e l s e t r u e 29

  30. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar t r u e o r t r u e l e t t = f a l s e i n o r t r u e i f t t h e n t e l s e t r u e 30

  31. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar t r u e o r t r u e l e t t = f a l s e i n o r t r u e i f t t h e n t e l s e t r u e Emulation Each surface term must desugar to the core term it purports to represent 31

  32. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar l e t t = f a l s e i n i f t t h e n t e l s e t r u e 32

  33. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar l e t t = f a l s e i n l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f t t h e n t e l s e t r u e 33

  34. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar l e t t = f a l s e i n l e t t = f a l s e i n i f t t h e n t e l s e t r u e i f t t h e n t e l s e t r u e Abstraction Show things in terms of a sugar precisely when the programmer used that sugar. 34

  35. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar l e t t = f a l s e i n i f t t h e n t e l s e t r u e resugar i f f a l s e t h e n f a l s e e l s e t r u e resugar t r u e t r u e 35

  36. Surface Core desugar n o t ( t r u e ) o r t r u e l e t t = n o t ( t r u e ) i n i f t t h e n t e l s e t r u e resugar Coverage l e t t = f a l s e i n i f t t h e n t e l s e t r u e Show as many steps resugar as possible i f f a l s e t h e n f a l s e e l s e t r u e resugar t r u e t r u e 36

  37. x o r y - > l e t t = x i n i f t t h e n t e l s e y 37

  38. expand match substitute x o r y - > l e t t = x i n i f t t h e n t e l s e y 38

  39. expand match substitute x o r y - > l e t t = x i n i f t t h e n t e l s e y substitute match unexpand 39

  40. A Little Theory expand : Surf Term → Core Term unexpand : Core Term × Surf Term → Surf Term 40

  41. A Little Theory expand : Surf Term → Core Term unexpand : Core Term × Surf Term → Surf Term It's a lens! 41

  42. A Little Theory expand : Surf Term → Core Term unexpand : Core Term × Surf Term → Surf Term It's a lens! unexpand (expand T) T = T GetPut GetPut expand (unexpand T’ T) = T’ PutGet PutGet 42

  43. A Little Theory expand : Surf Term → Core Term unexpand : Core Term × Surf Term → Surf Term It's a lens! unexpand (expand T) T = T GetPut GetPut expand (unexpand T’ T) = T’ PutGet PutGet Well-formedness criteria on rules ensure these laws. 43

  44. Key Properties Emulation Abstraction Coverage 44

  45. Key Properties Emulation (Lens Laws) Abstraction Coverage 45

  46. Key Properties Emulation (Lens Laws) Abstraction (T agging – see paper) Coverage 46

  47. Key Properties Emulation (Lens Laws) Abstraction (T agging – see paper) Coverage (Empirical) 47

  48. A WORKING SYSTEM 48

  49. 92 steps 7 steps 49

  50. Surface Core ( o r ( a n d # t # f ) # f ) 50

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend