Cant decide whether this list is appropriate for questions related to generics usage, or only to generics design?&nbsp; So let me know if I should use <a href="mailto:haskell@haskell.org">haskell@haskell.org</a> instead, but on the other hand I figure you guys are the experts :-)
<br><br>Trying to write an xmlserialization function for arbitrary (Data) objects, and not requiring a DTD or a code generation step.<br><br>It&#39;s possible in C# so it really ought to be possible in Haskell ;-)<br><br>
xml serialization is pretty easy, see section 9.1.1 of <a href="http://www.haskell.org/haskellwiki/HXT">http://www.haskell.org/haskellwiki/HXT</a><br><br>On the other hand deserialization is still a work in progress.&nbsp; At least I&#39;m not smart enough to figure it out, and nothing comes up in Google.
<br><br>The xml parsing bit is done, see section 9.1.2 of <a href="http://www.haskell.org/haskellwiki/HXT">http://www.haskell.org/haskellwiki/HXT</a><br><br>So, we can get a list of pairs/triples etc containing the data of our choice, such as field names, field values (in string format), data types, constructors, etc.
<br><br>What&#39;s remaining is to take makeConstrM, our final data type, and the list of field values, and to create the final object.<br><br>Here&#39;s my non-working attempt at this bit so far. Most of the working bits come from a demonstration by kpreid in irc yesterday night of using makeConstrM with a pair of strings.&nbsp; The rest of the code is my feeble attempt to get this working for the Config custom data type.
<br><br>runM&#39; :: (MonadState [String] m, Monad m, Data a) =&gt; m a
<br>runM&#39; = do<br>&nbsp;&nbsp; value &lt;- gets head<br>&nbsp;&nbsp; modify tail<br>&nbsp;&nbsp; -- then one of: (pick the non-working function of your choice ;-)&nbsp; :<br>&nbsp;&nbsp; -- return read (fromJust value)<br>&nbsp;&nbsp; -- return (fromJust $ cast value )<br>

&nbsp;&nbsp; -- return (fst $ head $ gread( &quot;(&quot; ++ value ++ &quot;)&quot; ) )<br>&nbsp;&nbsp; -- return (fromConstrM runM&#39; constr)<br>&nbsp;&nbsp; -- return (fromConstr contr)<br><br>testConstrM&#39; :: (Read a, Data a, Read c, Read b, Data b, Data c) =&gt; [String] -&gt; a -&gt; (b,c)
<br>testConstrM&#39; fieldvalues object = evalState( fromConstrM runM&#39; (toConstr object) ) fieldvalues<br><br>data Config = Config{ name :: String, age :: Int }<br>&nbsp;&nbsp; deriving( Data, Show, Typeable, Ord, Eq, Read )<br>

createConfig = Config &quot;blah&quot; 3<br><br>test = testConstrM&#39; [&quot;qsdfqsdf&quot;, &quot;7&quot;] createConfig<br><br>Note that whilst I&#39;m a total Haskell newbie (this is week 2), I&#39;ve used Reflection extensively in other languages, eg wrote a fast async rpc layer over guaranteed udp for C# 
<a href="http://metaverse.svn.sourceforge.net/viewvc/metaverse/Trunk/Source/Metaverse.Networking/">http://metaverse.svn.sourceforge.net/viewvc/metaverse/Trunk/Source/Metaverse.Networking/</a> , so I know more or less what I&#39;m aiming for, just not exactly how to do it ;-)
<br><br>