Skip to content

ApplicativeDo easily foiled with `pure`

ApplicativeDo fails to desugar do blocks ending with pure. For instance,

{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

newtype MaybeA a = MaybeA (Maybe a)
                 deriving (Show, Functor, Applicative)

main = print $ do x <- MaybeA $ Just 42
                  pure x

However, if the final pure is changed to return things work as expected.

Trac metadata
Trac field Value
Version 8.0.1-rc2
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information