
Neil Mitchell schrieb:
You seem to be describing SYB and not knowing it: http://homepages.cwi.nl/~ralf/syb1/
That basically does exactly what you've requested, in terms of traversing all items when only one matters.
Yup, that's exactly what I was looking for. Actually I had seen it a while ago, but didn't remember it now. Thanks. One thing that might become a problem is that the "Scrap your boilerplate" approach seems to work only in GHC. There's nothing wrong with GHC, but it sounds like I'm committing to a specific compiler right from the start. I'd like to keep the number of choices as high as possible... and besides, if the compiler gives me an error message, or the generated code does unexpected things, I'd like to have the possibility to cross-check with a different compiler. So have other compilers picked up SYB support yet? It might be not feasible though. The papers mention that you can't serialize (well, actually unserialize) function values with it. For the envisioned update-through-marshalling process, this would prevent me from ever using function values in data that needs to be persistent, and that's quite a harsh restriction.
That said, serialisation is still a hard problem - think long and hard before picking a data format.
What would be the problems of choosing the wrong one?
With Yhc.Core I used Drift to derve Binary instances, keep a version tag, and if the version tags mismatch refuse to load the data.
Links? Regards, Jo