pure icon indicating copy to clipboard operation
pure copied to clipboard

Impossible to define/raise user-defined exceptions

Open myreen opened this issue 2 years ago • 1 comments

This works:

data Error = Fail

main = Raise Subscript

While the following is rejected by the compiler:

data Error = Fail

main = Raise Fail

myreen avatar Jan 21 '23 12:01 myreen

As it stands, I believe type inference mostly supports user-defined exceptions - we would only need to update well-formedness checks of user-defined types to account for them. However, if I am not mistaken we decided to mimic ML-like languages and have a single, extensible exception type with a distinct declaration form to datatypes. This would change the example above to something like:

exception Fail

main = Raise Fail

I believe we don't currently have concrete syntax or abstract syntax forms for user-defined exceptions (only user-defined datatypes) so this may need to be added too.

hrutvik avatar Jan 21 '23 14:01 hrutvik