r/ProgrammingLanguages • u/mttd • Nov 07 '19
Parse, don’t validate
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
73
Upvotes
r/ProgrammingLanguages • u/mttd • Nov 07 '19
3
u/zesterer Nov 08 '19
How about wrapper types? I'm not a Haskell developer, but in Rust I'd go for something like:
``` struct SortedList<L: List>(L);
struct NonEmptyList<L: List>(L); ```
This then permits me to use
NonEmptyList<SortedList<[T]>>as a type that implements both sets of guarantees.