Haskell report typo (bad law for readsPrec)

Wolfgang Lux wlux@uni-muenster.de
Wed, 20 Jun 2001 11:29:39 +0200

Patrik Jansson wrote

> [Typo - you mean:]
>       head (readsPrec d (showsPrec d x "")) == (x,"")


> Both formulations look OK to me, but neither is an essential change and
> there are many other small variations possible with slight semantical
> differences. One example is
>       (x,"") `elem` readsPrec d (showsPrec d x "")
> And already the current (proposed) formulation is most likely impossible
> to satisfy if the element x contains bottoms somewhere inside. (Example:
> try to show and read the string (undefined : "hello").)

True, but in any case it seems sensible to me to require that readsPrec should
actually process the input string. With your proposal

> > |      fst (head (readsPrec d (showsPrec d x ""))) == x

it would be possible to return [(42,"42")] for the expression
readsPrec 0 (showsPrec 0 42 "").


Wolfgang Lux				  Phone: +49-251-83-38263
Institut fuer Wirtschaftinformatik	    FAX: +49-251-83-38259
Universitaet Muenster		      Email: wlux@uni-muenster.de