[r6rs-discuss] Enumerations

AndrevanTonder andre at het.brown.edu
Sun Oct 15 13:18:59 EDT 2006


I am not sure about the editors' intent as to the uses of enumerations, but one 
possible application I can imagine for it is for implementing closed sum types.

With this in mind, I'm thinking it would make a lot of sense to include an 
additional "enumeration-case" syntax, which is like "case" but with the tags 
restricted to a given enumeration.

For enumerations, enumeration-case is better than ordinary case, since

  - it can check exhaustiveness at compile-time
  - it can be compiled more efficiently

Something like enumeration-case really is a fundamental operation on 
"discriminated unions", providing the "discriminate" part, which is why most 
functional languages that have these types provide something like it.  More 
fundamentally, it is the ingredient that allows one to construct the missing 
arrow in the categorical definition of sum types as coproducts.

Cheers
Andre



More information about the r6rs-discuss mailing list