|
|
|
|
|
by mirekrusin
1091 days ago
|
|
This can't be solved by static analysis - anything that crosses i/o boundary has to be asserted, refuted or predicated at runtime and you have libraries for it ie. [0] which doesn't throw (based on refutations which can be mapped to predicates without much cost and assertions) or [1] which throws (based on assertions). Predicates are the most performant but won't give you any indication on why it failed (ie. some nested field was null but was expected to be number etc). Refutations is great sweet spot as it's fast while giving information about error. Assertions are slow, but more often than not you don't care. You can map between any of them, but it doesn't make much sense for mapping ie. assertion to predicate as you'd be paying cost for nested try/catch while dropping error information. Refutation is great base for all 3. [0] https://github.com/preludejs/refute [1] https://github.com/appliedblockchain/assert-combinators |
|