On Sun, 2006-09-03 at 19:37 -0400, Peter Tanski wrote:
> typedef typecase[co,clst] co clst => clst
> endcase a1 = company;
> ---------------------
> This last *is* the intended form for the generic type (compare with
> the Point example at the beginning of Barry Jay's paper. Anyway, if
> it is possible to use this last (intended) form for the generic type,
> we could write a typecase for a union of a certain form, such as a
> single-constructor union:
> ---------------------
> typecase[c,a] c a => a endcase a1;
> ---------------------
> Or we could make a generic traversal function, as you did in your
> example. Do you think that's possible?
Yes, in fact this is universal, since union constructors
in Felix can only have one argument, it covers them all.
Although union constructors can be used as functions directly
(unlike Ocaml), they can't really have curry form as in Haskell.
I mean, a variant can certainly accept a function argument:
union X = | V of d -> c;
but that's not the same as
union X = | V of d of c
which would allow
V d' c'
as a constructor. You can use eta expansion to fix this
for construction:
union X = V of d * c;
fun mkV (x:d) (y:c) => V (d,c);
but of course you can't do a partial pattern match on
mkV x
because it isn't an X, but a d->X.
Hmm .. it would be interesting to fix this, but it requires
a combined match and typematch.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language