Re: want better error msg with Class Read

2002-11-07 Thread Dean Herington
On 7 Nov 2002, Alastair Reid wrote: > > Why not just define your own function, much like `read`, that > > produces a more suitable error message? > > readsPrec (i.e., the class method) doesn't report how far it got when > it reports failure. Yes, that's true if no prefix is a valid parse. In th

Re: want better error msg with Class Read

2002-11-07 Thread Johannes Waldmann
thanks for the suggestions along the lines of > Why not just define your own function, much like `read`, that produces a > more suitable error message? but in this case, I can't change the names and types (since the code is used by students in assignments that are already running) also, I want t

Re: want better error msg with Class Read

2002-11-07 Thread Alastair Reid
> Why not just define your own function, much like `read`, that > produces a more suitable error message? readsPrec (i.e., the class method) doesn't report how far it got when it reports failure. One could change that but this requires a change to the report and to the code compilers derive when

Re: want better error msg with Class Read

2002-11-07 Thread Dean Herington
On Thu, 7 Nov 2002, Johannes Waldmann wrote: > Dear all, I would welcome some advice > on getting better error messages > when using read :: Read a => a > > The problem is, `readsPrec' (the class method) > eats the longest feasible input prefix, > but when I call `read' (built-in prelude funct

Re: want better error msg with Class Read

2002-11-07 Thread Iavor S. Diatchki
hi, Johannes Waldmann wrote: This is correct, but I would like to show (in the error message) the prefix that *was* parsed as well. If `read' was a class method, I could override it. (Compare class Show, where there is the method `showsPrec', but since H98 (?), `show' is a class method as well.)

want better error msg with Class Read

2002-11-07 Thread Johannes Waldmann
Dear all, I would welcome some advice on getting better error messages when using read :: Read a => a The problem is, `readsPrec' (the class method) eats the longest feasible input prefix, but when I call `read' (built-in prelude function) on a string that does not parse, but that has a valid p