ApplicativeDo: Add compiler message about irrefutable pattern matches and Monad constraints
Add an error message to the compiler when:
- A user-provided signature specifies a Functor/Applicative constraint
- ApplicativeDo desugaring requires a Monad constraint
- Adding a lazy pattern match could allow the Functor/Applicative constraint
bgamari suggests something like the following message:
ApplicativeDo is enabled yet Monad is required due to irrefutable pattern match; perhaps you want to make the match refutable by adding a ~?
In GHC 8.2.1, ApplicativeDo desugaring was changed to require monad constraints when using a strict pattern match (see #13875 (closed) for details). While this behavior is a requirement for maintaining the intended semantics of ApplicativeDo, it is both a breaking change, and somewhat unintuitive (see #14249 (closed)). Adding a message would provide both clarification around the requirement, and provide a simple resolution for the common use case.