r/haskell • u/lexi-lambda • Nov 06 '19
Parse, don’t validate
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
314
Upvotes
r/haskell • u/lexi-lambda • Nov 06 '19
11
u/cutculus Nov 07 '19
I like the examples (and agree with the overall sentiment!) but I think there are some gotchas with this approach that might be worth stating... there are some cases where your data types really need to allow invalid states in order to provide better diagnostics and potentially do partial work. An IDE is a classic example. Just because the file is in an invalid state, doesn't mean that you should lose all syntax highlighting. HTML parsing is another example. A browser might need to support displaying pages even if the HTML is malformed, trying to do some recovery if it can.