Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Forked from txus/core-typed-interop.clj
Created April 26, 2015 18:50
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 frenchy64/f2ab85d82000dbd0f96d to your computer and use it in GitHub Desktop.
Save frenchy64/f2ab85d82000dbd0f96d to your computer and use it in GitHub Desktop.
(ns typed.core
(:require [clojure.core.typed :as t]))
(t/ann-datatype Foo [fooName :- t/Str])
(deftype Foo [fooName])
(t/ann-datatype Bar [barName :- t/Str])
(deftype Bar [barName])
(t/ann theName [(t/U Foo Bar) -> t/Str])
(defmulti theName class)
(defmethod theName Foo [^Foo f] (.fooName f))
(defmethod theName Bar [^Bar f] (.barName f))
(t/check-ns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment