vrac

Template-based web library [WIP] - https://github.com/green-coder/vrac Zulip archive: https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/topic/vrac Clojureverse archive: https://clojurians-log.clojureverse.org/vrac
2020-10-25T03:56:05.011300Z

Lately, I took a break away from the project, now I am back at it.

2020-10-25T05:51:40.012400Z

Today I am working on modeling a query language which will be used between the Vrac clients and the Vrac servers.

2020-10-25T05:52:36.013200Z

I will call it VracQL (VQL in short), it naturally stands for Vrac’s Query Language

2020-10-25T09:41:20.013800Z

I finished to decide for the format:

; EQL
'{session [:session/title
           :session/description
           {:session/speakers [:speaker/name
                               :speaker/bio]}]}

; VQL
'[(:session/title session)
  (:session/description session)
  (for [speakers (:session/speakers session)]
    [(:speaker/name speakers)
     (:speaker/bio speakers)])]

;; VQL - same semantic as above
'(let [{:session/keys [title description speakers]} session]
   [title
    session
    (for [{:speaker/keys [name bio]} speakers]
      [name
       bio])])

; Returns values similarly to Clojure
["session title"
 "session description"
 [["name1"
   "bio1"]
  ["name2"
   "bio2"]]]

2020-10-25T09:42:47.015Z

VracQL can include a directed graph of data computations, similarly to the Vrac templates.

; VQL - computed data
'[(- (:admin.money/spent global)
     (:admin.money/earned global))
  (count (:admin/users global))]

; VQL - let with computed data
'(let [{:admin/keys [users]
        :admin.money/keys [earning spending]} global
       benefit (- earning spending)
       nb-users (count users)]
   [benefit
    nb-users
    (/ benefit nb-users)])

2020-10-25T09:43:38.015900Z

VracQL is more verbose than EQL, but I like the fact that users won’t have to remember one more DSL syntax, as it is a subset of Clojure.

2020-10-25T15:30:01.017100Z

I pushed my VQL wip code at https://github.com/green-coder/vrac/blob/vracql/src/vrac/model/vql.cljc I am considering adding support for recursion in VQL later. Any suggestion about the syntax is welcome.