Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Last active November 10, 2018 14:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustingetz/3704ee0d3fe2f8df54c848cb1fe183c8 to your computer and use it in GitHub Desktop.
Save dustingetz/3704ee0d3fe2f8df54c848cb1fe183c8 to your computer and use it in GitHub Desktop.
(require '[clojure.core.match :refer [match]])
(require '[datascript.parser :refer [parse-query]])
(import (datascript.parser FindRel FindColl FindTuple FindScalar Variable Aggregate Pull))
(def q '[:find [?e ...] :where [?e :db/ident]])
(let [FindColl FindColl ; Create locals for symbols
FindScalar FindScalar
FindRel FindRel
FindTuple FindTuple]
(match [(type (:qfind (parse-query q)))]
[FindRel] :rel ; match searches locals first before binding wildcards
[FindColl] :coll
[FindScalar] :scalar
[FindTuple] :tuple))
; => :coll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment