complete monitors for gradual types
play

COMPLETE MONITORS FOR GRADUAL TYPES Ben Greenman Matthias - PowerPoint PPT Presentation

Ben Greenman Matthias Felleisen Christos Dimoulas at at at COMPLETE MONITORS FOR GRADUAL TYPES Ben Greenman Matthias Felleisen Christos Dimoulas at at at COMPLETE MONITORS FOR GRADUAL TYPES a careful analysis of the mixed-typed


  1. Ben Greenman Matthias Felleisen Christos Dimoulas at at at COMPLETE MONITORS FOR GRADUAL TYPES

  2. Ben Greenman Matthias Felleisen Christos Dimoulas at at at COMPLETE MONITORS FOR GRADUAL TYPES a careful analysis of the mixed-typed design space

  3. Type soundness is not enough Complete monitoring is crucial for meaningful gradual types "Incomplete" monitoring provides a way to measure the quality of blame errors *from ESOP 2012 *

  4. Mixed-Typed Language

  5. Untyped/Typed mix Mixed-Typed Language = untyped code = simply-typed (no 'Dynamic' type) code U U U T T T U

  6. A Few Motivations U U T T U

  7. Prototyping A Few Motivations U U T T U

  8. Prototyping A Few Motivations write untyped code, rely on types U U T T U

  9. Prototyping A Few Motivations write untyped code, rely on types Re-Use U U T T U

  10. Prototyping A Few Motivations write untyped code, rely on types Re-Use write typed code, use old libraries U U T T U

  11. Many Implementations ... Python TypeScript JavaScript + Hack PHP + Mypy + JavaScript Reticulated Python + Typed Racket Racket + Flow +

  12. Many Implementations ... JavaScript ... diffcult to compare + TypeScript JavaScript + Hack PHP + Mypy Python + Reticulated Python + Typed Racket Racket + Flow UTU U T

  13. Many Models, too GTLC AGT λH λ* → UTU U T

  14. Goal: Characterize the Landscape

  15. Non-Goal : Restrict Landscape

  16. Warmup: Optional Typing / Erasure

  17. Example: Optional Typing T function f (x : [N,N]) { ... fst x ... }

  18. Example: Optional Typing T U function f (x : [N,N]) { f(9) ... fst x ... }

  19. Example: Optional Typing T U function f (x : [N,N]) { f(9) ... fst x ... } Error: 9 is not a pair

  20. types are meaningless at run-time Example: Optional Typing cannot help debug a faulty program T U function f (x : [N,N]) { f(9) ... fst x ... } Error: 9 is not a pair

  21. = Does Not Preserve Types Uni sound

  22. = Does Not Preserve Types Uni sound "type" sound

  23. ICFP '18

  24. ICFP '18 : Three Semantics, Soundnesses

  25. ICFP '18 : Three Semantics, Soundnesses Erasure semantics - types predict nothing

  26. ICFP '18 : Three Semantics, Soundnesses Erasure semantics - types predict nothing Transient semantics - types predict the top-level shape of values - enforced by tag checks

  27. ICFP '18 : Three Semantics, Soundnesses Erasure semantics - types predict nothing Transient semantics - types predict the top-level shape of values - enforced by tag checks Natural semantics - types predict the full behavior of values - enforced by higher-order wrappers

  28. ICFP '18 : Three Semantics, Soundnesses T sound - types predict the full behavior of values Natural semantics - enforced by tag checks - types predict the top-level shape of values Transient semantics - types predict nothing Erasure semantics - enforced by higher-order wrappers Erasure semantics Uni sound - enforced by higher-order wrappers - types predict the full behavior of values Natural semantics - enforced by tag checks - types predict the top-level shape of values Transient semantics - types predict nothing ⌊ T ⌋ sound

  29. ICFP '18: A Spectrum of Type Soundness Uni sound

  30. ICFP '18: A Spectrum of Type Soundness Uni sound Uni sound T sound Erasure Natural Transient ⌊ T ⌋ sound

  31. Natural T sound Transient ⌊ T ⌋ sound

  32. - enforced by higher-order wrappers T sound - types predict the full behavior of values Natural semantics - enforced by tag checks - types predict the top-level shape of values Transient semantics T sound - enforced by higher-order wrappers - types predict the full behavior of values Natural semantics - enforced by tag checks - types predict the top-level shape of values Transient semantics Transient Natural ⌊ T ⌋ sound ⌊ T ⌋ sound

  33. Natural T sound Transient ⌊ T ⌋ sound

  34. T sound Natural Transient Amnesic Amnesic semantics with higher-order wrappers - same behavior as Transient - same type soundness as Natural OOPSLA '19 Greenberg POPL '15 Castagna, Lanvin ICFP '17 ⌊ T ⌋ sound - enforce tag checks ⌊ T ⌋

  35. Type Soundness is NOT ENOUGH Uni sound T sound ??? Erasure Natural Transient Amnesic ⌊ T ⌋ sound

  36. Example: Transient/Amnesic vs. Natural

  37. Example: Transient/Amnesic vs. Natural Prototyping

  38. Example: Transient/Amnesic vs. Natural Prototyping Library Re-Use

  39. Example: Transient/Amnesic vs. Natural Prototyping Library Re-Use Combine: untyped script + typed API + untyped library via a higher-order value

  40. Example: Transient/Amnesic vs. Natural 1. plot data 2. listen for a click 3. draw an image Clickable Plot 1

  41. Example: Transient/Amnesic vs. Natural 1. plot data 2. listen for a click 3. draw an image Clickable Plot 2

  42. Example: Transient/Amnesic vs. Natural 1. plot data 2. listen for a click 3. draw an image Clickable Plot 3

  43. Example: interactive plot Client Library API U T U

  44. Example: interactive plot Client API Library U T U function h(x) { if (0 < fst x): pumpkin else : fish } p = ClickPlot(h) p.show() // click

  45. Example: interactive plot Client API Library U T U function h(x) { class ClickPlot { if (0 < fst x): constructor ( pumpkin onClick){...} else : fish mouseHandler(evt){ } i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show(){...} // click }

  46. Example: interactive plot Library Client API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  47. Example: interactive plot Library Client API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  48. Example: interactive plot Library Client API Promises a pair of numbers U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  49. Example: interactive plot Library Client API Promises a pair of numbers U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  50. Example: interactive plot Library Promises a pair of numbers Client API Expects a pair of numbers U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  51. Example: interactive plot Library Client API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  52. Example: interactive plot Library Client API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  53. Example: interactive plot Client Library API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i Sends MouseEvt value p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

  54. Example: interactive plot Client Library API U T U function h(x) { type ClickPlot { class ClickPlot { if (0 < fst x): constructor ( constructor ( pumpkin ([N,N]) => Image) onClick){...} else : [N,N] != MouseEvt fish mouseHandler : mouseHandler(evt){ } (MouseEvt) => Void i = onClick(evt) // draw i Sends MouseEvt value p = ClickPlot(h) } p.show() show : () => Void show(){...} // click } }

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