Skip to content

Instantly share code, notes, and snippets.

@Janiczek
Created September 22, 2014 21:44
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 Janiczek/20a2670091e49fb66792 to your computer and use it in GitHub Desktop.
Save Janiczek/20a2670091e49fb66792 to your computer and use it in GitHub Desktop.
core.typed aliases
(ns untitled.core
(:require [clojure.core.typed :as t]))
(t/defalias Length t/Num)
(t/defalias Count t/Num)
(t/defn add-lengths
[a :- Length
b :- Length]
:- Length
(+ a b))
(t/def a-length :- Length 1)
(t/def a-count :- Count 2)
(add-lengths a-length a-length) ;; 2
(add-lengths a-length a-count) ;; 3 but should throw an error
(t/check-ns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment