> 
> There is probably another way to do this, certainly with meta types
> one should be able to do:
> 
>       kind INT = ZERO | SUCC of INT
> 
> and then you can use the INT
> 
>       SUCC (SUCC (SUCC ZERO))
> 
> for three, and do subtraction by a recursive kindmatch. But Felix
> meta-typing system isn't strong enough to do that at present.


So I have wanted to improve the kinding system for some time.

The prospects are daunting, to do this in general.
Adding a kind construction like the above leaves open the question,
what about structures? The kind above is the same as a Felix union
up one level, so we shouldn't we have structs as well?

And what about anonymous kinds like tuples and sums?

Felix actually already has kinding tuples! The only problem is
that they only work on one kind: the kind TYPE. In fact Felix
already has kinding functions: here is one of them:

        typedef fun swap(T:TYPE, U: TYPE) : TYPE => U * T;

        var x: swap (int , long) = 1L, 2;
        println$ x;

In particular this works too:

        typedef pair = int, long;
        var y : swap pair = 1L, 2;      
        println$ y;


Now I ask, what is "pair"? It is NOT a type, it is in fact
a type tuple: a pair of types. So what kind is that?
It is in fact of kind:

        TYPE * TYPE

and the functor swap is of kind:

        TYPE * TYPE -> TYPE

which just says "give me a pair of types and I'll give you
a type back" which in fact the reversed product of the argument
types.

The point is Felix already has products of the kind TYPE
and indeed functions.

All types have kind TYPE. The next level up from kinds are
called sorts. In the compiler TYPE is actually written

        TYPE 0

and so it has the sort

        TYPE 1

Already we have the core infinite hierarchy. And we have a typematch which
can recognize product and function types as well as type constants,
but not yet any sums.

There are two options for progress here.

1. Add the kind declaration to add new kinds as sums.

2. Just add the two new kinds we desperately need right now:

        (a) BOOL
        (b) INT


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




------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to