[Haskell-cafe] How to avoid keeping old data formats in your code?

Corentin Dupont corentin.dupont at gmail.com
Sun Dec 21 01:10:47 UTC 2014

On Sun, Dec 21, 2014 at 1:50 AM, Evan Laforge <qdunkan at gmail.com> wrote:

> On Sat, Dec 20, 2014 at 3:29 AM, Corentin Dupont
> <corentin.dupont at gmail.com> wrote:
> > Hi,
> > I didn't had so much luck with this question. The question was:
> > -> "How to avoid keeping old data formats in your code?"
> > Indeed those old data formats are often needed for retro-compatibility
> with
> > previous versions of your software.
> >
> > Say you have a data structure that is serialized in a file, and then you
> add
> > a field in a later version. You are obliged to keep both versions of the
> > data structure if you want to be able to read both versions of the file.
> > Potentially, if you update very often your structure between releases,
> you
> > are obliged to keep N versions of the data structure in your code.
> > See the exemple at: http://acid-state.seize.it/safecopy
> I just keep both versions.  It doesn't seem like too much hassle.  I
> move the old version to the Serialize module so modules that aren't
> concerned with serialization aren't cluttered.
> In the fully general case, I think there's no way around it.  But if
> you are just adding a field, or or changing a field to a super-type
> (e.g. 'a' becomes 'Maybe a') then you can trivially upgrade in place
> in the deserialization code.  Or you can use something like protobufs,
> which supports that kind of thing automatically.

What I'm thinking about is to put in the Setup.hs  some code that will
extract from GIT the older versions of the data structure. This way you are
able to keep only the last version of it in the HEAD, and still be able to
build migration code.
Do you know of any such custom build?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141221/44559481/attachment.html>

More information about the Haskell-Cafe mailing list