[Haskell-cafe] How to avoid keeping old data formats in your code?
Roman Cheplyaka
roma at ro-che.info
Sun Dec 21 09:09:21 UTC 2014
Yeah, I agree with Evan, it does sound too complicated.
I also have a SafeCopy module where I keep my SafeCopy instances and old
versions of data types.
On 21/12/14 07:29, Evan Laforge wrote:
> I haven't heard of anything like that, it sounds too complicated for me.
> You still need to convert the old format to the new one, so it seems
> like you still need a bit of code for each version, which needs access
> to both old and new.
>
> On Dec 21, 2014 9:10 AM, "Corentin Dupont" <corentin.dupont at gmail.com
> <mailto:corentin.dupont at gmail.com>> wrote:
>
>
>
> On Sun, Dec 21, 2014 at 1:50 AM, Evan Laforge <qdunkan at gmail.com
> <mailto:qdunkan at gmail.com>> wrote:
>
> On Sat, Dec 20, 2014 at 3:29 AM, Corentin Dupont
> <corentin.dupont at gmail.com <mailto: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?
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list