[GHC] #14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint --------------------------------------+--------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: ApplicativeDo | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Other Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------- Pattern matching on a bind in 8.2.1 confuses ApplicativeDo, and causes the type to have a Monad constraint where a Functor constraint would suffice. In GHC 8.0: {{{#!hs
:set -XApplicativeDo :t \x -> do { (a, _) <- x; pure (a+1) } \x -> do { (a, _) <- x; pure (a+1) } :: (Num b, Functor f) => f (b, t) -> f b }}}
In GHC 8.2: {{{#!hs
:set -XApplicativeDo :t \x -> do { (a, _) <- x; pure (a+1) } \x -> do { (a, _) <- x; pure (a+1) } :: (Num b1, Monad m) => m (b1, b2) -> m b1 }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by Iceland_jack): Due to #13875? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by mutantmell): Adding the `~` to my pattern match changes the constraint, so it looks like it is due to #13875. I'll close the bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Changes (by mutantmell): * status: new => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by Iceland_jack): Thanks for filing the ticket, I'm sure you aren't the only one confused by this behavior -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by mutantmell): I was updating a codebase to 8.2 when I ran into this -- the only thing ghc told me was that my previously valid signature was wrong. Having the compiler output extra information here similar to how it informs the user about Language Extensions would have helped. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by bgamari): So you would like something like, {{{ ApplicativeDo is enabled yet Monad is required due to irrefutable pattern match; perhaps you want to make the match refutable by adding a ~? }}} Is this right? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by mutantmell): That would be excellent, yes. Do you want me to file a ticket about this, or take some other action? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by bgamari): Yes, a ticket would be great. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14249: ApplicativeDo: Pattern matching on a bind forces a Monad constraint -------------------------------+-------------------------------------- Reporter: mutantmell | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: ApplicativeDo Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by mutantmell): I created #14252, and referenced this ticket and #13875. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14249#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC