Back
coll? (clj)
(source)function
(coll? x)
Returns true if x implements IPersistentCollection
Examples
clojure/core.typed
(ns ^:skip-wiki clojure.core.typed.ann.clojure
"Type annotations for the base Clojure distribution."
(:require [#?(:clj clojure.core.typed
:cljs cljs.core.typed)
:refer [defalias] :as t]))
(t/rclass-preds
; clojure.lang.Seqable
; {:pred (fn [this a?]
; (cond
; (string? this) (every? a? this)
; (coll? this) (every? a? this)))}
clojure.lang.IPersistentCollection
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.ISeq
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.IPersistentSet
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.APersistentSet
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.PersistentHashSet
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.PersistentTreeSet
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.Associative
{:args #{2}
:pred (fn [this a? b?]
`(cond
(vector? ~this) (and (every? ~a? (range (count ~this)))
(every? ~b? ~this))
(map? ~this) (and (every? ~a? (keys ~this))
(every? ~b? (vals ~this)))))}
clojure.lang.IPersistentStack
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.IPersistentVector
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.APersistentVector
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.PersistentVector
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.IMapEntry
{:args #{2}
:pred (fn [this a? b?]
`(and (~a? (key ~this)) (~b? (val ~this))))}
clojure.lang.AMapEntry
{:args #{2}
:pred (fn [this a? b?]
`(and (~a? (key ~this)) (~b? (val ~this))))}
clojure.lang.MapEntry
{:args #{2}
:pred (fn [this a? b?]
`(and (~a? (key ~this)) (~b? (val ~this))))}
clojure.lang.IPersistentMap
{:args #{2}
:pred (fn [this a? b?]
`(and (every? ~a? (keys ~this))
(every? ~b? (vals ~this))))}
clojure.lang.ASeq
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.APersistentMap
{:args #{2}
:pred (fn [this a? b?]
`(and (every? ~a? (keys ~this))
(every? ~b? (vals ~this))))}
clojure.lang.PersistentHashMap
{:args #{2}
:pred (fn [this a? b?]
`(and (every? ~a? (keys ~this))
(every? ~b? (vals ~this))))}
clojure.lang.Cons
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.IPersistentList
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.PersistentList
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.LazySeq
{:args #{1}
:pred (fn [this a?]
`(every? ~a? ~this))}
clojure.lang.Reduced
{:args #{1}
:pred (fn [this a?]
`(~a? (deref ~this)))})
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 "A type that returns true for clojure.core/coll?, with members x."
:forms '[(Coll x)]}
t/Coll
(t/TFn [[x :variance :covariant]]
#?(:clj (clojure.lang.IPersistentCollection x)
:cljs (t/I (t/Seqable x)
cljs.core/ICollection
;;cljs.core/ICounted
cljs.core/IEmptyableCollection
;;cljs.core/IEquiv
))))
cc/associative? (t/Pred (t/Associative t/Any t/Any))
cc/coll? (t/Pred (t/Coll t/Any))
;TODO should these be parameterized?
cc/sequential? (t/Pred t/Sequential)
cc/sorted? (t/Pred (t/Sorted t/Any))
cc/meta [t/Any :-> (t/Nilable (t/Map t/Any t/Any))]
;; FIXME IObj annotations are a hack. doesn't literally return the same reference.
cc/with-meta (t/All [[x :< #?(:clj clojure.lang.IObj
:cljs cljs.core/IWithMeta)]]
[x (t/Nilable (t/Map t/Any t/Any)) :-> x])
cc/vary-meta (t/All [[x :< #?(:clj clojure.lang.IObj
:cljs cljs.core/IWithMeta)] b :..]
[x [(t/Nilable (t/Map t/Any t/Any)) b :.. b :-> (t/Nilable (t/Map t/Any t/Any))] b :.. b :-> x])
marick/structural-typing
(ns structural-typing.use.condensed-type-descriptions.f-whole-type-and-implies
(:require [structural-typing.preds :as pred])
(:use midje.sweet
structural-typing.type
structural-typing.global-type
structural-typing.clojure.core
structural-typing.assist.testutil)
(:refer-clojure :except [any?]))
(fact "an implication that checks the whole structure"
(type! :X (pred/implies coll? (show-as "even" (comp even? count)))
(pred/implies string? (show-as "uncool" #(not= % "cool"))))
(built-like :X [1 2]) => [1 2]
(check-for-explanations :X [2]) => [(err:shouldbe "Value" "even" [2])]
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]))
java.util.Set
(size [_]
(tree/node-size root))
(iterator [this]
(clojure.lang.SeqIterator. (seq this)))
(containsAll [this s] ;; TODO: is this how an interval-set should work?
(with-interval-set this
(cond
(identical? this s) true
(coll? s) (every? #(.contains this %) s)
true (throw (ex-info "unsupported comparison: " {:this this :s s})))))
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]))
java.util.Set
(size [_]
(tree/node-size root))
(iterator [this]
(clojure.lang.SeqIterator. (seq this)))
(containsAll [this s]
(with-ordered-set this
(cond
(identical? this s) true
(.isCompatible this s) (tree/node-subset? root (.getRoot ^OrderedSet s))
(coll? s) (every? #(.contains this %) s)
true (throw (ex-info "unsupported comparison: " {:this this :s s})))))