unison icon indicating copy to clipboard operation
unison copied to clipboard

Feature/Idea: Automatic data serialization

Open jaredly opened this issue 5 years ago • 1 comments

It would be fantastic to have (e.g. JSON) serialization/deserialization baked into the runtime, for ease of interfacing with other languages. One question that comes up, of course, is what to do about names of attributes, variants, etc.. It might make sense to have two modes -- "generic" (hashes) and "specific" (human-readable names). Generic would be the preferred way when establishing e.g. an API that you want to remain consistent, and Specific would be useful for debugging & one-off scripts. I'm imagining output something like

type Person = { name : Text, age : Nat, parrots : Float }

(specific)

builtin.serializeSpecific(julia)
->
{
  "name": "Julia",
  "age": 27,
  "parrots": 2.5
}

(generic, the default)

builtin.serialize(julia)
->
{
  "#1234bac43f90ecd": "Julia",
  "#bac43f90ecd4367": 27,
  "#45673245acd6725": 2.5,
}

jaredly avatar Aug 15 '20 11:08 jaredly