[GHC] #14700: ApplicativeDo in MonadComprehensions

GHC ghc-devs at haskell.org
Mon Jan 22 17:22:11 UTC 2018


#14700: ApplicativeDo in MonadComprehensions
-------------------------------------+-------------------------------------
           Reporter:  lspitzner      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 It appears that a MonadComp (even one that is "Applicative only") is not
 transformed appropriately in the presence of ApplicativeDo.

 {{{#!hs
 {-# LANGUAGE MonadComprehensions #-}
 {-# LANGUAGE ApplicativeDo #-}

 value1 = [ f a b c | a <- ma, b <- mb, c <- mc ]
 value2 = do { a <- ma; b <- mb; c <- mc; return (f a b c) }
 value3 = f <$> ma <*> mb <*> mc
 }}}

 value1 should desugar to value2 via monadcomp and to value3 via appdo. Yet
 I observe very bad performance in some specific instance (due to a slower
 Monad instance) when using value1, where value2 and value3 have good
 performance. I have not looked at desuraged/core dumps but the observation
 seems clear.

 Tested on ghc-8.0.2 only.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14700>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list