[GHC] #14252: ApplicativeDo: Add compiler message about irrefutable pattern matches and Monad constraints

GHC ghc-devs at haskell.org
Tue Sep 19 17:05:32 UTC 2017


#14252: ApplicativeDo: Add compiler message about irrefutable pattern matches and
Monad constraints
-------------------------------------+-------------------------------------
           Reporter:  mutantmell     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Add an error message to the compiler when ApplicativeDo desugaring:
 * requires a Monad constraint when a Functor/Applicative constraint is
 expected
 * Adding a lazy pattern match could allow the Functor/Applicative
 constraint

 bgamari suggests something like the following message:

 {{{#!hs
 ApplicativeDo is enabled yet Monad is required due to irrefutable pattern
 match;
 perhaps you want to make the match refutable by adding a ~?
 }}}

 Background:

 In GHC 8.2.1, ApplicativeDo desugaring was changed to require monad
 constraints when using a strict pattern match (see #13875 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).  Adding a message would provide both
 clarification around the requirement, and provide a simple resolution for
 the common use case.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14252>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list