Top Banner
Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016
25

Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Nov 27, 2018

Download

Documents

lethuy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Hazel: Semantic Foundations for Interactive Programming Tools

Cyrus OmarCarnegie Mellon University

IBM PL Day 2016

Page 2: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Q: What do programmers interact with?

2

Page 3: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Q: What do programmers interact with?

3

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, median =

syntactically malformed program text

Page 4: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Syntactic error recovery heuristics

4

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ),▢ median = ▢ }

syntactically malformed program text term with holes→

[Kats et al., OOPSLA 2009]

Page 5: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

Syntactic structure editors

5

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

syntactically malformed program text → term with holes

[Teitelbaum and Reps, Comm. ACM 1981; many others]

Page 6: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

6

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

Page 7: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

7

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

Page 8: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

8

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

What type is synthesized for the function as a whole?

Page 9: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

9

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

What type is synthesized for the function as a whole?

A: A static semantics for terms with holes.

Page 10: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

10

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

What type is synthesized for the function as a whole?

A: A static semantics for terms with holes.

[Omar et al., POPL 2017]

Page 11: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

11

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

What type is synthesized for the function as a whole?

A: A static semantics for terms with holes.

matrix<float> → { mean : vec<float>, std : vec<float>, median : }▢

[Omar et al., POPL 2017]

Page 12: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

12

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, ), ▢ median = ▢ }

Q: How to reason statically about terms with holes?

What type of expression is expected here?

What type is synthesized for the function as a whole?

A: A static semantics for terms with holes.

matrix<float> → { mean : vec<float>, std : vec<float>, median : }▢

(RowWise + ColumnWise)

[Omar et al., POPL 2017]

Page 13: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

13

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, “oops”), median = ▢ }

Q: How to reason statically about terms with type errors?

What type is synthesized for the function as a whole?

[Omar et al., POPL 2017]

A: A static semantics for terms with holes.

Page 14: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

14

fun summary_stats(m : matrix<float>) = { mean = stats.mean(m, ColumnWise), std = stats.std(m, “oops”), median = ▢ }

Q: How to reason statically about terms with type errors?

What type is synthesized for the function as a whole?

[Omar et al., POPL 2017]

A: A static semantics for terms with holes.

matrix<float> → { mean : vec<float>, std : vec<float>, median : }▢

Page 15: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

15

A static semantics for lambda terms with holes

[Omar et al., POPL 2017]

Page 16: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

16

A typed edit action semantics

[Omar et al., POPL 2017]

Page 17: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

17

Demo

[Omar et al., POPL 2017]

See http://hazelgrove.github.io/

Page 18: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

18

From Hazelnut to Hazel

Page 19: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

19

From Hazelnut to Hazel

TODO: scale up POPL17

Page 20: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

20

From Hazelnut to Hazel

TODO: type-specific projections(based on my work at ICSE 2012, ECOOP 2014)

Page 21: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

21

From Hazelnut to Hazel

TODO: a dynamic semantics for incompleteprograms (very live programming)

Page 22: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

22

From Hazelnut to Hazel

TODO: an action suggestion semantics

Page 23: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

23

From Hazelnut to Hazel

TODO: a statistical model of edit actions

Page 24: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

24

From Hazelnut to Hazel

TODO: library-defined derived actions

Page 25: Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for Interactive Programming Tools Cyrus Omar Carnegie Mellon University IBM PL Day 2016

25

From Hazelnut to Hazel

Joint work with Ian Voysey (CMU), Matt Hammer (CU Boulder), Michael Hilton (Oregon State), Claire Le Goues (CMU), Jonathan Aldrich (CMU), Josh Sunshine (CMU). Interested? Contact me! http://hazelgrove.github.io/