#7205: Re-introduce left/right coercion decomposition
---------------------------------+------------------------------------------
    Reporter:  simonpj           |       Owner:                  
        Type:  feature request   |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.4.2           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
 Suppose we have
 {{{
 data T a where
   MkT :: f a -> T (f a)
   ...other constructors...

 foo :: T (f a) -> f a
 foo (MkT x) = x
 }}}
 You might think this would obviously be OK, but currently we get
 {{{
 Foo.hs:10:15:
     Could not deduce (a1 ~ a)
     from the context (f a ~ f1 a1)
       bound by a pattern with constructor
                  MkT :: forall (f :: * -> *) a. f a -> T (f a),
                in an equation for `foo'
       at Foo.hs:10:6-10
 }}}
 Reason: we don't have the left/right decomposition rules for coercions,
 which were in an earlier version.  (In fact this does compile with GHC
 7.0.)  We removed them (a) because we were interested in supporting un-
 saturated type functions, and (b) we didn't think it was that important.

 But in fact it IS an annoying problem.  A recent example is [http://www
 .mail-archive.com/[email protected]/msg100962.html this email from
 Paul Liu], which ultimately stems from precisely this problem.

 I think we've since decided to put left/right back (pulling back on
 unsaturated type functions), but I need to actually implement it; hence
 this ticket.

 Simon

 PS: here's Paul's example
 {{{
 {-# LANGUAGE GADTs, MultiParamTypeClasses, FlexibleInstances,
 FlexibleContexts #-}
 module Liu where

 data Abs env g v where
   Abs :: g (a, env) h v -> Abs env (g (a, env) h v) (a -> v)

 class Eval g env h v where
   eval :: env -> g env h v -> v

 evalAbs :: Eval g2 (a2, env) h2 v2
         => env
         -> Abs env (g2 (a2, env) h2 v2) (a2->v2)
         -> (a2->v2)
 evalAbs env (Abs e) x
   = eval (x, env) e    -- e :: g (a,env) h v
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7205>
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