one icon indicating copy to clipboard operation
one copied to clipboard

Provide support in CoDL schemas for coproducts

Open propensive opened this issue 2 years ago • 1 comments

There should be a standard way of serializing a coproduct. For example, given,

sealed trait Node
case class File(path: Text) extends Node
case class Directory(path: Text, empty: Boolean) extends Node

we should write these as,

node file
  path /path/to/file
node directory
  empty yes
  path /path/to/directory/

where the parameter, file or directory would have the name type. The children of each should be checked for the particular type.

In a schema, the definitions for node file and node directory should (on some level) be as different as any other two distinct keywords, but consideration needs to be paid to the multiplicity of node... This is currently unresolved.

propensive avatar Aug 03 '23 08:08 propensive

As a suggestion for how to encode the example above in a schema, we could define:

node type:
node.file path
node.directory path empty

This indicates that the schema for the field node has a parameter called type which is indicated, by the :, to be a coproduct, and that a node which is a file should have a path parameter, while the node which is a directory should have a path and an empty parameter.

node.file and node.directory should behave like schemata for ordinary product types.

propensive avatar Jan 02 '24 15:01 propensive