News for hackers. Stuff that matters.
Re:Parse, Don't Validate (2019) by crvdgc on Tuesday March 07, 2023 @11:47AM (#35057510)
At least in Haskell this can be expressed as type classes. For each condition, you can create a (possibly empty) type class to guarantee that the condition is met. Then the call site type class constraints will be checked at compile time.
Re:Parse, Don't Validate (2019) by dwohnitmok on Tuesday March 07, 2023 @05:48PM (#35062416)
This doesn't really work because you still end up needing specific types for the output of every "parser" you have and then you still need a way of combining those types together.

Or you get the ability to forge evidence (e.g. you use the evidence provided by a parser for one integer as evidence for another).

This works better for dependency injection scenarios (the Has* pattern).