metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.46k stars 208 forks source link

Add schema simplification / worker optimization #815

Open bsless opened 1 year ago

bsless commented 1 year ago

Schemas that contain choice need to backtrack when validation or coercion fail. As schemas get larger and more complicated, this can result in redundant work.

Proposed solution, using boolean algebra notation:

( A B ) + (A C) -> A (B +C)

This can be done trivially for validation, and with some care for transformation as well.

Users might want to trade off compile time for run time, so it should be configurable.

Also see: https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm

opqdonut commented 1 year ago

See also: https://github.com/miikka/boolean-simplifier