You might want to look at the code out there that processes command line options by creating record setting functions, which then are foldl&#39;-ed to create an updated structure. See <a href="http://leiffrenzel.de/papers/commandline-options-in-haskell.html">http://leiffrenzel.de/papers/commandline-options-in-haskell.html</a> at the bottom of the page. I suspect you can easily create a conversion function (of functions) that does what you want.<br>
<br><div class="gmail_quote">On Mon, Nov 2, 2009 at 6:38 PM, Evan Laforge <span dir="ltr">&lt;<a href="mailto:qdunkan@gmail.com">qdunkan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mon, Nov 2, 2009 at 5:29 PM, Magicloud Magiclouds<br>
&lt;<a href="mailto:magicloud.magiclouds@gmail.com">magicloud.magiclouds@gmail.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;  Say I have something like this:<br>
&gt; [ Record { item = &quot;A1&quot;, value = &quot;0&quot; }<br>
&gt; , Record { item = &quot;B1&quot;, value = &quot;13&quot; }<br>
&gt; , Record { item = &quot;A2&quot;, value = &quot;2&quot; }<br>
&gt; , Record { item = &quot;B2&quot;, value = &quot;10&quot; } ]<br>
&gt;  How to convert it into:<br>
&gt; [ XXInfo { name = &quot;A&quot;, value1 = &quot;0&quot;, value2 = &quot;2&quot; }<br>
&gt; , XXInfo { name = &quot;B&quot;, value1 = &quot;13&quot;, value2 = &quot;10&quot; } ]<br>
&gt;  If XXInfo has a lot of members. And sometimes the original data<br>
&gt; might be not integrity.<br>
<br>
</div>This is a function from my library that I use a lot:<br>
<br>
-- | Group the unsorted list into @(key x, xs)@ where all @xs@ compare equal<br>
-- after @key@ is applied to them.  List is returned in sorted order.<br>
keyed_group_with :: (Ord b) =&gt; (a -&gt; b) -&gt; [a] -&gt; [(b, [a])]<br>
keyed_group_with key = map (\gs -&gt; (key (head gs), gs))<br>
    . groupBy ((==) `on` key) . sortBy (compare `on` key)<br>
<br>
-- You can use it thus, Left for errors of course:<br>
<br>
to_xx records = map convert (keyed_group_with item records)<br>
  where<br>
  convert (name, [Record _ v1, Record _ v2]]) = Right (XXInfo name v1 v2)<br>
  convert (name, records) = Left (name, records)<br>
<div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>