Skip to content

ApplicativeDo requires (>>=) and (<*>)

The following ApplicativeDo+RebindableSyntax program requires (>>=) and (<*>) to be present in scope, even though neither is used. There's a similar problem with return, covered by #18313.

{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE RebindableSyntax #-}
module Bug where

import Prelude (Applicative(pure), Functor(..))

return x = [x]

(>>=) = (>>=) -- shouldn't be needed
(<*>) = (<*>) -- shouldn't be needed

xs :: [a]
xs = do
  x <- []
  pure x

Similar issue arises from combining ApplicativeDo+QualifiedDo:

module Ado where

(>>=) = undefined -- shouldn't be needed
(<*>) = undefined -- shouldn't be needed

pure :: Applicative f => a -> f a
pure = undefined

return :: Applicative f => a -> f a
return = Prelude.pure

fmap :: Functor f => (a -> b) -> f a -> f b
fmap = Prelude.fmap

----

{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE ApplicativeDo #-}

module Adotry where

import qualified Ado as A

xs :: [Int]
xs = A.do
  x <- []
  A.pure $ x

Bug found by Georgi Lyubenov https://twitter.com/aspiwack/status/1313595873058750464

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information