<br><br><div class="gmail_quote">On Tue, Jul 28, 2009 at 7:47 AM, Henry Laxen <span dir="ltr"><<a href="mailto:nadine.and.henry@pobox.com">nadine.and.henry@pobox.com</a>></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">Malcolm Wallace <Malcolm.Wallace <at> <a href="http://cs.york.ac.uk" target="_blank">cs.york.ac.uk</a>> writes:<br>
<br>
><br>
> > and perhaps use emacs to<br>
> > query-replace all the Foo1's back to Foo's<br>
><br>
> At least this bit can be avoided easily enough, by using<br>
> module qualification during the conversion process.<br>
><br>
> module Original (Foo(..)) where<br>
> data Foo = Foo { ... y :: Int } deriving ...<br>
><br>
> module New (Foo(..)) where<br>
> data Foo = Foo { ... y, z :: Int } deriving ...<br>
><br>
> module Convert where<br>
> import Original as Old<br>
> import New as New<br>
> newFoo :: Old.Foo -> New.Foo<br>
> newFoo old{..} = New.Foo { a=a, b=b, ... z=1 }<br>
><br>
> Finally rename module New.<br>
><br>
> Regards,<br>
> Malcolm<br>
><br>
<br>
</div>Thanks Malcolm, yes, that keeps me out of emacs, but the part I would really<br>
like to avoid is writing the New.Foo { a=a, b=b, ... z=1 } part, where the field<br>
names are many, long, and varied. Yes, I could cut and paste, but I'm hoping<br>
for a "better way." Thanks.</blockquote><div><br>I guess you could define:<br>type UpgradeFoo = (Foo, Int)<br><br>And then write the conversion code as a zip. upgradeFoo foos = zip foos [1..]<br><br>instance Show UpgradeFoo where ...<br>
<br>And then use the module trick to switch the code around?<br><br>Jason</div></div>