-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkl Writer #46
Comments
When you consume a If you want UI-manipulated static data to be validated by Pkl, I'd dump it into JSON and let your Pkl module use |
Ok, makes sense for me for the current model. But don't you think it would be valuable to use Pkl from both sides? E.g. to have a package that is capable of parsing Pkl to an AST and writing it back after a manipulation.
That's the main point why I opened the issue: I could totally move forward this way, but the user would loose all the awesome features of Pkl when the final format is always JSON. |
In very many discussions, this is a source of cognitive dissonance; Pkl isn't a static data format. Yes, you could parse it into an AST, but it would be deeply non-trivial for your GUI to decide how to mutate said AST to change a setting. You'd have to resolve all names and determine whether you're at the end of an amends chain before you can write things out.
If you're giving people a GUI, they don't see the code at all, so there hardly is any Pkl features GUI users will ever see. If you want a strong validation stage, because your GUI could generate settings that don't work (mutually incompatible property settings, for example), then you can still have that using |
While I completely understand what you're saying, I think the reason for the cognitive dissonance is that one of, if not the main, use-cases for language bindings is to programmatically load configuration directly into an application. That is, I just want to allow users of my application to write .pkl, rather than using pkl to generate another format, a use case that pkl does advertise quite prominently:
In that scenario, being able to write back to the configuration is very common - basically every other static configuration format supports this, preserving comments, etc. If we assume that this is a requirement of my application, then I can't really use .pkl as the native format, I have to use JSON, YAML, TOML or something similar. In that case all that pkl brings to the table is validation - I can't write .pkl and I can't take advantage of IDE integration IIUC? At that point I can get a similar experience from something like JSON-schema (albeit much more verbosely). |
All that is not to say that pkl-go should support writing BTW, just to explain why I think there's confusion. |
Entirely agreed.
True, but that's when the configuration on disk is just a serialised form of application-determined (simple - i.e. numbers, booleans, strings) values.
So, here's the thing to solve. If your Pkl file says
and your application determines that This gets worse when you have
Now suppose your application loads |
I would like to be able to evaluate existing pkl files and also write changes.
For my use case, I want to provide an UI for a pkl-based configuration. I then want write back the changes the user has made to the original pkl file.
The text was updated successfully, but these errors were encountered: