Created
September 22, 2014 21:44
-
-
Save Janiczek/20a2670091e49fb66792 to your computer and use it in GitHub Desktop.
core.typed aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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