Skip to content
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

Feature request: add an option to deserialize ndJson array to set (or another collection) #806

Open
lbinria opened this issue Apr 5, 2023 · 9 comments

Comments

@lbinria
Copy link

lbinria commented Apr 5, 2023

Is it possible to add an option to ndDeserialize function to choose if we want to deserialize json array as sequence, set, or another type of collection ?

@lbinria lbinria changed the title Add an option to deserialize ndJson array to set (or another collection) Feature request: add an option to deserialize ndJson array to set (or another collection) Apr 5, 2023
@lbinria
Copy link
Author

lbinria commented Apr 5, 2023

I just made an implementation of a method ndJsonDeserializeOption(path, arrayToSet), but it has several drawbacks:

  • All arrays were de-serialized uniformly as sets or seq
  • There is maybe another collection types that we want to de-serialize arrays into
  • It's not proper to pass argument arrayToSet in the whole function stack that need it

It's possible to imagine another way to do it by using some annotations in Json, for example:

{"__set":[1,2,3]}

Maybe my request doesn't match with the guidelines of this module. I need some advice.

@lemmy
Copy link
Member

lemmy commented Apr 5, 2023

If you need to differentiate between sets and sequences (functions), JSON may not be the best option. Instead, consider using other formats like EDN. Preliminary support for EDN can be found at https://github.com/pfeodrippe/tla-edn by @pfeodrippe.

@pfeodrippe
Copy link
Contributor

pfeodrippe commented Apr 9, 2023

If you need to differentiate between sets and sequences (functions), JSON may not be the best option. Instead, consider using other formats like EDN. Preliminary support for EDN can be found at https://github.com/pfeodrippe/tla-edn by @pfeodrippe.

Thanks, Markus o/

@lbinria If you need anything, we can talk, try also https://github.com/pfeodrippe/tladeps (check the Usage section), it shows you exactly how to use the TLA+ Edn module while leveraging the TLC CLI exactly as it's.

@lemmy I guess I will think about something that allows using tladeps in VSCode (as a separate plugin or by opening a PR against the VSCode TLA+ extension (not necessarily only for tladeps, but maybe something more generic as tladeps has the option of returning just the necessary classpath, letting the TLC CLI untouched)), wdyt?

@lemmy
Copy link
Member

lemmy commented Apr 9, 2023

@pfeodrippe, does your EDN module have any unique features that require dependency on tladeps? It would be ideal if you could contribute your EDN module to the CommunityModules, where it can live alongside other modules like the Json one.

@pfeodrippe
Copy link
Contributor

@pfeodrippe, does your EDN module have any unique features that require dependency on tladeps? It would be ideal if you could contribute your EDN module to the CommunityModules, where it can live alongside other modules like the Json one.

@lemmy One of the reasons for tladeps existence is not having to add things to the CommunityModules at all (a module just needs to be on maven or clojars to be used like a normal Java library, so things get more decentralized), also the Edn module relies on Clojure being available, which I wouldn’t find reasonable to add to CommuntyModules.

tladeps can be used with the classpath option so it can be integrated with the TLC CLI without wrapping TLC.

Does it make sense?

@lemmy
Copy link
Member

lemmy commented Apr 10, 2023

The TLA+ CommunityModules serve not only as a distribution channel, but also as a review platform by the community. When a module is considered ready, it may graduate to be included in TLC, TLAPS, and Apalache (?). For example, the JSON module has already graduated from the CommunityModules to TLC (tlaplus/CommunityModules#84).

@pfeodrippe
Copy link
Contributor

pfeodrippe commented Apr 10, 2023

The TLA+ CommunityModules serve not only as a distribution channel, but also as a review platform by the community. When a module is considered ready, it may graduate to be included in TLC, TLAPS, and Apalache (?). For example, the JSON module has already graduated from the CommunityModules to TLC (tlaplus/CommunityModules#84).

Got it, but l I guess we don’t need to follow this pattern for every module, people should be able to lazily download (and distribute) any modules they want (it doesn’t need to be built-in), this is what tladeps minimally provides (without having to reinvent a new package manager as we are able to leverage deps.edn tooling).

Do you think we could also have a more decentralized version of the modules? Or it’s not desired by the community?

And tladeps is only one tool, it’s not the way of doing it, just one way. WDYT?

@lbinria
Copy link
Author

lbinria commented Apr 11, 2023

@lemmy Thanks for your answer, it make sense.
@pfeodrippe Thank you, I will try to use JSON for now, but if I want more expressive format, I will talk with you.

@pfeodrippe
Copy link
Contributor

@lemmy @lbinria Added something to ease the use of EDN (and other modules) with the VSCode extension (it should also work from the command line).

https://tladeps.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants