Skip to content

ApplicativeDo: `return` sometimes not allowed

Steps to reproduce

The following program is rejected, because "No instance for (Monad F) arising from a use of ‘return’".

-- F is an Applicative but not a Monad
x :: F Int
x = do
  let a = 3
  return a

However, it is accepted if let a = 3 is changed to a <- pure 3.

Expected behavior

In an ado-block, the last statement can be return, so the above program should be accepted.

Environment

  • GHC version used: 9.3.20210913
Edited by Ziyang Liu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information