Skip to content

Instantly share code, notes, and snippets.

@matstani
Last active October 24, 2017 02:42
Show Gist options
  • Save matstani/6420121 to your computer and use it in GitHub Desktop.
Save matstani/6420121 to your computer and use it in GitHub Desktop.
try core.typed
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
; String型の引数をとりnilを返す
(ann foo [String -> nil])
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann foo [String -> nil])
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
(ann call-foo [-> nil])
(defn call-foo []
; 型情報[String -> nil]と異なる呼出し
(foo 1.5))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann inc-str [String -> AnyInteger])
(defn inc-str
[s]
;incにStringが渡される
(inc s))
(ns try-typed.core
(:require [clojure.core.typed :refer :all]))
(ann inc-str [String -> AnyInteger])
(defn inc-str
[s]
;StringをIntegerに変換
(let [i (Integer/parseInt s)]
(inc i)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment