This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-03
Channels
- # aws (12)
- # beginners (12)
- # biff (10)
- # calva (1)
- # cider (10)
- # cljfx (1)
- # clojure (2)
- # clojure-conj (1)
- # clojure-europe (25)
- # clojure-madison (1)
- # clojure-nl (1)
- # clojure-norway (12)
- # clojure-sweden (4)
- # clojure-uk (6)
- # datomic (11)
- # dev-tooling (3)
- # emacs (5)
- # gratitude (1)
- # introduce-yourself (7)
- # java (3)
- # jobs (1)
- # london-clojurians (2)
- # lsp (23)
- # off-topic (4)
- # practicalli (9)
- # quil (6)
- # re-frame (3)
- # reagent (4)
- # remote-jobs (1)
- # ring (1)
- # shadow-cljs (18)
- # squint (67)
- # tools-deps (5)
- # xtdb (4)
- # yamlscript (12)
I'm working on organizing my ~200 to-do items for YAMLScript (big and small) that are in various places. I want to get most of them into public GitHub issues and label/prioritize/organize them appropriately. Many of these are in a GitHub Project that is private. I was able to export to TSV which is nice. GitHub API access requires GraphQL. This got me to thinking that maybe GraphQL usage is a great targeted domain for YS. I found this very nice Clojure library to build off of: https://github.com/walmartlabs/lacinia Excited to explore this a bit.
Well I'll be...
I was talking about having implemented tag functions in YS like !str/upper-case:
and !merge*:
But then I couldn't get it working so thought maybe I dreamed I wrote that 😄
Found it: https://github.com/yaml/yamlscript/blob/main/core/test/compiler-stack.yaml#L649-L687
$ cat foo.ys
--- &a-map
foo: 111
bar: 222
baz: 333
--- !yamlscript/v0/
- !merge*: [*a-map, {derp: 444}]
- !merge*:
- *a-map
- foo: 444
derp: 555
- !merge*:
- *a-map
- foo: !str/upper-case: hello
derp: 555
$ ys -Y foo.ys
- foo: 111
bar: 222
baz: 333
derp: 444
- foo: 444
bar: 222
baz: 333
derp: 555
- foo: HELLO
bar: 222
baz: 333
derp: 555
I just implemented a very useful thing I've wanted for some time. The ability to write raw Clojure code as part of a YAMLScript file.
$ cat foo.ys
!yamlscript/v0
=>: !clj |
(defmacro qq [x]
`(quote ~x))
say:
qq: (1 2 3)
$ YS foo.ys
(1 2 3)
YS doesn't yet have the syntax for defining Clojure macros (backtick, tilde, etc).
This will be very useful for doing things in YS where the language isn't quite entirely ready for.Note this isn't released or even pushed yet. I'll probably play with it on a branch for a couple days...
Interesting that it -c
compiles with macros expanded.
$ YS foo.ys -c
(defmacro
qq
[x]
(clojure.core/seq
(clojure.core/concat
(clojure.core/list 'quote)
(clojure.core/list x))))
(say (qq (1 2 3)))
Not entirely sure I want that.pushed to branch clj-raw
I share that with appreciation of how yamlscript smuggles in a “real” (not greenspun) lisp.
> It's likely people who already use YAML and want it to do more; not just in k8s or GHA but anywhere they use it. I think the entry point could be data templating, ie. "this YAML is quite repetitive, how can I reduce it?"
This is one such thing I did IRL: https://github.com/BetterThanTomorrow/calva/pull/2511 It turned this: https://github.com/BetterThanTomorrow/calva/blob/ce6fdd3d23ea0cc46e842a38a0eac5ca2d3aca1b/.circleci/config.yml Into this: https://github.com/BetterThanTomorrow/calva/tree/2952822ac64a4e85d0e28031749ab44d1df8aac4/.circleci
By year end I'd like to see YS be the preferred YAML loader (for plain old YAML usage) in every major language. The challenge will get be to get major players like GHA (CircleCI etc) to adopt it natively. But people can do things like this in the mean time...
https://github.com/BetterThanTomorrow/calva/blob/2952822ac64a4e85d0e28031749ab44d1df8aac4/.circleci/config.ys yes Every context using yaml ends up with hacked in "include", "for", templating, etc. I've done it myself