On Sat, Nov 16, 2013 at 12:30 PM, Gábor Lehel <[email protected]> wrote:
> What I was wondering in the parentheses above is whether you could have
> something `type<type> MT<type<type>>`. In other words whether "templates
> can return templates", which you can't do in C++ but can in Haskell. This
> is closely tied to the question about currying and partial application at
> the type level. If we do have that, then the above is completely equivalent
> to `type MT<type<type>, type>` (just like `(* -> *) -> * -> *` and `(* ->
> *) -> (* -> *)` are the same thing in Haskell), though it might be nicer to
> write it one way or the other in different cases.
>
I just noticed that if this is true, then it actually unifies your proposal
for syntax with my earlier one. What happens is that `type F<type>` is a
type-level unary function, and `type<type> F` is a nullary function
returning a unary function, and we can consider these to be equivalent.
This is like how, thanks to the absence of side effects and such, Haskell
gets to elide the difference between nullary functions and plain values.
Rust's type level shares these kind of properties with Haskell's value
level, so this is kinda appealing. On the other hand, maybe the added
flexibility doesn't actually gain us anything except a taller learning
curve. But in either case, it's really cool to realize that our two
proposals are not just ad hoc stylistic choices, but in fact both have
sensible theoretical interpretations in the same system with a
correspondence between them.
To recap the options:
1. Everything must be on the left:
type<type<type>, type> MT
2. All parameters must be on the right, and only the final return kind on
the left:
type MT<type<type>, type>
3. Both are legal and equivalent, along with forms in between the two
extremes:
type<type> MT<type<type>>
--
Your ship was destroyed in a monadic eruption.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev