ApplicativeDo and RebindableSyntax requires *both* return and pure
-XApplicativeDo
applies special treatment to do
-blocks whose last statement is a call to return
or pure
. With -XRebindableSyntax
, the return
/pure
is the one in scope, not the one from the Prelude
. But this means that this combination of extensions requires a user to define both return
and pure
. This is silly; if one isn't in scope, we should simply not look for it.
Here is a test case:
{-# LANGUAGE RebindableSyntax, ApplicativeDo #-}
module Bug where
_ >> _ = ()
return _ = ()
_ <*> _ = ()
fmap _ _ = ()
x = do x
return x
This currently fails with
Bug.hs:10:5: error: Not in scope: ‘pure’
|
10 | x = do x
| ^^^^...
but I think it should succeed.
Sidenote: changing to x = do x
is accepted, but I have no idea why it doesn't look for pure
in a one-line do
. Maybe that's special-cased. But it's not documented.