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.
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
alternate, better proposal
specify it in the export list
module Foo(closed Foo(..)) where
this has the advantage that you can create instances in several modules in a private implementation then export them closed in the public interface. it also fits in nicely with the idea of explicit namespaces in the ModuleSystem and the readonly modifier in the ReadonlyConstructors proposal.
- 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.
- a new language construct