Am 21.10.2004 um 09:55 schrieb Johannes Waldmann:
turns out that check1 and check2 work, but check0 will not (I thought it would). The implementation (in the Prelude) seems to think that "]" (in check0) could possibly be the beginning of a list element.
This is just a problem of non-deterministic parsing. The prelude's read function always explores all possible parses (in order to flag ambiguous ones). Thus, at the beginning of the list it will always try to match the input against ] and an element causing check0 to fail. For later elements there is no problem because the choice is between ] and ,. Because of that, calling error in one of your read functions seems a bad idea. In fact, returning an empty list is the right way to return an error in the prelude's parsing framework. If you want something different (e.g., because you want better error messages) you should not be using the prelude's read function. IMHO, the prelude's Read class for that reason is quite useless -- except for converting strings into numbers. Wolfgang