On 25/04/2015, at 3:44 AM, Shayne Fletcher wrote:
>
> On Fri, Apr 24, 2015 at 1:07 PM, john skaller <[email protected]>
> wrote:
> fun ravel[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2
>
> Neat function.
But I want
ravel[D1,C1,D2,C2,D3,C3,....D9,C9] (f1:D1->D2, f2:D2->C2 ...
f9:D9->C9): D1 * D2 *..D9 -> C1 *C2 .. C9;
I can do
str[D1,D2, ... D9] (p1:D1, p2:D2,.. p9:D9):string
given str:T->string which should be harder, since it involves polymorphic
recursion.
However the latter is just a string fold of the individual components.
However I don't think Ocaml can do this using any method,
and I'm not sure Haskell can either (in fact Haskell doesn't
even HAVE tuples AFAIK)
Felix and C++ can do it.
However I can't generalise it, even if you want a bool fold of some property,
i.e. fix the return type.
The ravel doesn't need any typeclass, it can be done with a purely
parametric function, but I can't figure it out :)
In Felix and C++ you have to use template instantiation to do
polymorphic recursion over a typeclass, you cannot do it
without a typeclass, and I see no way to do it in Felix at all.
In fact, short of making "ravel" a compiler intrinsic, I see no way
to do it. If I am having to add a compiler intrinsic or two, I would
want to add the most general ones.
Hence reading category theory papers to see what the most
general ones are.
--
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