What would be the practical use case for ground, tuple, and untuple? Passing tuples to a query via :in?
For ground, I think https://docs.datomic.com/query/query-data-reference.html#ground show the use case decently well. Tuple and untuple are used for querying based on an element of a tuple, or building a tuple based on something else in a query. For example, imagine an entity that has a tuple identity attr, and you want other entities that share one element of that tuple but with another other member. That query would look like this:
[?e :tuple-identity-attr ?t]
[(untuple ?t) [_ ?b]]
[(tuple :other-a ?b) ?t2]
[?e2 :tuple-identity-attr ?t2]So is datalevin’s ground basically an alias to identity? Does it enable any optimizations like it does in datomic?
So is ground is only there for optimizations? Or is there some other case I'm missing?
If ground is just an alias for identity, then it can be used for introducing new bound values mid-query. For example, if you're using or and you need to bind some constant to a lvar on one of the branches, you can use [(identity :foo) ?x] to do that