3 ms·
> And pray tell how do you verify that the parser is actually correct? How strict can you get? The idea presented in the article is that the data type of the p
by klodolph 6y ago
> And pray tell how do you verify that the parser is actually correct? How strict can you get?
The idea presented in the article is that the data type of the parser output ensures that your invariants are satisfied. It’s not a panacea for solving every possible problem with input validation, it’s more of an alternative technique that gives you much better assurances that some of the invariants you think should be satisfied, are satisfied.
- cptskippy 6y agoThe point of input validation is to fail early, not to ensure the function executes. Returning an empty list when the input is an invalid list sounds like a really bad idea. What if the function is deleteWhereNotIn( list param )? That empty list just deleted everything.
- lambda_obrien 6y agoThe original article was in a Haskell context, where you'd use a Maybe or Either to prevent that sort of mistake.
- a1369209993 6y ago> The point of input validation is to fail early, not to ensure the function executes. > What if the function is deleteWhereNotIn( list param )? error: could not assign `param` = `mungeList foo` note: failed to match `List a` <= `Either SomeError (List b)` note: failed to match `List` <= `Either SomeError`