core.typed

A var of containing a function should be a subtype of the function

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Vars implement IFn by delegating to the function they contain. Thus a var is a valid value anywhere its contained function is valid.

Currently core.typed does not allow treating vars as functions:

(t/cf + [Number * -> Number])
;= (Fn [Number * -> Number])

(t/cf #'+ [Number * -> Number])
; Type Error (user:1:1) Expected type: (Fn [Number * -> Number])
; Actual: Var
; in: (var clojure.core/+)
;
;
; Type Error (user:1:1) Expected type: (Fn [Number * -> Number])
; Actual: Var
; in: (var clojure.core/+)
;
;
; ExceptionInfo Type Checker: Found 2 errors  clojure.core/ex-info (core.clj:4327)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: