Fork me on GitHub
#malli
<
2021-05-29
>
Adam Helins09:05:39

Why is :ref not allowed in seqex? Are they truly incompatible or is it a goal implementing it later?

ikitommi09:05:33

There was a reason, @U4MB6UKDL should know thay

nilern13:06:53

Allowing :ref would incidentally make context-free parsing possible, like in Spec. But that is much harder to specify and implement cleanly and efficiently e.g. I think left recursion drives Spec to a stack overflow. The implementation could be elegantly extended to do GLL parsing, like Instaparse. But supporting all CFG:s means supporting the ambiguous ones as well, so parse would have to return a seq of plausible parse trees etc. One could argue ambiguous schemas are undesirable anyway, but the best way to ban those is (some extension of) LR parsing and nobody wants to deal with shift-reduce conflicts either and many grammars are unambiguous but not LR (without manual mangling) 😩 I would say from a theoretical perspective there are some satisfactory options but it is not simply a matter of allowing :ref. From a UX standpoint it comes down to most programmers happily wielding regex but quickly getting confused with YACC (and even Instaparse when it comes to ambiguous grammars).

Adam Helins16:06:00

@U4MB6UKDL That's a very thorough answer, thanks!

ikitommi09:05:42

@eoliphant kinda like dependent schemas? I guess we could have a formal way of doing that, e.g. schema value -> schema mapping. There is already content-dependent schemas and some ways to do that at validation time

ikitommi09:05:23

for the simple key, :or or :multi would work too

ikitommi09:05:57

1. ... or just :and with a :fn constraint

ikitommi09:05:33

but with dependent schemas you could ask "what is the derived schema for this given value, against this (conditional) schema". Would be great.

ikitommi09:05:33

but with dependent schemas you could ask "what is the derived schema for this given value, against this (conditional) schema". Would be great.

eoliphant13:05:50

yeah i’d played around with :or and :multi, I guess :fn is the only route, was just trying to still leverage the ‘declared’ type