Comment by wwalexander
4 hours ago
> It's the same thing. In the latter case, something has validated that your NonEmpty has a first and a last element.
No, it has parsed it into a structure that structurally has at least one element, not just the promise that there ought to be one. From the original “Parse, don’t validate” article:
data NonEmpty a = a :| [a]
> your type still permits {name: "\0\0\0\0\0\0", host: "!"}
I actually originally wrote it with an array of EmailNameCharacters, etc but didn’t want to overcomplicate the example.
No comments yet
Contribute on Hacker News ↗