hodur-engine notes
Motivation
Awesome if you could generate stuff from a single source of definition
lacinia-schema
spec
datomic-schema
etc...
Especially if they can refer to the same datatype
e.g. would be expensive to ensure that the person definition in the lacinia schema is consistent with the corresponding spec
And if writing your own generator is easy
Predecessor(?)
Difference
Umlaut
DSL
parsed with instaparse
generators work with the resulting map
extend definition beyond dsl via annotation
Hudor
edn
read by the clojure reader
returning a datascript db
which generators can query
extend definition beyond default via metadata
Implementation details
Using a generator
No datascript/datalog knowledge required
add hudor/engine along with whatever plugins that you will use as deps. Here I will stick to spec.
code:clojure
{:deps {hodur/engine {:mvn/version "0.1.5"}
hodur/spec-schema {:mvn/version "0.1.0"}}}
Define a model in edn along with meta data that is recognized by the generator
e.g. if it is a lacinia generator, could be :lacinia/something
code:clojure
[^{:spec/tag-recursive true}
Food
[^{:type String
ingredients]
^{:spec/tag-recursive true}
Diet
[^{:type Food
:nullable true}
meals]]
Invoke the generator
code:clojure
(hodur-spec/schema
(hodur/init-path "domain-model.edn")
{:prefix "foo"})
=>
[(clojure.spec.alpha/def
:foo.food/ingredients
(clojure.spec.alpha/coll-of
clojure.core/string?
:min-count
0
:max-count
4))
(clojure.spec.alpha/def
:foo/food
(clojure.spec.alpha/keys
:req-un
:opt-un
[]))
(clojure.spec.alpha/def
:foo.diet/meals
(clojure.spec.alpha/coll-of :foo/food :min-count 1 :max-count 3))
(clojure.spec.alpha/def
:foo/diet
Authoring a generator
query the datascript db and do stuff