diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

data/case must have at least one constructor/case #65

Closed davidweichiang closed 1 year ago

davidweichiang commented 2 years ago

It was already a type error for case to have zero cases (I think because type inference wouldn't know what to do with zero cases), but now it's also a parse error. It's also a parse error for data to have zero constructors in the first place.

Closes #52.

davidweichiang commented 2 years ago

@ccshan Do you have time to review instead? I think this is an easy one.

ccshan commented 1 year ago

@ccshan Do you have time to review instead? I think this is an easy one.

Hi hi, thanks. Your code is fine! I noticed that | was not required between consecutive branches, but I think it should be. If you don't mind, let me make it required here.

davidweichiang commented 1 year ago

Thanks! I realized later that it is possible for the -c option to generate datatypes with zero cases. Towards the end of making the compiler accept its own -c output, I wonder if we should allow data Foo = ;.

ccshan commented 1 year ago

FWIW, in GHC Haskell it's notated data Foo and case e of {}

davidweichiang commented 1 year ago

case e of {} always raises an exception, right? Also it seems to require -XEmptyCase.