←back to thread

203 points dahlia | 2 comments | | HN request time: 0.476s | source
Show context
12_throw_away ◴[] No.45154518[source]
I like this advice, and yeah, I always try to make illegal states unrepresentable, possibly even to a fault.

The problem I run into here is - how do you create good error messages when you do this? If the user has passed you input with multiple problems, how do you build a list of everything that's wrong with it if the parser crashes out halfway through?

replies(6): >>45154618 #>>45154627 #>>45155518 #>>45155610 #>>45155934 #>>45156178 #
1. mark38848 ◴[] No.45156178[source]
Just use optparse-applicative in PureScript. Applicatives are great for this and the library gives it to you for free.
replies(1): >>45156700 #
2. bradrn ◴[] No.45156700[source]
> Just use optparse-applicative in PureScript.

Or in Haskell!