
Do you intentionally disallow `return x = pure x`, which some people might write? (No strong opinion here, having precisely one official way is
#11128: New `-fwarn-noncanonical-monad-instances` warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: hvr Type: feature request | Status: patch Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1516 Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:2 nomeata]: probably desirable, but let’s at least document that it has been given thought.) Yes, that was quite intentional, and there are a couple of reasons actually: - I found only *one* single `return a = pure a` on Hackage when I grepped for `rgrep 'return *[a-z] *= *pure *[a-z]'`; this is maybe because any instructions I saw for making code AMP-proof used rather pointsfree equational style e.g. (`return = pure`), and the Haddock documentation in `base` uses that style too - the warning is easier to document, implement, and less corner-cases to worry about - "canonical" somewhat implies we want a single unique form here, this also has the benefit of being able to have a simpler regexp to find all `return *= *pure` patterns in your codebase (e.g. if you want to drop those when base<4.8 compat doesn't matter anymore) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11128#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler