<div>I would like to propose improving the Data instances for a number of currently completely opaque data types in the containers package, by using virtual constructors.</div><div><br></div><div>The instance for Data.Map already uses <font face="courier new, monospace">fromList</font> for <font face="courier new, monospace">gfoldl</font>, it just stops there.</div>
<div><br></div><div>Extending it to be able to gunfold and mention the name of that constructor would enable generic traversal libraries like uniplate, etc. to work over the contents of the Map, rather than bailing out in fear or crashing at the sight of a <font face="courier new, monospace">mkNoRepType</font>.</div>
<div><br></div><div>An example of the changes for Data.Map are highlighted below.</div><div><br></div><div><font face="courier new, monospace">instance (Data k, Data a, Ord k) =&gt; Data (Map k a) where</font></div><div><font face="courier new, monospace">  gfoldl f z m   = z fromList `f` toList m</font></div>
<div><font face="courier new, monospace" color="#ff0000" style="background-color:rgb(255,255,255)">  toConstr _     = fromListConstr</font></div><div><font face="courier new, monospace" color="#ff0000" style="background-color:rgb(255,255,255)">  gunfold k z c  = case constrIndex c of</font></div>
<div><font face="courier new, monospace" color="#ff0000" style="background-color:rgb(255,255,255)">    1 -&gt; k (z fromList)</font></div><div><font face="courier new, monospace" color="#ff0000" style="background-color:rgb(255,255,255)">    _ -&gt; error &quot;gunfold&quot;</font></div>
<div><font face="courier new, monospace" color="#ff0000" style="background-color:rgb(255,255,255)">  dataTypeOf _   = mapDataType</font></div><div><font face="courier new, monospace">  dataCast2 f    = gcast2 f</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace" color="#ff0000">fromListConstr :: Constr</font></div><div><font face="courier new, monospace" color="#ff0000">fromListConstr = mkConstr mapDataType &quot;fromList&quot; [] Prefix</font></div>
<div><font color="#ff0000"><br></font></div><div><font face="courier new, monospace" color="#ff0000">mapDataType :: DataType</font></div><div><font face="courier new, monospace" color="#ff0000">mapDataType = mkDataType &quot;Data.Map.Map&quot; [fromListConstr]</font></div>
<div><br></div><div><font face="arial, helvetica, sans-serif">I&#39;ve used this approach for years on my own libraries to great effect.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Discussion Period: 3 Weeks</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">(I added a week for ICFP)</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">-Edward</font></div>