2024年的Clojure状态调查!中分享您的想法。

欢迎!请访问关于页面获取更多关于此如何工作的信息。

0
core.typed

https://gist.github.com/joerupen/efb104ea81fce9d3a77d

`

;; core.type的交集在值上不工作吗?

(ns user-types.demo
(:require [clojure.core.typed :as t]))

(t/defalias week-days "mon-fri"
(t/U (t/Val :mon) (t/Val :tue) (t/Val :wed)

   (t/Val :thu) (t/Val :fri) ))

(t/defalias party-days "有派对活动的天数"
(t/U (t/Val :fri) (t/Val :sat)))

(t/defalias party-days-of-the-week "一周中举行派对活动的那天"
(t/I week-days party-days))

(t/defn party-during-week [x :- party-days-of-the-week] x)

;; 然后在REPL中
(check-ns 'user-types.demo)

(t/cf (u/party-during-week :wed))
;; 哎呀,没有错误?只有星期五应该被允许
=> [(t/I u/party-days u/week-days) {:then tt, :else ff}]
`

1 回答

0
参考:https://clojure.atlassian.net/browse/CTYP-225(由ambrosebs报告)
...