Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Last active December 13, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonbloom/4982699 to your computer and use it in GitHub Desktop.
Save brandonbloom/4982699 to your computer and use it in GitHub Desktop.
(defn infer-tag [e]
(if-let [tag (get-tag e)]
tag
(case (:op e)
:do (infer-tag (:ret e))
:let (infer-tag (:expr e))
:letfn (infer-tag (:expr e))
:if (let [then-tag (infer-tag (:then e))
else-tag (infer-tag (:else e))]
(when (= then-tag else-tag)
then-tag))
:constant (case (:form e)
true 'boolean
false 'boolean
nil)
nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment