[r6rs-discuss] Enumerations

From: AndrevanTonder <andre>
Date: Sun Oct 15 13:21:31 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
Received on Sun Oct 15 2006 - 13:18:59 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC