pure
pure copied to clipboard
Impossible to define/raise user-defined exceptions
This works:
data Error = Fail
main = Raise Subscript
While the following is rejected by the compiler:
data Error = Fail
main = Raise Fail
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.