Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: