Back
supers (clj)
(source)function
(supers class)
Returns the immediate and indirect superclasses and interfaces of c, if any
Examples
clojure/core.typed
(ns clojure.core.typed.test.rclass-supers
(:require [clojure.core.typed.test.test-utils :refer :all]
[clojure.test :refer :all]
[clojure.core.typed :as t]
[clojure.core.typed.util-vars :as vs]
[clojure.core.typed.checker.type-rep :refer :all]
[clojure.core.typed.checker.type-ctors :refer :all]
[clojure.core.typed.checker.jvm.parse-unparse :refer [unparse-type]]
[clojure.set :as set])
(:import (clojure.lang Seqable IPersistentVector IPersistentCollection
Indexed IPersistentMap APersistentVector PersistentVector APersistentMap PersistentHashMap
PersistentHashSet PersistentTreeSet IPersistentSet APersistentSet
IPersistentList PersistentList ISeq ASeq IPersistentCollection Associative
IPersistentStack
PersistentTreeMap)))
(deftest rclass-supers-test
(is-clj
(let [num (RClass-of Number)
nnum (Un num -nil)]
(doseq [[t r] {(RClass-of Seqable [num]) (Un -nil num)
(RClass-of IPersistentVector [num]) (Un -nil num)
(RClass-of APersistentVector [num]) (Un -nil num)
(RClass-of PersistentVector [num]) (Un -nil num)
(RClass-of IPersistentList [num]) (Un -nil num)
(RClass-of PersistentList [num]) (Un -nil num)
(RClass-of ISeq [num]) (Un -nil num)
(RClass-of ASeq [num]) (Un -nil num)
(RClass-of clojure.lang.Cons [num]) (Un -nil num)
(RClass-of clojure.lang.LazySeq [num]) (Un -nil num)
(RClass-of IPersistentCollection [num]) (Un -nil num)
(RClass-of IPersistentSet [num]) (Un -nil num)
(RClass-of APersistentSet [num]) (Un -nil num)
(RClass-of PersistentTreeSet [num]) (Un -nil num)
(RClass-of PersistentHashSet [num]) (Un -nil num)
(RClass-of Associative [num num num]) -any
(RClass-of IPersistentStack [num]) (Un -nil num)
(RClass-of String) (Un -nil (RClass-of Character))
(RClass-of CharSequence) (Un -nil (RClass-of Character))
; only supports key/val
;(RClass-of clojure.lang.IMapEntry [num num]) num
(RClass-of clojure.lang.AMapEntry [num num]) num
(RClass-of clojure.lang.MapEntry [num num]) num
(RClass-of IPersistentMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of APersistentMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of PersistentHashMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of PersistentTreeMap [num num]) (Un -nil (-hvec [num num]))}]
(t/check-form* '(fn [a] (first a))
(binding [vs/*verbose-types* true]
(unparse-type
(make-FnIntersection
(make-Function [t] r))))))
true)))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
"Type annotations for the base Clojure distribution."
#?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
(:require [clojure.core :as cc]
[typed.clojure :as t]
#?(:clj [typed.ann-macros.clojure :as macros])
#?(:clj typed.ann.clojure.jvm) ;; jvm annotations
#?(:clj clojure.core.typed))
#?(:clj
(:import (clojure.lang PersistentHashSet PersistentList
APersistentMap #_IPersistentCollection
#_ITransientSet
IRef)
(java.util Comparator Collection))))
(t/defalias
^{:doc "An atom that can read and write type x.
Deprecated: Please use t/Atom instead."
:deprecated "1.1.6"
:superseded-by `t/Atom
:forms '[(Atom1 x)]}
t/Atom1
t/Atom)
(t/defalias
^{:doc "An var that can read and write type x."
:deprecated "1.1.6"
:superseded-by `t/Var
:forms '[(Var1 x)]}
t/Var1
t/Var)
#?(:clj
(t/defalias
^{:doc "A ref that can read and write type x."
:deprecated "1.1.6"
:superseded-by `t/Ref
:forms '[(Ref1 x)]}
t/Ref1
t/Ref))
#?(:clj
(t/defalias
^{:doc "An agent that can read and write type x.
Deprecated: Please use t/Agent."
:deprecated "1.1.6"
:superseded-by `t/Agent
:forms '[(Agent1 x)]}
t/Agent1
t/Agent))
clojure.set/subset? [(t/Set t/Any) (t/Set t/Any) :-> t/Bool]
clojure.set/superset? [(t/Set t/Any) (t/Set t/Any) :-> t/Bool]
clojure.set/join [(t/Set (t/Map t/Any t/Any)) (t/Set (t/Map t/Any t/Any)) (t/? (t/Map t/Any t/Any)) :-> (t/Set (t/Map t/Any t/Any))]
cc/supers [Class :-> (t/U nil (t/I t/NonEmptyCount (t/Set Class)))]
])
typedclojure/typedclojure
(ns clojure.core.typed.test.rclass-supers
(:require [typed.clj.checker.test-utils :refer :all]
[clojure.test :refer :all]
[clojure.core.typed :as t]
[clojure.core.typed.util-vars :as vs]
[typed.cljc.checker.type-rep :refer :all]
[typed.cljc.checker.type-ctors :refer :all]
[typed.clj.checker.parse-unparse :refer [unparse-type]]
[clojure.set :as set])
(:import (clojure.lang IPersistentVector IPersistentCollection
Indexed IPersistentMap APersistentVector PersistentVector APersistentMap PersistentHashMap
PersistentHashSet PersistentTreeSet IPersistentSet APersistentSet
IPersistentList PersistentList ISeq ASeq IPersistentCollection Associative
IPersistentStack
PersistentTreeMap)))
(deftest rclass-supers-test
(is-clj
(let [num (RClass-of Number)
nnum (Un num -nil)]
(doseq [[t r] {(-name `t/Seqable num) (Un -nil num)
(RClass-of IPersistentVector [num]) (Un -nil num)
(RClass-of APersistentVector [num]) (Un -nil num)
(RClass-of PersistentVector [num]) (Un -nil num)
(RClass-of IPersistentList [num]) (Un -nil num)
(RClass-of PersistentList [num]) (Un -nil num)
(RClass-of ISeq [num]) (Un -nil num)
(RClass-of ASeq [num]) (Un -nil num)
(RClass-of clojure.lang.Cons [num]) (Un -nil num)
(RClass-of clojure.lang.LazySeq [num]) (Un -nil num)
(RClass-of IPersistentCollection [num]) (Un -nil num)
(RClass-of IPersistentSet [num]) (Un -nil num)
(RClass-of APersistentSet [num]) (Un -nil num)
(RClass-of PersistentTreeSet [num]) (Un -nil num)
(RClass-of PersistentHashSet [num]) (Un -nil num)
(-name `t/Associative num num) -any
(RClass-of IPersistentStack [num]) (Un -nil num)
(RClass-of String) (Un -nil (RClass-of Character))
(RClass-of CharSequence) (Un -nil (RClass-of Character))
; only supports key/val
;(RClass-of clojure.lang.IMapEntry [num num]) num
(RClass-of clojure.lang.AMapEntry [num num]) num
(RClass-of clojure.lang.MapEntry [num num]) num
(RClass-of IPersistentMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of APersistentMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of PersistentHashMap [num num]) (Un -nil (-hvec [num num]))
(RClass-of PersistentTreeMap [num num]) (Un -nil (-hvec [num num]))}]
(t/check-form* '(fn [a] (first a))
(binding [vs/*verbose-types* true]
(unparse-type
(make-FnIntersection
(make-Function [t] r))))))
true)))
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.interval-set
(:require [clojure.core.reducers :as r :refer [coll-fold]]
[clojure.set]
[com.dean.interval-tree.tree.interval :as interval]
[com.dean.interval-tree.tree.node :as node]
[com.dean.interval-tree.tree.order :as order]
[com.dean.interval-tree.tree.protocol :as proto]
[com.dean.interval-tree.tree.root]
[com.dean.interval-tree.tree.tree :as tree])
(:import [clojure.lang RT]
[com.dean.interval_tree.tree.protocol PExtensibleSet]
[com.dean.interval_tree.tree.root INodeCollection
IBalancedCollection
IOrderedCollection
IIntervalCollection]))
;; TODO: how should these work for interval-set?
PExtensibleSet
(intersection [this that]
(with-interval-set this
(cond
(identical? this that) this
(.isCompatible this that) (IntervalSet. (tree/node-set-intersection root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(union [this that]
(with-interval-set this
(cond
(identical? this that) this
(.isCompatible this that) (IntervalSet. (tree/node-set-union root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(difference [this that]
(with-interval-set this
(cond
(identical? this that) (.empty this)
(.isCompatible this that) (IntervalSet. (tree/node-set-difference root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(subset [this that]
(with-interval-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? (.getRoot that) root) ;; Grr. reverse args of tree/subset
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(superset [this that]
(with-interval-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? root (.getRoot that)) ;; Grr. reverse args of tree/subset
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.ordered-set
(:require [clojure.core.reducers :as r :refer [coll-fold]]
[clojure.set]
[com.dean.interval-tree.tree.node :as node]
[com.dean.interval-tree.tree.order :as order]
[com.dean.interval-tree.tree.protocol :as proto]
[com.dean.interval-tree.tree.root]
[com.dean.interval-tree.tree.tree :as tree])
(:import [clojure.lang RT]
[com.dean.interval_tree.tree.protocol PExtensibleSet]
[com.dean.interval_tree.tree.root INodeCollection
IBalancedCollection
IOrderedCollection]))
PExtensibleSet
(intersection [this that]
(with-ordered-set this
(cond
(identical? this that) this
(.isCompatible this that) (new OrderedSet (tree/node-set-intersection root (.getRoot ^OrderedSet that))
cmp alloc stitch {})
(.isSimilar this that) (clojure.set/intersection (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(union [this that]
(with-ordered-set this
(cond
(identical? this that) this
(.isCompatible this that) (new OrderedSet (tree/node-set-union root (.getRoot ^OrderedSet that))
cmp alloc stitch {})
(.isSimilar this that) (clojure.set/union (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(difference [this that]
(with-ordered-set this
(cond
(identical? this that) (.empty this)
(.isCompatible this that) (new OrderedSet (tree/node-set-difference root (.getRoot ^OrderedSet that))
cmp alloc stitch{})
(.isSimilar this that) (clojure.set/difference (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(subset [this that]
(with-ordered-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? (.getRoot ^OrderedSet that) root) ;; Grr. reverse args of tree/subset
(.isSimilar this that) (clojure.set/subset? (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(superset [this that]
(with-ordered-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? root (.getRoot ^OrderedSet that)) ;; Grr. reverse args of tree/subset
(.isSimilar this that) (clojure.set/subset? that (into #{} this))
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))