I have this code for detecting whether something is a Datomic-style https://docs.datomic.com/query/query-data-reference.html#pull-expressions:
(defn- pull-expr? [expr]
(and (list? expr) (= 'pull (first expr))))
However, this can break if something modifies expr e.g. turning it into a LazySeq before it gets to this fn. I fixed this by calling sequential? instead of list? but I'm wondering if this is a sound approachseq? Is usually what you want instead of list?
oh that makes sense, thanks
side note, what is Sequential even for? the interface has no methods?
A marker interface. To make sequential? work.
it was funny having just read that and reading the docstring of sequential? again: Returns true if coll implements Sequential. An ouroboros of meaning, unfolding in an endless sequence...
but I think I get it. sequential? is just whether or not a collection is ordered...?
Yes, indeed. And of course it only works properly with Clojure types, so you cannot check arbitrary collection types with it. Although, I still don't know why e.g. a sorted map is not considered sequential.
If you really want to be sure it's a valid pull expr https://github.com/bsless/datalog-parser.spec/blob/master/src/bsless/datalog_parser/spec.clj#L77