<br><br><div class="gmail_quote">2010/10/9 André Batista Martins <span dir="ltr"><<a href="mailto:andre_bm@netcabo.pt">andre_bm@netcabo.pt</a>></span> Said:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>Might have not been clear, but i will try illustrate .<div class="im"><br>f:: a-> b -> c -> (b,(c,a))<br>f1 :: c -> a -> d</div></blockquote><div>-----------------------------<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"></div><br></blockquote></div>I think I would attack this with glue consisting of:<br><br>comb f f1 a b c = arr (\(a,b,c) -> f a b c) >>> arr (\(b,(c,a))) ->f1 c a) $ (a,b,c)<br><br>and yes, have to agree that easier to roll your own if only a few functions are like this..<br>
but should be able to parse the type signatures of the functions involved and write a program to automate this process.. using this format as a template.. <br><br>Actually if you just set it to take all the variables prior to last (->) in sig you can put them<br>
put them together in an uncurried format.. for instance the "a -> b -> c" portion would become always \(a,b,c) -> then the function so arr (\(a,b,c) -> f a b c) then the term (output) would be the last term in this case (b,(c,a) add that with a "->" between to give that to first part of another lambda construction (\(c,a) -> f1 c a) ... arrowizing the whole thing with arr (first lambda) >>> arr (second lambda) $ and a tuple from all but the last variables in all cases of first function ... so for f it would be (a,b,c). if for some odd reason it was a single it would just become ((a)) an added parenthesis, which would not hurt a thing for the case where it was a sig like f :: a -> b<br>
<br>So for your case it becomes as shown above:<br>comb f f1 a b c = arr (\(a,b,c) -> f a b c) >>> arr (\(b,(c,a))) ->f1 c a) $ (a,b,c)<br>and say for:<br><br>f :: a -> (b,c)<br>f1:: b -> d<br><br>(\(a) -> f a) >>> (\(b,c) -> f1 b) $ (a) <- it just harmlessly adds the '( ' and ')' around the 'a' even though it doesn't need it as the only parameter prior to the last '->'. <br>
<br>This is probably clear as mud, on first look, but I think a way forward in automating from <br>this is possible.. I am sure of it.. but it would be at the source code level and a string parse and output from that .. <br>
<br>cheers,<br>gene<br><br><br>