Public Vars

Back

any? (clj)

(source)

function

(any? x)
Returns true given any argument.

Examples

arohner/spectrum
(ns spectrum.core-specs
  (:require [clojure.core :as core]
            [clojure.spec.alpha :as s]
            [spectrum.core :as st]
            [spectrum.types :as t]
            [spectrum.util :refer [def-instance-predicate]]))

(s/fdef clojure.core/in-ns :args (s/cat :ns symbol?) :ret namespace?)
(s/fdef clojure.core/list :args (s/* any?) :ret list?)
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))))

cc/seq? (t/Pred (t/Seq t/Any))
cc/set? (t/Pred (t/Set t/Any))
cc/vector? (t/Pred (t/Vec t/Any))
cc/nil? (t/Pred nil)
#?@(:cljs [
cc/undefined? (t/Pred t/JSundefined)
])
cc/false? (t/Pred false)
cc/true? (t/Pred true)
cc/symbol? (t/Pred t/Sym)
cc/keyword? (t/Pred t/Keyword)
cc/map? (t/Pred (t/Map t/Any t/Any))
cc/boolean? (t/Pred t/Bool)
cc/any? [t/Any :-> true]
cc/record? (t/Pred #?(:clj clojure.lang.IRecord
                      :cljs cljs.core/IRecord))
typedclojure/typedclojure
(ns typed-test.spec.clojure.core
  (:require [typed.spec.clojure.core :as api]
            [clojure.alpha.spec :as s]
            [clojure.alpha.spec.gen :as gen]
            [clojure.alpha.spec.test :as stest]
            [typed.clj.spec :as t]
            [typed.clj.spec.test-utils :as tu]
            [clojure.test :refer :all]))

(deftest atom-spec-test
  ;; deref
  (tu/is-valid (s/fspec :args (s/cat :atom (api/atom-spec :read integer?))
                        :ret integer?)
               deref)
  (tu/is-invalid (s/fspec :args (s/cat :atom (api/atom-spec :read integer?))
                          :ret boolean?)
                 deref)
  (tu/is-valid ::deref deref)
  (tu/is-invalid ::deref (comp str deref))
  ;; reset!
  (tu/is-valid ::reset! reset!)
  (tu/is-invalid ::reset! deref)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w))
                                              :w (t/tv :w))
                                 ; bad return
                                 :ret integer?))
                 reset!)
  ;; swap! (arity 2)
  (tu/is-valid ::swap!-2 swap!)
  (tu/is-valid ::swap!-2
               ; spec does not require the write to actually happen
               (fn [a f]
                 (f @a)))
  (tu/is-invalid ::swap!-2
                 ; cannot just return deref
                 (fn [a f]
                   @a))
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r))
                                                          ;returns wrong val
                                                          :ret any?))
                                 :ret (t/tv :w)))
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :w)) ;takes :w
                                                          :ret (t/tv :w)))
                                 :ret (t/tv :w)))
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :r) ;swap :r and :w
                                                                   :read (t/tv :w))
                                              :f (s/fspec :args (s/cat :r (t/tv :r))
                                                          :ret (t/tv :w)))
                                 :ret (t/tv :w)))
                 swap!)
  ;; swap! (arity 3+)
  (tu/is-valid ::swap! swap!)
  (tu/is-invalid ::swap!
                 ;drops args
                 (fn [a f & args] (swap! a f)))
  (tu/is-invalid ::swap!
                 swap-vals!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              ;provided args too broad
                                              :extra-args (t/fold-binders any? :extra-args))
                                 :ret (t/tv :w)))
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              ; no extra args passed
                                              #_#_:extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                 :ret (t/tv :w)))
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       ; no extra args accepted
                                                                       #_#_:extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                 :ret (t/tv :w)))
                 swap!)
  ;; swap-vals! (arity 2)
  (tu/is-valid ::swap-vals!-2
               swap-vals!)
  (tu/is-invalid ::swap-vals!-2
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r))
                                                          :ret (t/tv :w)))
                                 ;swapped return order
                                 :ret (s/tuple (t/tv :w) (t/tv :r))))
                 swap-vals!)
  ;; swap-vals! (arity 3+)
  (tu/is-valid ::swap-vals!
               swap-vals!)
  (tu/is-invalid ::swap-vals!
                 ;drops args
                 (fn [a f & args] (swap-vals! a f)))
  (tu/is-invalid ::swap-vals!
                 swap!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              ;provided args too broad
                                              :extra-args (t/fold-binders any? :extra-args))
                                 :ret (s/tuple (t/tv :r) (t/tv :w))))
                 swap-vals!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              ; no extra args passed
                                              #_#_:extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                 :ret (s/tuple (t/tv :r) (t/tv :w))))
                 swap-vals!)
  (tu/is-invalid (t/all :binder (t/binder :w (t/bind-tv)
                                          :r (t/bind-tv)
                                          :extra-args (t/bind-tv
                                                        :kind (s/* (t/binder
                                                                     :arg (t/bind-tv)))))
                        :body
                        (s/fspec :args (s/cat :atom (api/atom-spec :write (t/tv :w)
                                                                   :read (t/tv :r))
                                              :f (s/fspec :args (s/cat :r (t/tv :r)
                                                                       ; no extra args accepted
                                                                       #_#_:extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                                          :ret (t/tv :w))
                                              :extra-args (t/fold-binders (t/tv :arg) :extra-args))
                                 :ret (s/tuple (t/tv :r) (t/tv :w))))
                 swap-vals!)
  ;; clojure.core/atom
  ;(tu/is-valid ::atom atom) ;;FIXME fails in CI
  (tu/is-invalid ::atom (comp atom str))
  (tu/is-invalid ::atom (comp #(doto % (reset! "a")) atom))
  )
bsless/more.async
(ns more.async.dataflow.node
  (:require
   [clojure.spec.alpha :as s]
   [clojure.core.async :as a]
   [more.async :as ma]
   [clojure.data]))

(s/def ::to ::name)
(s/def ::to* (s/* ::to))
(s/def ::to-map (s/map-of any? ::to))
(s/def ::from ::name)
(s/def ::size nat-int?)
(s/def ::xf fn?)
(s/def ::rf fn?)
(s/def ::fn fn?)
(s/def ::init-fn fn?)
(s/def ::async? boolean?)
(s/def ::timeout pos-int?)

(s/def ::pubsub (s/keys :req [::pub ::topic-fn] :opt [::sub]))
(s/def ::pub ::name)
(s/def ::sub (s/* (s/keys :req [::topic ::name])))
(s/def ::topic any?)
(s/def ::topic-fn ifn?)
liquidz/merr
(ns merr.spec
  (:require
   [clojure.core.specs.alpha :as c.s]
   [clojure.spec.alpha :as s]
   [merr.core :as core]))

(s/def ::merr-error (partial instance? merr.core.MerrError))
(s/def ::type some?)
(s/def ::message (s/or :string string? :none nil?))
(s/def ::data any?)
(s/def ::cause any?)
(s/def ::error-map (s/keys :opt-un [::type ::message ::data ::cause]))

(s/fdef core/error?
  :args (s/cat :x any?)
  :ret boolean?)

(s/fdef core/let
  :args (s/cat :err-sym simple-symbol?
               :bindings ::c.s/bindings
               :body (s/* any?))
  :ret any?)

(s/fdef core/assert
  :args (s/cat :pred any?
               :m map?)
  :ret (s/or :err ::merr-error
             :none nil?))

(s/fdef core/type :args (s/cat :e any?))
(s/fdef core/message :args (s/cat :e any?))
(s/fdef core/data :args (s/cat :e any?))
(s/fdef core/cause :args (s/cat :e any?))