
#14960: Invalid law for MonadPlus: v >> mzero = mzero -------------------------------------+------------------------------------- Reporter: lyxia | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 8.2.2 libraries/base | Keywords: laws, mzero | Operating System: Unknown/Multiple Architecture: | Type of failure: Documentation Unknown/Multiple | bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The documentation of `MonadPlus` states: `v >> mzero = mzero`. This law is broken by `IO`, `MaybeT`, and a few other monads with some notion of "irreversible effects". I propose to just remove that law. https://hackage.haskell.org/package/base-4.11.0.0/docs/Control- Monad.html#t:MonadPlus Another alternative is to keep it but remove unlawful instances, so `MonadPlus` instances can signal that those laws hold, on top of the `Alternative` instances. But that breaks backwards compatibility, because `MonadPlus` for `IO` and `MaybeT` is already used in many places. This thread previously brought up the issue but hasn't been followed up: https://mail.haskell.org/pipermail/libraries/2014-January/021993.html, continued on https://mail.haskell.org/pipermail/libraries/2014-February/022004.html with some interesting discussion about what those laws should be. This even older thread also discusses `MonadPlus` laws, hence it also seems relevant to improve the documentation: https://mail.haskell.org/pipermail/haskell-cafe/2005-January/008751.html. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14960 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler