[Haskell] Read Instances for Data.Map and Data.Set

Georg Martius martius at informatik.uni-leipzig.de
Fri Oct 21 05:50:33 EDT 2005

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 


> Cheers,
> 	Simon
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

Georg Martius
Institut für Informatik
Universität Leipzig
Tel.: +49 341 9732284
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/libraries/attachments/20051021/fccfa262/attachment.bin

More information about the Libraries mailing list