Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for...

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

Transcript of Hazel: Semantic Foundations for Interactive Programming Tools · Hazel: Semantic Foundations for...

Hazel: Semantic Foundations for Interactive Programming Tools

Cyrus OmarCarnegie Mellon University

IBM PL Day 2016

Q: What do programmers interact with?

2

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

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]

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]

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?

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?

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?

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.

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]

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]

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]

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.

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 : }▢

15

A static semantics for lambda terms with holes

[Omar et al., POPL 2017]

16

A typed edit action semantics

[Omar et al., POPL 2017]

17

Demo

[Omar et al., POPL 2017]

See http://hazelgrove.github.io/

18

From Hazelnut to Hazel

19

From Hazelnut to Hazel

TODO: scale up POPL17

20

From Hazelnut to Hazel

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

21

From Hazelnut to Hazel

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

22

From Hazelnut to Hazel

TODO: an action suggestion semantics

23

From Hazelnut to Hazel

TODO: a statistical model of edit actions

24

From Hazelnut to Hazel

TODO: library-defined derived actions

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/