Utilities for Clojure.
clojure.core/satisfies?
that also checks if a value implements all methods in the protocol (considering direct, extended, and metadata methods).clojure.core/satisfies?
that is compatible with metadata extension.clojure.core/some-fn
that has a simple definitional equivalence, a zero-arity, and consistent return values.clojure.core/every-pred
that has a simple definitional equivalence, and a zero-arity.never?
that always returns false.clojure.core/run!
that does not short-circuit on reduced.clojure.core/future
that clears conveyed bindings after execution, resolving a known memory leak.clojure.test/{deftest,testing}
that report the testing context on uncaught exceptions.clojure.core/areduce
that supports naming the array.clojure.core/defprotocol
whose methods can see future extensions.satisfies?
, find-protocol-impl
, find-protocol-method
, extends?
, extenders
that look up the latest version of the protocol such that they have the same behavior with partial.locking
(upstream report), binding
, with-bindings
, sync
, with-local-vars
, with-in-str
, dosync
, with-precision
, with-loading-context
, with-redefs
, delay
, vswap!
, lazy-seq
, lazy-cat
, future
, pvalues
, clojure.test/{deftest,deftest-,testing,with-test,with-test-out}
, clojure.java.shell/with-sh-{dir,env}
, clojure.test.tap/with-tap-output
, clojure.pprint/with-pprint-dispatch
, clojure.core.async/thread
, clojure.core.logic.pldb/with-{db,dbs}
, clojure.tools.trace/dotrace
, clojure.test.check.properties/for-all
, clojure.test.check.generators/let
, clojure.java.jmx/with-connection
, clojure.core.match.debug/with-recur
::reify-body
, a spec for clojure.core/reify
.Current version API documentation
Available on Clojars.
Leiningen:
[io.github.frenchy64/fully-satisfies "1.7.1"]
Clojure CLI (Maven deps):
:deps {io.github.frenchy64/fully-satisfies
{:mvn/version "1.7.1"}}
Clojure CLI (git deps):
;; requires `clj -X:deps prep` to compile java
:deps {io.github.frenchy64/fully-satisfies
{:git/tag "1.7.1", :git/sha "db2c6e3"}}
Try it in a REPL:
# compile
clj -Sdeps '{:deps {io.github.frenchy64/fully-satisfies {:git/tag "1.7.1", :git/sha "db2c6e3"}}}' -X:deps prep
# start REPL
clj -Sdeps '{:deps {io.github.frenchy64/fully-satisfies {:git/tag "1.7.1", :git/sha "db2c6e3"}}}'
(require '[io.github.frenchy64.fully-satisfies :refer [fully-satisfies?]])
(defprotocol A
(a [this])
(b [this]))
(fully-satisfies? A (reify))
;=> false
(fully-satisfies? A (reify A))
;=> false
(fully-satisfies? A (reify A (a [this])))
;=> false
(fully-satisfies? A (reify A (a [this]) (b [this])))
;=> true
(require '[io.github.frenchy64.fully-satisfies.run-all :refer [run-all!]])
(run-all! println [1 (reduced 2) 3])
;1
;2
;3
;=> nil
;; does not short-circuit on reduced
(run-all! println [1 (reduced 2) 3])
;1
;#object[clojure.lang.Reduced 0x3deeac1 {:status :ready, :val 2}]
;3
;=> nil
1.0.0-SNAPSHOT
Release {:major,:minor,:patch}
{:major,:minor,:patch}
SNAPSHOTThanks Wanderson Ferreira for the idea of fully-satisfies?
and its name. My initial stance that fully-satisfies?
was impossible to implement quickly proved to be incorrect after Wanderson's asked the right questions and decompiled some bytecode.
Wanderson and Mark Herman, II also helped improve early iterations of fully-satisfies?
.
supers
call is suspiciousClojure 1.10.3
user=> (get (into-array [1 2 42]) 4294967296)
1
user=> (get "123" 4294967296)
\1
user=> (get (into-array [1 2 42]) 4294967296 :not-found)
1
user=> (get "123" 4294967296 :not-found)
\1
clojure.test-clojure.delays
to use Thread.
+ bound-fn
for is
is
. easy gotcha to fall for.clojure.pprint/with-pprint-logical-block
Where noted, contains code from Clojure under license:
Copyright (c) Rich Hickey. All rights reserved.
The use and distribution terms for this software are covered by the
Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
which can be found in the file epl-v10.html at the root of this distribution.
By using this software in any fashion, you are agreeing to be bound by
the terms of this license.
You must not remove this notice, or any other, from this software.
Otherwise:
Copyright © 2021 Ambrose Bonnaire-Sergeant
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close