Uploaded image for project: 'core.typed'
  1. CTYP-294

Infer untyped vars via unsafe Dyn-like type

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: 0.3.29
    • Components: None
    • Labels:
      None

      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

        Attachments

          Activity

            People

            • Assignee:
              ambrosebs Ambrose BS
              Reporter:
              ambrosebs Ambrose BS
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: