Now for the hard bit: variants. A variant node is just like
a tuple node, however the address of each branch is the same,
and the size of the node is the maximum of the branch sizes.

However: a variant node contains its own selector.
We don't know what that is, however a path going through
a variant has to have the same selector in it!

The only way to make this work, is for the path itself to split!
The branch of the path chosen is the one determined by
the discriminant in the data structure (you should think
about how a union match works).

So just to confirm: with tuples/arrays, a path is just the
composition of projections. You can chose any one of
the available projections i.e. components.

With a sum or variant type, you do not get a choice,
the data itself makes the choice, so this time you have
to supply multiple branches in the path.

So: with tuples the data structure is a tree and you pick
one of several possible paths. The set of all possible
paths here is a tree isomorphic to the data structure.

With variants it goes the other way! The path supplies
the choices, which are injections, and the data structure
picks from the alternate paths.

To make this one work exactly right .. the data structure for
paths and that for the typecode should probably have to be .. the SAME.
That's duality: control = codata, co-control = data.

An array: T ^ N of repeated products T * T * T .. T (N times)
has an analog: a repeated sum:  T * N = T + T + T...T (N times).


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to