I am stumped at the moment defining certain operators on tuples.
If you look at src/lib/std/datatype/tuple.flx you will see there is general way
to apply a function
T -> K
T * T -> K
to a tuple, where K is a constant type. For example
T -> string // Str
T * T -> bool // Eq
are defined. See also that we can do
F T0, F T1 ... F TN -> F (T0, T1 .. TN)
in some cases, such as in src/lib/std/algebra/set.flx we can "almost" define
\otimes (set_form[T0], set_form[T1],.. set_form[TN] )
I say almost because actually we can do
var x = { x: int | x > 0} \otimes { x: double | x > 0.0} \otimes { x:string | x
> "H" };
println$ (24,3.2,"Hello") \in x;
but this is right associative. What I REALLY want to define is:
\otimes (s1,s2,s3);
but this doesn't work. It would be a "generic fold".
Another example:
//$ parallel composition
// notation: f \times g
fun ravel[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2 =>
fun (x1:u1,x2:u2) => f1 x1, f2 x2;
This function takes a pair of functions, and makes them into a single
function accepting the product of the domains as its domain and the
product of its codomains as the codomain.
It's easy to define this for 3 or 4 components, but I want to define it
for an *arbitrary* length tuple.
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language