fsharp
fsharp copied to clipboard
Improve compilation error when parametrizing non-partial active patterns
As I understand it, non-partial active patterns may not have extra parameters:
let inline (|Lt|Gt|Eq|) compareWith x =
if x < compareWith then Lt
elif x > compareWith then Gt
else Eq
match 2 with
| Lt 3 -> ()
//^^^^
// Type mismatch. Expecting a 'int -> Choice<'a,'b,'c>' but given a
// 'int -> int -> Choice<unit,unit,unit>' The type 'Choice<'a,'b,'c>'
// does not match the type 'int -> Choice<unit,unit,unit>'
The error is very confusing. It would be better to have an error on the active pattern definition itself.