
Ross Paterson
On Tue, Jan 11, 2005 at 02:33:52PM +0200, Krasimir Angelov wrote:
Isn't it simpler to change the hooks type to something like:
PackageDescription -> IO PackageDescription
where the argument is the original description and the result is the possible updated one? This avoids the need of merging and simplifies the library code.
It replaces the need for merging with the need to check that they haven't changed the fields they weren't supposed to.
That's not too bad actually; definitely easier than merging, and conceptually simpler than defining either an AbstractPackageDescription (so we can actually tell when they've over-ridden a field) or a new buildinfo type. Though the advantage of the buildinfo type is that the inability to over-ride is enforced by the typechecker.
Other alternatives: - have the prehooks return a type other than PackageDescription, containing only the fields they're allowed to override. That means a different parser for buildinfo files. - introduce a variant of writePackageDescription that only writes the fields they're allowed to override (or only writes non-empty fields).
This second one is also quite easy and not a bad idea in general. peace, isaac