Better error message for attempt to use : with operator declarations
Motivation
If a user is unfamiliar with the restriction on : , the message can lead them pretty far astray.
Example 1:
Prelude> let (:=) :: Show a => String -> a -> String
<interactive>:3:5:error:
Invalid type signature: (:=) :: ...
Should be of form <variable> :: <type>
Example 2:
> let (:=) a b = undefined
<interactive>:2:5: error:
Not in scope: data constructor ‘:=’
Perhaps you meant one of these:
variable ‘>=’ (imported from Prelude),
variable ‘==’ (imported from Prelude),
variable ‘/=’ (imported from Prelude)
> data Foo a b = a := b
>
Proposal
Less a proposal, and more a hypothesis. Example 2 above could maybe look like
> let (:=) a b = undefined
<interactive>:2:5: error:
Syntax restriction: ':' is reserved for data constructor operators
I say "more a hypothesis" because I'm not sure that message is precise enough.