Let statements don't work with ApplicativeDo
Summary
Let statements don't work with ApplicativeDo. Bug or feature?
Steps to reproduce
Compile this snippet and see the compiler complain.
{-# LANGUAGE ApplicativeDo #-}
module Bug where
foo :: Applicative f => f Int
foo = undefined
bar :: Applicative f => f Int
bar = do
x <- foo
let y = x + 1
pure y
Expected behavior
I would expect let
bound variables to be allowed if they are not used in any RHSs of <-
bindings.
The example above can trivially bee rewritten to (which works)
bar :: Applicative f => f Int
bar = do
x <- foo
pure $ let y = x + 1 in y
Environment
- GHC version used:
The Glorious Glasgow Haskell Compilation System, version 8.10.1