New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infer types #2

wants to merge 1 commit into
Jump to file or symbol
Failed to load files and symbols.
+49 −4
Diff settings


Just for now

@@ -8,6 +8,49 @@
[clojure.spec :as s]
[clojure.spec.test :as stest]))
;; Start: Generated by clojure.core.typed - DO NOT EDIT
(declare E NameTypeMap P T)
'{:E ':app, :args (Vec E), :fun E}
'{:E ':false}
'{:E ':if, :else E, :test E, :then E}
'{:E ':lambda, :arg Sym, :arg-type T, :body E}
'{:E ':var, :name Sym}))
(defalias NameTypeMap '{:name Sym, :type T})
'{:P ':=, :exps (Set E)}
'{:P ':and, :ps (Set P)}
'{:P ':is, :exp E, :type T}
'{:P ':not, :p P}
'{:P ':or, :ps (Set P)}))
'{:T ':false}
'{:T ':fun, :params '[NameTypeMap], :return T}
'{:T ':intersection, :types (Set T)}
'{:T ':num}))
(ann check [(Set t/Nothing) E :-> T])
(ann id [(t/Map t/Any t/Any) :-> (t/Map t/Any t/Any)])
(ann id-test AnyFunction)
(ann parse-exp [t/Any :-> E])
(ann parse-exp-test AnyFunction)
(ann parse-prop [(t/Coll t/Any) :-> P])
(ann parse-prop-test AnyFunction)
(ann parse-roundtrip [(t/Coll t/Any) :-> Boolean])
(ann parse-type [t/Any :-> T])
(ann parse-types-test AnyFunction)
(ann tc [(Vec t/Nothing) false :-> false])
(ann tc-test AnyFunction)
(ann unparse-exp [E :-> t/Any])
(ann unparse-prop [P :-> (t/Coll t/Any)])
(ann unparse-prop-test AnyFunction)
(ann unparse-type [T :-> (U Sym false)])
;; End: Generated by clojure.core.typed - DO NOT EDIT
;; e ::= x | (if e e e) | (lambda (x :- t) e) | (e e*) | #f | n? | add1
;; t ::= [x : t -> t] | (not t) | (or t t) | (and t t) | #f | N | Any
;; p ::= (is e t) | (not p) | (or p p) | (and p p) | (= e e)
@@ -143,9 +186,11 @@
(defn parse-type [t]
(vector? t) (let [[args [_ ret]] (split-at (- (count t) 2) t)
args (map (fn [[x _ t]]
{:name x
:type (parse-type t)})
args (map (t/ann-form
(fn [[x _ t]]
{:name x
:type (parse-type t)})
[(t/Coll (U Sym ':-)) :-> NameTypeMap])
(partition 3 args))]
(assert (#{'->} (get t (- (count t) 2)))
(get t (- (count t) 2)))
@@ -526,4 +571,4 @@ str/upper-case
(atom {x 1
y 2})