wiki:ClosedClasses

Version 1 (modified by john@…, 8 years ago) (diff)

--

closed classes

closed classes are ones for which no more instances may be defined. these can be used to produce better error messages and to refine types.

proposal

allow the closed keyword right after class.

class closed ... where
    ...

this will mean that even if the class is exported no one may declare more instances for it

pro

  • compilers based on jhc's class system can take very good advantage of such declarations when optimizing.
  • This sort of thing is often needed when doing phantom type and type class tricks.
  • this is available in helium in order to increase the accuracy of error messages to good effect.
  • syntax is similar to 'class alias' and 'class overlapping' proposals

con

  • a new language construct