Introduce TryParse
?
#125
Replies: 3 comments 17 replies
-
@randomeizer has had some cool parser suggestions as well. Have you seen hsdoc/parse-throws which includes a Try parser? You two might be able to share some ideas. |
Beta Was this translation helpful? Give feedback.
-
This is indeed a great idea. There is a |
Beta Was this translation helpful? Give feedback.
-
We actually added a [Edit: release notes updated with this and a few other changes/additions, thanks!]
We've now specifically added documentation advising against this approach, now that we use rethrowing parsers:
This is neat way of approaching things with builders! As I also replied here, we're definitely open to tweaking the ergonomics here, but it'd be a good idea to figure out a style guide for when to use parser builders over parser modifiers. |
Beta Was this translation helpful? Give feedback.
-
Feature Suggestion: Wondering if you'd contemplate a variant of
Parse { }
that takes a fallback value?I know you have suggested this approach:
In my own project I made a type called
TryParse
that is a helper wrapper of this.Usage:
Implentation:
I realise I'm missing the convenience of
Parse(User.init) { }
. I respect any suggestions or bikeshedding of names.Beta Was this translation helpful? Give feedback.
All reactions