Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

edn is a mechanism for the conveyance of values. It is not a system for defining their semantics, types nor schemas.

That said, there should be no problem using edn to convey the values of types whose definitions are algebraic or recursive.

In particular:

"A tag may specify more than one format for the tagged element, e.g. both a string and a vector representation."

admits unions.

And the system itself nests arbitrarily, i.e. a tagged element can be defined in terms of others.

Values of this type:

    data Tree = Empty
              | Leaf Int
              | Node Tree Tree
could be conveyed like this:

    #tree/Tree Empty
    #tree/Tree [Leaf 42]
    #tree/Tree [Node #tree/Tree Empty, #tree/Tree [Leaf 42]]


Thanks for the info. Having written wire serialization from typed to untyped formats many times over the years, the limited expressivness of such formats has been an ongoing source of annoyance.


It is only me who has a strong feeling that this vector is an ugly construct here - [Node #tree/Tree Empty, #tree/Tree [Leaf 42]] and traditional S-Expression, which just describes an abstract structure - a list, not a particular data-structure - vector, is much better way?

And [Leaf 42]? What is this? Vector? Of elements of arbitrary type?

But a list of arbitrary elements is a quite natural and human-mind-friendly concept, and the Lisp notation, which intentionally omits any description of underlying representation, is a great idea.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: