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 报告)
...