Mercerenies / tfactor

0 stars 0 forks source link

Record Constructor #3

Closed Mercerenies closed 4 years ago

Mercerenies commented 4 years ago

It should be a compile error if you fail to define a constructor for your record. Defining multiple constructors is strange but fine, since you'll just get multiple functions that do the same thing correctly. But if you define no constructor, then your type is useless, so it should be an error.

Note that if you want an uninhabited type, you should be using sum types, which will be added to the language later, or explicitly using Nothing, the primitive uninhabited type. Record types are always inhabited, as long as each field is inhabited.

Mercerenies commented 4 years ago

10 is blocking, of course, since we lost our record syntax sugar.

Mercerenies commented 4 years ago

Closed as of abd1cda. The new record syntax (which is superficially similar to the old but desugars differently) performs a check for constructor count. Note that you must now have exactly one constructor, no more no less.