Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New Trait Syntax Coming.


I've on and off been complaining about how the current way of specifying
traits sucked for two reasons:

  - Tons of redundancy in the trait listings for type spec
  - The syntactic impossibility of specifying aux types for traits.

So, thanks to some talking with npnth on IRC, we've finally got a solution
to both issues. The '::' separator is now being pulled out of the type, and
instead will follow the whole type. It will take a trait list which appies
to the type variables in the preceeding type.

For example,

	generic rngrand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral))

becomes:

	 generic rngrand : (rng : rng#, lo : @a, hi : @a -> @a) :: numeric,integral @a

Which, to my eyes, is a lot nicer to read. Any number of traits can be
specified this way:

	generic foo : (x : @a, y : @b -> @c) :: numeric,integral @a, 
						numeric,integral @b, 
						iterable @c -> (@a, @b)

Note that the syntax for these types mirrors the syntax for impl
specifications. Also, thanks for tarug0's change to remove the need
for escaping the newlines after a ',', which makes wrapping these things
much nicer.

This change has already been mostly implemented, although some of the
wiring for aux types needs work. I'll bang on it a little bit more before
I put it somewhere accessible.

Happy new year!

-- 
    Ori Bernstein

Follow-Ups:
Re: New Trait Syntax Coming.Ori Bernstein <ori@xxxxxxxxxxxxxx>