#4370: Bring back monad comprehensions
---------------------------------+------------------------------------------
    Reporter:  simonpj           |        Owner:  nsch        
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:  7.2.1       
   Component:  Compiler          |      Version:  6.12.3      
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by nsch):

 I have a more technical question about the core language generation in the
 desugarer. I'm trying to use a function from the GHC.Exts library to
 simplify
 core generation a bit and since I only lookup the functions `Id` I have to
 manually apply all the types etc. to the function. The code looks
 something
 like this:

 {{{
   do { [..]
      ; mmap_id  <- dsLookupGlobalId mmapName -- new function from GHC.Exts
      ; let -- Apply types & arguments to 'mmap'
            tupleElem n = mkApps (Var mmap_id)
                                 -- Types:
                                 -- mmap :: forall (m :: * -> *) a b. Monad
 m => ..
                                 [ Type m_ty, Type a_ty, Type b_ty
                                 -- Arguments:
                                 , .. ]
     ; [..] }
 }}}

 But that expression is missing one more type argument for that `Monad m
 =>`
 predicate, which leads to the following error (for a simple example with
 lists
 and integers):

 {{{
 C:\Users\Nils\dev\hiwi\ghc\inplace\bin>ghc-stage2.exe -dcore-lint
 mc_group.hs
 [2 of 2] Compiling Main             ( mc_group.hs, mc_group.o )
 *** Core Lint errors : in result of Desugar ***
 <no location info>:
     In the expression: GHC.Exts.mmap
                          @ []
                          @ (GHC.Types.Int, GHC.Types.Int)
                          @ GHC.Types.Int
                          (\ (ds_dqc :: (GHC.Types.Int, GHC.Types.Int)) ->
                             case ds_dqc of _ { (ds_dq9, _) -> ds_dq9 })
     Argument value doesn't match argument type:
     Fun type:
         GHC.Base.Monad [] =>
         ((GHC.Types.Int, GHC.Types.Int) -> GHC.Types.Int)
         -> [(GHC.Types.Int, GHC.Types.Int)]
         -> [GHC.Types.Int]
     Arg type: (GHC.Types.Int, GHC.Types.Int) -> GHC.Types.Int
     Arg:
         \ (ds_dqc :: (GHC.Types.Int, GHC.Types.Int)) ->
           case ds_dqc of _ { (ds_dq9, _) -> ds_dq9 }
 }}}

 Comparing this core dump with other core dumps, it's clear that there
 should be
 another argument `GHC.Base.$fMonad[]` (for this example) to the `mmap`
 function, but I don't know what kind of argument that is and how to get
 it. So
 my question is pretty simple: What function will get me that missing
 argument?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4370#comment:28>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to