[Haskell-cafe] handling multiple versions of a data structure
akamaus at gmail.com
Thu Dec 16 19:26:18 CET 2010
while developing my neural net simulator I stumbled upon a problem.
I have a data type NeuralNet and use Show and Read instances for saving
and loading configurations. As time passed, I changed the data type, so
the program can no longer load files saved in previous versions.
I want fix it. My current idea looks as follows. I'm going to create a
bunch of types NN1, NN2, NN3..NNn for different versions and write
converters c12 :: N1 -> N2, c23 :: N2 -> N3 and so on.
But how to organize the whole process of parsing String into NNn so it's
easy to change formats?
Something based on using a list of parsers
[read, c43 . read, c43 . c23 . read, c43, c23 . c12 . read, c43 . c32 .
c21 . read]
looks rather verbose and grows quadratically with N.
I'm sure there must be a more elegant way. Any ideas?
More information about the Haskell-Cafe