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

Corentin Dupont corentin.dupont at gmail.com
Sat Dec 20 11:29:25 UTC 2014


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


On Sun, Nov 30, 2014 at 1:04 PM, Corentin Dupont <corentin.dupont at gmail.com>
wrote:

> Hi the list,
> I have some question relative to data migration.
>
> Say you have a software in version A which save data in a file with format
> FA. Later, you update your software to version B, with data format FB.
> Now, if you want your version B of the software to be able to read data
> saved by version A, you're obliged to include FA in version B, together
> with some functions to translate from FA to FB.
>
> This is what I don't find elegant: you're obliged to keep old code (data
> formats) in your software.
> -> do you know of any way to avoid keeping old data formats (for
> retro-compatiblilty) in your code?
>
> In practice I use acid-state with safecopy:
> http://acid-state.seize.it/safecopy
> In this example you can see the problem: the author is obliged to keep old
> code (data structures) to maintain compatibility. Even worth, you might be
> obliged to suffix your data structure with a version number:
>
> data MyType_V1 = MyType_V1 Intdata MyType_V2 = MyType_V2 Integer
>
>
> Instead, I'm thinking of a process using GIT, or Cabal as a back-end.
> The idea would be to have an additional program (or library) specialized
> in the data migration of your main software. It would extract both version
> A and B from the repo, and then would compile an application capable of
> handling migrations from FA to FB.
>
> Does something like this exists (even outside of Haskell)?
>
> Cheers,
> Corentin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141220/62982fca/attachment.html>


More information about the Haskell-Cafe mailing list