Open gvergnaud opened 1 year ago
Owesome! 🎉
I love the Do
Let
Ap
utils. makes everything simple to grasp, i think that nothing would prevent my implementation to also have it since it's just adding the ability to Sequence
parsing to take a Fn that returns a Parser.
Our implementations are almost the same. The difference is only :
mapError
to create meaningful messages.I think the debate wether introspection is a nice or not is not my concern, i could let this feature go away. i personnally think it allows easier error handling out of the box. But maybe adding mapError
to customize errors is fine.
And about object vs tuple as the returned type of the parser, i prefer readbility for the user. I think object is also faster. But maybe i'm wrong.
Here are some minor things that are easily fixable :
mapError
to create a meaninfull message. Indeed, current implementation yields cryptic union of all possible literals that is not user friendly.mapError
to make better error messagesWords
should match common definition : [a-zA-Z_][0-9a-za-Z]*
But instead of diverging more. I think we should try to merge our implementations. I don't like spliting the effort here since both are almost identical.
Since one type-level parser implementation is worth a thousand words, here is how to implement a JSON parser:
And here is how to use it: