Commit graph

28 commits

Author SHA1 Message Date
Ruud van Asseldonk
5ee2a7e244 Update Vega example now that floats are supported 2025-02-24 20:42:59 +01:00
Ruud van Asseldonk
12ffe62cf4 Address a few minor issues in the new build code
Caught in self-review, and I don't feel like turning them into fixups
for all of the commits that introduced these.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
0831fda447 Add --dry-run option to "rcl build"
As expected, the golden tests fail to run under Nix because the test
directory is not writable. And it's better to not write in my opinion,
let's not hack that and have a dry run output mode.

For now the output format is not structured, this is good enough for the
thests. It could be nice to do structured output in RCL format, but we
can do that later if needed.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
207d8c75bd Simplify banner support in 'rcl build'
I couldn't add a banner to the GitHub Actions yaml because the output
format is json which does not support comments. By making the banner
just a string that is up to the user to fill, everything becomes both
simpler and more general.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
f9014cb1ef Add entry point for 'rcl build' command 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
972fa2fe4e Add Vega graphic as an example
Vega is a data format, though one could say configuration format, for
declaratively defining data visualizations. It can be generated from
Python using Altair, but how about generating it with RCL?

I don't know if this is a good idea, but it is at least possible.
And it's already way more convenient to write than writing json in
the online editor, because in RCL you don't have to quote the keys.
2024-07-22 21:19:03 +02:00
Ruud van Asseldonk
a070021547 Make a trailing comma always force tall
At first I thought, “but a single-element collection should always fit,
right?” And sure it fits, but then I reformatted a larger experimental
config I have, including some GitHub Actions, and it turns out that
sometimes I prefer even single-element litst to be tall. Black is right
about this. I should be less opinionated, leave it to the user.
2024-06-18 19:23:40 +02:00
Ruud van Asseldonk
b0a44ec583 Implement magic trailing comma for collections
This gives users a bit more control over whether things get formatted
wide or tall. This matters in practice, as Black learned the hard way,
and I did as well in the GitHub Actions example.
2024-06-15 21:55:38 +02:00
Ruud van Asseldonk
606376f2d9 Run new autoformatter on all examples
In the past I did not autoformat them because I was not happy with the
output yet, but now the formatter is good enough that I'm willing to
take this. There are still a few cases where I'm like ... meh, but that
requires human judgement that I think a formatter can never get right,
so I'm willing to stop arguing about this to get a formatter.

Possibly in the future I can add the magic trailing comma like Black has
in Python, to force collections to be tall. That could still be nice.
We can do that in a follow-up.
2024-06-15 21:18:08 +02:00
Ruud van Asseldonk
186184dfcd Finish first draft of the tutorial 2023-12-05 01:01:39 +01:00
Ruud van Asseldonk
b363460d92 Begin writing a tutorial
I realized I'm often complaining about tools for not having good
documentation. I tried to get started with D for the Advent of Code
for example, and although it has a reference, I couldn't find good
introductory material. RCL doesn't even have an introduction, so let's
fix that.
2023-12-04 22:42:40 +01:00
Ruud van Asseldonk
b33a015316 Update examples to showcase group_by/key_by 2023-12-01 01:07:44 +01:00
Ruud van Asseldonk
878eaa4aa4 Use comma as the separator in record notation
I am still ambivalent about this. On the one hand I have a strong sense
that "key = value;" is a statement that needs a terminator. On the other
hand, it makes things more uniform to have only a single separator.

I think I just need to get used to the comma, and then I will not mind
so much. But let's see.
2023-10-21 10:43:44 +02:00
Ruud van Asseldonk
7db1f94bf9 Add Dict.len and List.len builtins 2023-09-30 16:24:03 +02:00
Ruud van Asseldonk
a8f0203454 Add use case example: preventing duplicate UIDs 2023-09-30 16:18:19 +02:00
Ruud van Asseldonk
1c842d0c9d Fix how a {}-comprehension's type is resolved
We have to look at the syntactic construct, we cannot look at the
runtime value. Otherwise, because an empty collection is a dict, the
following would be a dict:

    {for x in xs: x}

Even though we can tell that it's a set, because it contains a scalar
value in the comprehension, not a key-value pair.
2023-09-24 13:48:36 +02:00
Ruud van Asseldonk
93cdd59a2c Make GitHub Actions example more powerful
Show off the f-strings and loops.
2023-09-20 22:47:00 +02:00
Ruud van Asseldonk
33391d2ea1 Add a GitHub Actions example
GitHub Actions is one of those things that tends to have a lot of
repetition, where RCL may come in handy.
2023-09-20 22:41:59 +02:00
Ruud van Asseldonk
0a30d29c25 Move initial ideas document to ideas directory
Then the examples are examples that actually work.
2023-09-20 22:41:35 +02:00
Ruud van Asseldonk
cd264ad60d Fix typo in example 2023-08-10 20:36:49 +02:00
Ruud van Asseldonk
8dbf042efb Implement the map inversion example without groupby
Actually we already have all the ingredients we need! Pretty sweet!
2023-08-10 00:05:32 +02:00
Ruud van Asseldonk
0b7840a128 Allow identifiers to start with underscore 2023-08-09 23:59:41 +02:00
Ruud van Asseldonk
ac800eb063 Begin working on example to invert mapping
I need some kind of group by for this, and for that I need what in
Haskell is called unionWith. I could add that as a builtin on maps,
then I need to implement lambdas to make progress.

But now there is a dilemma. All of that is much nicer syntax-wise and
typecheck-wise if there were freestanding functions instead of methods.
And when you define helpers yourself, they are going to be free-standing
anyway. So maybe it's better to make them free-standing from the start?

But anyway that's for later.
2023-08-09 23:45:56 +02:00
Ruud van Asseldonk
a157d7ee4e Implement parser with terminals based on new grammar
This is a lot more principled now, writing down the grammar helped a
lot. Parsing "seq" is still a bit ad-hoc, but it will do for now.
2023-08-08 21:48:02 +02:00
Ruud van Asseldonk
15e85d2d26 Add some more ideas about types 2023-08-06 22:50:07 +02:00
Ruud van Asseldonk
2eabedd26f Begin working on a concrete syntax tree
This is a major complication, but I do want to be able to build an
autoformatter, and then I will need one, so let's do it from the start,
I think it will be less work in the end.
2023-08-06 22:39:33 +02:00
Ruud van Asseldonk
f60fc43ced License the project under the Apache 2.0 license 2023-08-06 00:38:51 +02:00
Ruud van Asseldonk
c2ed853174 Move example out of Rust src directory, split it
There is the part that is now working, for which I wrote the AST by
hand, and for which I can write a parser now.

And then there is the part which is still vaporware, my scratchpad to
write down ideas, so let's split that out too.
2023-08-06 00:33:43 +02:00