[GHC] #8004: Applicative/Monad proposal related warnings (AMP phase 1)

GHC ghc-devs at haskell.org
Thu Oct 22 13:59:14 UTC 2015


#8004: Applicative/Monad proposal related warnings (AMP phase 1)
-------------------------------------+-------------------------------------
        Reporter:  quchen            |                Owner:  quchen
            Type:  feature request   |               Status:  closed
        Priority:  high              |            Milestone:  7.8.1
       Component:  Compiler          |              Version:  7.6.3
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #4834             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by songzh):

 I am so curious that I want to ask for the second case "You have an
 instance of Monad, but not Applicative"
 why cann't we add default implementation to Applicative typeclass?
 {{{
 class Functor f => Applicative f where
     pure :: a -> f a
     default pure :: Monad f => a -> f a
     pure = return
     (<*>) :: f (a -> b) -> f a -> f b
     default (<*>) :: Monad f => f (a -> b) -> f a -> f b
     (<*>) f a = ap
 }}}

 Replying to [comment:14 Austin Seipp <austin@…>]:
 > In [changeset:75a9664af1c4e6f87794b49a215adb235b20696d/ghc]:
 > {{{
 > #!CommitTicketReference repository="ghc"
 revision="75a9664af1c4e6f87794b49a215adb235b20696d"
 > Implement the AMP warning (#8004)
 >
 > This patch implements a warning when definitions conflict with the
 > Applicative-Monad Proposal (AMP), described in #8004. Namely, this will
 > cause a warning iff:
 >
 >     * You have an instance of Monad, but not Applicative
 >     * You have an instance of MonadPlus, but not Alternative
 >     * You locally defined a function named join, <*>, or pure.
 >
 > In GHC 7.10, these warnings will actually be enforced with superclass
 > constraints through changes in base, so programs will fail to compile
 > then.
 >
 > This warning is enabled by default. Unfortunately, not all of
 > our upstream libraries have accepted the appropriate patches. So we
 > temporarily fix ./validate by ignoring the AMP warning.
 >
 > Dan Rosén made an initial implementation of this change, and the
 > remaining work was finished off by David Luposchainsky. I finally made
 > some minor refactorings.
 >
 > Authored-by: Dan Rosén <danr at chalmers.se>
 > Authored-by: David Luposchainsky <dluposchainsky at gmail.com>
 > Signed-off-by: Austin Seipp <austin at well-typed.com>
 > }}}

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


More information about the ghc-tickets mailing list