On 10/28/19 3:35 PM, Mark Clements wrote:
I found that the following function is very useful for converting Ur/Web
data structures within JavaScript. This may be useful to others --
although has it been implemented elsewhere?

Thanks for sharing this code.  It's not obvious to me that this code belongs in a general library, since it seems to be based on some nontrivial assumptions about which Ur/Web types to handle. For instance, I think the code mishandles pairs (records with field names 1 and 2), incorrectly identifying them as lists.  It also seems to assume that all algebraic datatypes are option-style, which isn't true in general.  For instance, a term like A (B (C 7))) will apparently be flatted into 7, even if the constructors that were peeled away are conveying important information.

If one wants to support the full range of types, then I think it becomes clear that the original format is actually a pretty good choice!  At least, every one of the features that you flatten away was included explicitly to avoid ambiguity.  One possible exception is avoiding underscores at the beginnings of some record field names, but in that case I was motivated by uniformity (simple map to field names in JavaScript just by prepending underscores).

_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to