Last active
August 29, 2015 14:05
-
-
Save halcat0x15a/ffb21d469e58b9c05dac to your computer and use it in GitHub Desktop.
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
!SLIDE | |
# Clojureの型推論器 | |
## typelogicの紹介 | |
[@halcat0x15a](https://twitter.com/halcat0x15a) | |
!SLIDE | |
# 型の話 | |
```clojure | |
(class "") ; => java.lang.String | |
(class 0) ; => java.lang.Long | |
(defn first [coll] | |
(clojure.lang.RT/first coll)) | |
``` | |
!SLIDE | |
# 型推論器の利用 | |
型検査 | |
```clojure | |
=> (defn contains0? [^String s] | |
(.contains s 0)) | |
=> (check (quote (fn [^String s] (.contains s 0)))) | |
Unhandled clojure.lang.ExceptionInfo | |
type mismatch; | |
{:op [::fn ([[CharSequence] boolean])], | |
:args (0)} | |
``` | |
!SLIDE | |
# typelogicの特徴 | |
```clojure | |
; core.typed | |
(ann twice [Number -> Number]) | |
(defn twice [n] | |
(* n 2)) | |
(check-ns) | |
(cf twice) ; => (clojure.core.typed/IFn [Number -> Number]) | |
; typelogic | |
(check (quote (fn [n] (* n 2)))) ; => [::fn ([long] long) ([double] double) ([Object] Number)] | |
(check {(quote *) [::fn ([Number Number] Number)]} | |
(quote (fn [n] (* n 2)))) ; => [::fn ([Number] Number)] | |
(check (quote str)) ; => [::var str [::fn ([] String) ([Object] String) ([Object [::seq]] String)]] | |
``` | |
!SLIDE | |
# これから | |
* special formの網羅 | |
* 構造的な型のサポート | |
* 推論器を使ったツールの作成 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment