
#11692: Suggest default definition of Applicative -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): Your suggested warning enhancement is in contradiction to the recommendation expressed in several places (migration guide, AMP wiki page etc, `-Wnoncanonical-monad-instances`) to define `return` in terms of `pure` rather than the other way round. In fact, since GHC 7.10/base-4.8 you don't even need to define `Monad(return)` at all anymore, as it's got a default implementation `return = pure`. Suggesting to define `pure = return` risks ending up with circular definition of `return`/`pure` when refactoring. In fact, together with the MonadFail proposal the proper (minimal, i.e. excluding non-mandatory methods) mental model of the F-A-M-MF hierarchy to have is more or less: {{{#!hs class Functor f where fmap :: (a -> b) -> f a -> f b class Functor f => Applicative f where pure :: a -> f a (<*>) :: f (a -> b) -> f a -> f b class Applicative m => Monad m where (>>=) :: m a -> (a -> m b) -> m b class Monad m => MonadFail m fail :: String -> m a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11692#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler