I think I semi-answered my own question, although I'm still curious to know if anyone has a better solution:
For Java classes, you can start by googling e.g. "Java Integer class," and the official docs will show you the chain of inheritance up from java.lang.Integer
-> java.lang.Number
-> java.lang.Object
. It seems that most (if not all...?) java.lang.X
classes can be abbreviated within extend-protocol
as just X
, so Number
should work for extending a protocol to all subclasses of numbers.
It seems like the online documentation for Clojure doesn't clearly show chains of inheritance like this, unless I'm missing something. But clojure.core/supers is a handy method to at least find classes to try extending a protocol to in order to get the functionality you're looking for:
user> (class [])
;=> clojure.lang.PersistentVector
user> (supers (class []))
;=> #{clojure.lang.Sequential clojure.lang.ILookup clojure.lang.AFn
clojure.lang.APersistentVector java.util.concurrent.Callable
java.util.RandomAccess clojure.lang.Reversible java.util.List
clojure.lang.IHashEq java.util.Collection clojure.lang.IMeta
java.lang.Object java.io.Serializable clojure.lang.Associative
clojure.lang.Seqable clojure.lang.IEditableCollection java.lang.Iterable
clojure.lang.Counted java.lang.Runnable clojure.lang.IPersistentCollection
clojure.lang.IObj clojure.lang.IPersistentVector clojure.lang.Indexed
clojure.lang.IFn clojure.lang.IPersistentStack java.lang.Comparable}
clojure.lang.Sequential
seems like a useful class for extending a protocol for which you'd like a general implemention for all sequential collections.