plutus
plutus copied to clipboard
add support for lists, pairs and data to concrete syntax
Describe the feature you'd like
The parser and pretty printer do not properly support lists, pairs and data.
I would like to use the syntax
con (list bool) [True, False, True]
and con (list (pair integer bool)) [(1, True), (500000, False), (0, True)]
for lists and pairs.
@SchmErik proposes the following syntax for data which I think is nice:
(program 0.0.0 (con data {
Map [ (ByteString #0123, Integer 12345),
(ByteString #456789, Integer 789453),
(ByteString #0ABCDE, Integer 12364689486)]
}))
Note that the concrete syntax is not used on chain, is not guaranteed to be production quality, and is subject to change. For testing production code, the flat representation should be used. Concrete syntax is useful for pedagogical and exploratory purposes.
Describe alternatives you've considered
I suppose one could write something more json like inside the curly brackets for data.
I'm fine with the syntax for pairs and lists. Although it occurs to me that if we really wanted to stick to our sexp guns we could have (pair x y) and (list x y z) as term syntax (punning with the type syntax).
I don't have very good suggestions for data...
Proposed syntax needs to deal with nested examples when it comes to polymorphic data. e.g.
(con (list (list (list integer))) [[[1], []], [[], [2,3]]])
This is a duplicate of #4751. This one is older, but the other one has a bit more discussion, so I'm going to close this issue and copy all the messages to the other thread verbatim, so that they don't get lost.