Open BebeSparkelSparkel opened 4 years ago
@BebeSparkelSparkel I was looking at your DXF example and noticed something. You don't capture the whitespace for the integer lines in the parsed representation. When printing, how much leading whitespace should the numbers be padded with?
The interesting thing is that I was trying to use the many
combinator to parse out the whitespace, but the types simply wouldn't let me.
@masaeedu Whitespace of the integer lines has always been the same. It seems like we should be able to choose if we want to conserve whitespace or not because it may or may not be important, because it could be a lot of overhead to deal with and it could be hard to optimize speed and space.
For many
, I put in the biMany
in there but it would be cool to allow the parser combinators like many
.
@BebeSparkelSparkel What I mean regarding the many
thing is that while snd <$> many space /\ nat
makes for a fine parser of lines that have some leading whitespace and then a natural number, it doesn't actually work as a biparser. Specifically, if all you're parsing out is a natural number, you have no idea how much space to pad it with when you're printing it back out (unless this number is fixed somehow, or you hang on to the whitespace in the parsed representation).
Regarding:
Whitespace of the integer lines has always been the same.
I see a few lines in there where the leading whitespace is different. For example you have two spaces in " 9"
but one space in " 70"
and none in "160"
.
If the rule here is that the number lines are always exactly three characters, that works, but we need some kind of rule so that when you're printing out your number you know what to do.
Sorry, you are correct. It is always a 3 digit number with whitespace if there is no digit there.
I was thinking there could be some biparser constructor that is sort of like prism
Please put in some input result tests for your biparsing needs.
Just add them to tests and try to explain yourself as best as possible.