Infer untyped vars via unsafe Dyn-like type

Description

Problem

Writing untyped annotations sucks, and can be especially daunting if you're just starting to port a namespace to typed.

Wouldn't it be great if core.typed provided best-guess annotations that could be copy-pasted into your file?

Solution

Add per-namespace flag to import unannotated vars as a new "Unchecked" type.

Unchecked is both Top and Bottom.

It sticks in an intersection: ie. (I Unchecked Int) does not simplify to Int.

Then `clojure.core/infer-untyped-vars` returns a vector of code you can paste into your buffer (in the same namespace that you flagged) that annotates the unannotated variables. The Unchecked types record how they are used, and the generated annotations reflect this.

Notes

This paper has a very similar Unknown type that replaces Dynamic, but also does complicated escape analysis to ensure Unknown doesn't flow out into dangerous territory.

The Ins and Outs of Gradual Type Inference, POPL '12 https://www.cs.umd.edu/~avik/papers/iogti.pdf

Pull request: https://github.com/typedclojure/core.typed/pull/81

Environment

None

Activity

Show:
Ambrose Bonnaire-Sergeant
January 8, 2017, 1:09 AM
Completed

Assignee

Ambrose Bonnaire-Sergeant

Reporter

Ambrose Bonnaire-Sergeant

Labels

None

Approval

None

Patch

None

Fix versions

Priority

Minor