Provide default implementation of `Monad(return)`

Authored by hvr on Feb 8 2015, 2:05 PM.



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

However, the risk of accidental mutually recursive definitions of
return/pure is rather low, while not having the default method
implementation in place as soon as possible would complicate
any future attempt to clean-up the Monad-class.

Test Plan

local validate passed

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
hvr updated this revision to Diff 2200.Feb 8 2015, 2:05 PM
hvr retitled this revision from to Provide default implementation of `Monad(return)`.
hvr updated this object.
hvr edited the test plan for this revision. (Show Details)
hvr added reviewers: ekmett, austin.
ekmett accepted this revision.Feb 9 2015, 2:30 AM
ekmett edited edge metadata.

We talked about this one on IRC before the patch was made.

Unlike with (>>) = (*>), any cyclic definitions would necessarily wind up being new ones, rather than changing the semantics for old operations and introducing bottoms.

It looks good to me.

This revision is now accepted and ready to land.Feb 9 2015, 2:30 AM
hvr edited edge metadata.Feb 9 2015, 2:43 AM
hvr updated the Trac tickets for this revision.
austin accepted this revision.Feb 9 2015, 2:49 AM
austin edited edge metadata.

OK, LGTM. Yes, I think this was dropped whenever I simply got rid of a the other (bad) defaults.

This revision was automatically updated to reflect the committed changes.

Right, I think this is clearly acceptable as long as there isn't also a default definition for Applicative's pure in terms of return for Monads (using whatever that GHC extension is called). If you have to write a definition for at least one method to get mutually recursive definitions then there isn't really an issue IMHO. After all, one could equally well write instance Eq X where a == b = not (a /= b) and that would pass the MINIMAL check but result in mutual recursion.