yamlscript 2024-07-30

I tried to form the table into a markdown table, but I ran into the limitations of markdown tables

looks like the multi-line examples are mangled

I copied to google sheets exported to TSV ran through this dumb thing https://products.aspose.app/cells/conversion/tsv-to-markdown then pasted into gist

Yeah it's crap but we just need to find the right flow

Where did you find that canvas thing?

I'm guessing using google sheets might be best in that we can find more tooling to get where we want

but maybe there's something better

Maybe we just need to break it out of the table structure and make it a flat markdown document instead

working on something. sec

which we can easily format with markys

yeah that looks great

I wonder if github has multiedit mode

vscode probably does and github has vscode in the browser

I need to be granted access to your google doc it seems

it's just a copy of the gist

let's not go the google route

This is cool. In the middle of stuff but will ping later!

Can I edit this?

Yes feel free to edit it

I made it with the intent to synthesize my learnings and confirm my understanding

so I'm open to all changes, feedback, & correction

I made a bunch of changes 🙂

Let me know if you have any questions

I like all the changes, I'll go ahead and delete the incorrect interpolation example

Thank you for the edits!

Do you know if that exports to markdown or anything else?

I'm not sure to be honest

I don't see anything

Why does this work:

!yamlscript/v0

my-metadata =: 
    =>: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient

with-meta:
    client
    my-metadata
while this gets an error:
!yamlscript/v0

with-meta:
    client
    =>: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient
This is the error I see (note that I'm using ys -c)
ys -c src/experiment.ys 
Error: mapping values are not allowed here
 in reader, line 5, column 7:
        =>: !
          ^
{:eval [], :debug-stage {}, :compile true}

It's invalid YAML (thus invalid YS)

!yamlscript/v0

with-meta:
    =>: client
    =>: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient
maybe

or better:

!yamlscript/v0

with-meta client:
    =>: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient

or better:

!yamlscript/v0

with-meta client: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient

or better:

!yamlscript/v0

with-meta client::
  :unsynchronized-mutable: True
  :tag: AsyncHttpClient

with-meta:
    client
    my-metadata
is same YAML as:
with-meta: client my-metadata
client my-metadata is a YAML scalar but the you kept a scalar client and tried to add a mapping, which you can't do

but in YS

with-meta: client my-metadata
is same as
with-meta client: my-metadata
so now you can replace the scalar node my-metadata with the mapping node it refers to

also

my-metadata =: 
    =>: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient
can be simplified to
my-metadata =: !
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient
or
my-metadata =::
        :unsynchronized-mutable: True
        :tag: AsyncHttpClient
:: was made to avoid : ! (just because it is so common and looks cleaner)

Error: mapping values are not allowed here
 in reader, line 5, column 7:
        =>: !
          ^
is an error from the YAML parser in YS, because you started a scalar with client and now a mapping node is not allowed there

you would get the same error from clj-yaml (which uses essentially the same YAML parsing library (snakeyaml) as YS)

oh ok thank you for the very thorough answer!

👍 1

I have this defprotocol from https://github.com/redplanetlabs/rama-demo-gallery/blob/master/src/main/clj/rama/gallery/rest_api_integration_module.clj from the Rama demo gallery:

(defprotocol FetchTaskGlobalClient
  (task-global-client [this]))
which I've written as
defprotocol FetchTaskGlobalClient:
  task-global-client: .[this]
am I misusing the . dot here? The generated code looks right

Sorry. missed this one. You are using . correctly although I now favor + over . for that. They are the same but I might deprecate .

The act as escape chars for things that YAML parses as a certain thing but you want it to parse as a "plain YAML scalar" (thus a ys expression)

say: "Go!\n" * 3   # YAML error
say: +"Go!\n" * 3   # Works

say:: [1 2 3]   # ["1 2 3"]
say: +[1 2 3]   # [1, 2, 3]
say: [1 2 3]    # YS error, flow seq not allowed in code mode