
Am Freitag, 21. Oktober 2005 11:22 schrieb Simon Marlow:
On 21 October 2005 08:43, Johannes Waldmann wrote:
Georg made the point that if a type is an instance of Show, then it should also be an instance of Read, and read . show == id
I rather think that this should be an explicit design requirement for Read/Show instances in the libraries, along with the requirement that the Show instance outputs valid Haskell syntax that can be included in a program (assuming appropriate imports, and possibly an appropriate type signature). Show is not for pretty-printing, it is for serialising.
Are there any Show instances that violate these requirements in the base/haskell98 packages currently?
AFAIK not, but the "new" Show instances of Data.Map and such like do not follow this requirement, since they introduce new syntax like: { a := b,..} and < 1,2,3 > ... Therefore I would suggest to change these instances to something like: show $ Data.Map.fromList [(1,"Foo"),(2,"Bar")] = "Data.Map.fromList [(1,\"Foo\"),(2,\"Bar\")]" It uses the ordinary List syntax and the constructing function is given as well. Cheers, Georg
Cheers, Simon _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries