yamlscript

Markus Agwin 2025-11-15T15:13:00.197059Z

I prepared a draft for a https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01_ys.html , basically a translation to YS from a Clojure post that is live. The goal is to going to show YS in the best possible way, I'd like to take time for this and I am hereby asking for feedback and improvements on my thus shown YS style.

🔥 1
❤️ 1
Markus Agwin 2025-11-21T14:33:16.690489Z

Ratio support is great! I very much like R *:instead of =>: R* and the possibility to line break. This a.(b) for a function call is great, had I known that before, but now I am so in awe of my (hence technically unnecessary) workaround of/at that I'd like to keep it in the case of Emmy. This +/* for partial/compose is horrible 🙂 ! It must never be used in the context of Emmy, math people will run away in droves (after I managed to lure them to YS in the thousands 🙂 ) Concerning ys::std I am generally unsure how to use YS within a Clojure namespace. For Civitas, I do not want to use the graal-compiled parts of YS. I like to add coordinates (via a PR) to deps.edn and require a Clojure namespace containing YS (like I do with [yamlscript.compiler :as ys] in my Emmy example). Is there a standardised way to do this and use ys::std? I have the feeling my use of the git-sha in https://github.com/ClojureCivitas/clojurecivitas.github.io/blob/main/deps.edn is a hack. ClojureCivitas was started in May 2025 by Timothy Pratley who is very active in the [SciCloj/Clay](https://github.com/scicloj/clay) community. The idea is to leverage Clay, the literate programming tool primarily conceived for data-science, in a platform for conveying any idea to the wider Clojure community. To me, YS is a means to even reach beyond Clojure people with those ideas that merit a respective (?additional?) notebook sporting YS syntax.

Ingy döt Net 2025-11-21T14:39:00.101369Z

ys::std is always referred just like clojure::core is. graalvm changes nothing

Ingy döt Net 2025-11-21T14:40:00.719899Z

YS also refers most of clojure::string and clojure::math iirc

Ingy döt Net 2025-11-21T14:40:59.784419Z

you don't need to require any of the standard namespaces

Ingy döt Net 2025-11-21T14:41:47.467619Z

and clojure::str is aliased as str as is normal practice.

Ingy döt Net 2025-11-21T14:44:04.689559Z

$ ys -pe ys/compile
#object[ys.ys$compile 0xb4e3111 "ys.ys$compile@b4e3111"]

Ingy döt Net 2025-11-21T14:45:43.424289Z

I'll set up a best deps.edn for you later

Markus Agwin 2025-11-21T16:08:55.468259Z

I'd like to also highlight a Civitas feature: at the bottom of the https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01_ys.html#and-the-pudding is a link to the Clojure source code. The YS code is represented as ordinary Clojure strings within the Clojure namespace that represents the notebook.

Ingy döt Net 2025-11-20T19:45:50.037989Z

Hey @markus.agwin! Apologies for just replying. I was in transit to Berlin when you posted and then tested positive for covid when I got here. Been a heck of a week, but I'm on the mend. Taking a look now.

Ingy döt Net 2025-11-20T19:51:35.073369Z

mass * 1/2 * square(v) nice. ratio support recently added!

Ingy döt Net 2025-11-20T19:52:12.205769Z

note

$ ys -pe '1/2'
1/2
$ ys -pe '1 / 2'
0.5

Ingy döt Net 2025-11-20T19:52:59.062199Z

because:

$ ys -ce '1 / 2'
(div+ 1 2)

Ingy döt Net 2025-11-20T19:58:12.946689Z

The next example could also be:

defn sphere-to-R3(R):
  fn([_ [theta phi]]):
    up:
      R *: sin(theta) * cos(phi)
      R *: sin(theta) * sin(phi)
      R *: cos(theta)
to avoid the =>s

Ingy döt Net 2025-11-20T20:01:07.514729Z

=>: D(0).of(F).at(state) + ( D(1).of(F).at(state) * velocity(state) )
could be:
D(0).of(F).at(state) +: D(1).of(F).at(state) * velocity(state)

Ingy döt Net 2025-11-20T20:03:50.688849Z

but also I like to keep my lines short:

D(0).of(F).at(state) +:
  D(1).of(F).at(state) * 
  velocity(state)

Ingy döt Net 2025-11-20T20:04:22.970369Z

You can split lines at many many places in YS

Ingy döt Net 2025-11-20T20:22:01.713179Z

I assume you know that q is in ys::std Did you know that call is too?

Ingy döt Net 2025-11-20T20:22:36.663639Z

Like many things call is a bit more polymorphic...

$ ys -pe 'call(inc 1)'
2
$ ys -pe 'call("inc" 1)'
2

Ingy döt Net 2025-11-20T20:29:27.590799Z

I recently added support for a.(b) to mean a.call(b) so:

$ ys -pe 'inc.call(41)'
42
$ ys -pe 'inc.(41)'
42

Ingy döt Net 2025-11-20T20:30:49.260079Z

$ ys -pe 'reverse("cni").(41)'
42
😄

Ingy döt Net 2025-11-20T20:33:36.928189Z

Also + is partial when first arg is ifn?

$ ys -pe 'partial(mul 6): 7'
42
$ ys -pe 'mul + 6: 7'
42

Ingy döt Net 2025-11-20T20:34:16.358199Z

and * is compose:

$ ys -pe 'inc * inc: 40'
42
$ ys -pe '(inc * inc).(40)'
42

Ingy döt Net 2025-11-20T20:35:12.490499Z

I'll poke at this more later

Ingy döt Net 2025-11-20T20:36:57.914969Z

is https://clojurecivitas.github.io/ a newish thing?