Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns cljs.core.typed
"Macros for Clojurescript type checking"
(:refer-clojure :exclude [type defprotocol #_letfn fn loop dotimes let for doseq
#_def #_filter #_remove])
(:require [clojure.core.typed :as t]
[clojure.core.typed.current-impl :as impl :refer [v]]
[clojure.core.typed.util-cljs :as u]
[cljs.analyzer :as ana]
[cljs.compiler :as comp]
[cljs.core :as core]
[cljs.env :as env]
[clojure.pprint :as pprint]))
; many of these macros resolve to CLJS functions in
; the CLJS ns cljs.core.typed
(defmacro ann-form [form ty] form)
(defmacro ann [varsym typesyn] varsym)
(defmacro defalias [& args] nil)
(defn bindings--strip-types [lst]
(apply vector
(map second
(filter (core/fn [[a b]]
(and (not= a :-)
(not= b :-)))
(map vector (cons nil lst) lst)))))
(defmacro def [v tag typ & rst]
(concat ['def v]
rst))
(defmacro defn> [nm tag typ bindings & rst]
(concat ['defn nm (bindings--strip-types bindings)]
rst))
(defmacro doseq [bindings & rst]
(concat ['cljs.core/doseq]
[(bindings--strip-types bindings)]
rst))
(defmacro for [bindings & rst]
(concat ['cljs.core/for]
[(bindings--strip-types bindings)]
rst))
(defmacro let [bindings & rst]
(concat ['cljs.core/let]
[(bindings--strip-types bindings)]
rst))
(defmacro fn [bindings tag type & rst]
(concat ['cljs.core/fn]
[(bindings--strip-types bindings)]
rst))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment