Created
February 18, 2015 15:26
-
-
Save bendisposto/3a4698e46366637906fa to your computer and use it in GitHub Desktop.
vl_5_2_2015 Teil2: Type Checking
This file contains hidden or 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 type.core | |
| (:require [clojure.core.typed :as t])) | |
| (defn anzahl [c] | |
| (if-not (seq c) | |
| 0 | |
| (inc (anzahl (rest c))))) | |
| (t/ann anzahl [(t/Seqable t/Any) -> t/Int]) | |
| (defn x [] (anzahl [0 0 0])) | |
| (defn y [] (anzahl 3)) | |
| (defn seq' [c] | |
| (if (or (nil? c) (= c [])) | |
| false | |
| c)) | |
| (t/ann seq' [(t/Seqable t/Any) -> t/Bool]) | |
| (t/ann seq' [(t/Seqable t/Any) -> (t/U t/Bool (t/Seqable t/Any))]) | |
| (comment | |
| (t/check-ns 'type.core) | |
| ;; Warum verwende ich (noch) kein typed clojure? | |
| (t/cf (partial + 5)) | |
| (t/cf map) | |
| (t/cf first) | |
| (t/cf cons) | |
| (instance? (type t/NonEmptySeq) t/ASeq) | |
| (t/cf conj) | |
| ) |
This file contains hidden or 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
| (defproject type "0.1.0-SNAPSHOT" | |
| :description "FIXME: write description" | |
| :url "http://example.com/FIXME" | |
| :license {:name "Eclipse Public License" | |
| :url "http://www.eclipse.org/legal/epl-v10.html"} | |
| :dependencies [[org.clojure/clojure "1.6.0"] | |
| [org.clojure/core.typed "0.2.77"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment