mrkkrp/megaparsec

Why is `Stream s` requiring `Ord (Token s)`?

janmasrovira opened this issue · 8 comments

To me it is not intuitive to require that tokens of a stream must have an order. I guess there must be a reason for that, but I haven't been able to find it by reading the documentation of the library.

See #451

I see.
Have you considered using HashSet instead of Set , then requiring Hashable and Eq instead of Ord?

I think it would be good for the library to be able to parse streams of tokens which have no sensible Ord definition.

I'd say that the main problem right now is compatibility. Besides, if you can define Hashable for your type, then you probably can also define some kind of Ord by doing comparisons on the resulting hashes, right?

Besides, if you can define Hashable for your type, then you probably can also define some kind of Ord by doing comparisons on the resulting hashes, right?

Yes, this is a good idea.

I have a followup question. Is the Ord constraint only used for error reporting, or is it a structural part of the parsing algorithm?

It is used to construct ParseError values (which uses Sets) which is hardwired in the library, but not for parse error rendering/reporting per se.

Closing for now.

Thank you for your answers @mrkkrp!