|
From: john s. <sk...@us...> - 2015-04-28 01:29:06
|
This works:
fun \times[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2 =>
fun (x1:u1,x2:u2) => f1 x1, f2 x2;
fun \otimes[D1,C1,D,C] (f1:(D1->C1), f:(D->C)) : (D1 ** D) -> (C1 ** C) =>
fun (a:D1 ** D) : C1 ** C => match a with
| (x1,,x) => f1 x1,,f x
endmatch
;
fun i2s (x:int)=>x.str+"!";
fun i2i (x:int)=>x+1;
var fs = i2s,i2i,i2s,i2s;
var r = fs.0 \otimes fs.1 \otimes (fs.2 \times fs.3);
println$ r (1,2,3,4);
But it isn't pretty. The final \times is requires as the ground case
(and need parens because of grammar issues, \otimes is right assoc).
However \prod (f,g,h) still can't be defined, i have ravel (f,g,h) in the
library for up to 5 cases.
--
john skaller
sk...@us...
http://felix-lang.org
|