<br><br><div class="gmail_quote">On Mon, Jun 1, 2009 at 12:20 PM, Ralf Laemmel <span dir="ltr"><<a href="mailto:rlaemmel@gmail.com">rlaemmel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mon, Jun 1, 2009 at 8:20 PM, David Fox <<a href="mailto:david@seereason.com">david@seereason.com</a>> wrote:<br>
> Is there a Scrap Your Boilerplate guru out there who could whip up a three<br>
> argument version of gzip for me?<br>
<br>
</div>This can be done of course (untested but type-checked code follows).<br>
Left wondering what the scenario might be :-)<br>
<br>
Ralf<br>
<br>
import Prelude hiding (GT)<br>
import Data.Generics<br>
<br>
-- As originally defined: Twin map for transformation<br>
gzipWithT2 :: GenericQ (GenericT) -> GenericQ (GenericT)<br>
gzipWithT2 f x y = case gmapAccumT perkid funs y of<br>
([], c) -> c<br>
_ -> error "gzipWithT2"<br>
where<br>
perkid a d = (tail a, unGT (head a) d)<br>
funs = gmapQ (\k -> GT (f k)) x<br>
<br>
-- For three args now<br>
gzipWithT3 :: GenericQ (GenericQ (GenericT)) -> GenericQ (GenericQ (GenericT))<br>
gzipWithT3 f x y z = case gmapAccumT perkid funs' z of<br>
([], c) -> c<br>
_ -> error "gzipWithT3"<br>
where<br>
perkid a d = (tail a, unGT (head a) d)<br>
funs' = case gmapAccumQ perkid' funs y of<br>
([], q) -> q<br>
_ -> error "gzipWithT3"<br>
where<br>
perkid' a d = (tail a, unGQ (head a) d)<br>
funs = gmapQ (\k -> (GQ (\k' -> GT (f k k')))) x<br>
</blockquote></div><br>Thank you! What I have in mind is three way merging - you have two revisions based on the same original value, and you need to decide whether they can be merged automatically or they need to be merged by a user. You only have a real conflict when both revisions differ from the original and from each other.<br>
<br>-david<br><br>