[GHC] #4834: Implement Functor => Applicative => Monad Hierarchy (aka AMP phase 3)

GHC ghc-devs at haskell.org
Mon Feb 9 09:04:38 UTC 2015


#4834: Implement Functor => Applicative => Monad Hierarchy (aka AMP phase 3)
-------------------------------------+-------------------------------------
        Reporter:  gidyn             |                   Owner:
            Type:  task              |                  Status:  new
        Priority:  high              |               Milestone:  7.10.1
       Component:  libraries/base    |                 Version:  7.0.1
      Resolution:                    |                Keywords:  report-
Operating System:  Unknown/Multiple  |  impact
 Type of failure:  None/Unknown      |            Architecture:
      Blocked By:                    |  Unknown/Multiple
 Related Tickets:  #8004             |               Test Case:
                                     |                Blocking:
                                     |  Differential Revisions:  Phab:D13
-------------------------------------+-------------------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"a741e69a230eb6d6e3373ad1fbe53c73b5f95077/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="a741e69a230eb6d6e3373ad1fbe53c73b5f95077"
 Provide default implementation of `Monad(return)`

 This was dropped last-minute from d94de87252d0fe2ae97341d186b03a2fbe136b04
 (re #4834) together with the default implementation for `(>>)`
 (see 65f887e1a0d864526f6a2609a3afc2c151c25e38 for explanation).

 However, the risk of accidental mutually recursive definitions of
 `return`/`pure` is rather low as unlike with the `(>>) = (*>)` default,
 any cyclic definitions would necessarily wind up being new ones, rather
 than changing the semantics for old operations and introducing bottoms.

 On the other hand, not having the default method implementation in place
 in GHC 7.10 would complicate/delay any future attempt to clean-up the
 `Monad`-class.

 This finally allows (for `base >= 4.8`) to define a F/A/M instance-chain
 with the following minimal definitions (while ignoring that `return` is
 still a class-method in `Monad`)

   instance Functor M where
     fmap  = ...

   instance Applicative M where
     pure  = ...
     (<*>) = ...

   instance Monad M where
     (>>=) = ...

 Reviewed By: ekmett, austin

 Differential Revision: https://phabricator.haskell.org/D647
 }}}

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


More information about the ghc-tickets mailing list