Skip to content

Instantly share code, notes, and snippets.

@joerupen
Created May 31, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joerupen/efb104ea81fce9d3a77d to your computer and use it in GitHub Desktop.
Save joerupen/efb104ea81fce9d3a77d to your computer and use it in GitHub Desktop.
;; Does core.type intersection not work on values?
(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 "days with party events"
(t/U (t/Val :fri) (t/Val :sat)))
(t/defalias party-days-of-the-week "days in the week with party events"
(t/I week-days party-days))
(t/defn party-during-week [x :- party-days-of-the-week] x)
;; then in repl
(check-ns 'user-types.demo)
(t/cf (u/party-during-week :wed))
;; ups, no error? only friday should be allowed
=> [(t/I u/party-days u/week-days) {:then tt, :else ff}]
@frenchy64
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment