I’ve tried the following, which don’t work.
exception MyError<'a> of 'a
exception 'a MyError of 'a
Do I have to use the long form:
type MyError<'a>(value) =
inherit System.Exception()
member this.Value : 'a = value
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to the specification, you have to use the long form. I didn’t find any explanation why that’s the case, but the grammar for exception declarations looks like this (and maybe also hints why the behavior is as you described):
This is quite interesting, because it suggests that exception declarations are more like discriminated union cases than like types. I guess you can think of an exception declaration…
…as a declaration adding new case to the standard
System.Exceptiontype (if it was a discriminated union). In this case you wouldn’t expect to be able to use a generic type parameter: