[GHC] #7862: Could not deduce (A) from the context (A, ...)

GHC cvs-ghc at haskell.org
Fri May 3 08:57:15 CEST 2013


#7862: Could not deduce (A) from the context (A, ...)
----------------------------------------+-----------------------------------
    Reporter:  alang9                   |       Owner:                           
        Type:  bug                      |      Status:  new                      
    Priority:  normal                   |   Milestone:                           
   Component:  Compiler (Type checker)  |     Version:  7.6.2                    
    Keywords:                           |          Os:  Linux                    
Architecture:  x86_64 (amd64)           |     Failure:  GHC rejects valid program
  Difficulty:  Unknown                  |    Testcase:                           
   Blockedby:                           |    Blocking:                           
     Related:                           |  
----------------------------------------+-----------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown


Comment:

 The error is indeed strange.  With a minor variant I got
 {{{
 T7862.hs:18:29:
   Overlapping instances for
     Num (Tower s0 (Scalar (Tower s (Scalar (Tower s a)))))
 }}}
 Whoa!  Look at that alternation of `Tower` and `Scalar`! Nothing like that
 shows up in the program.

 Turned out that it was to do with flattening type-function applications.
 After all, taking the strange constraint above, we see:
 {{{
     Num (Tower s0 (Scalar (Tower s (Scalar (Tower s a)))))
 =   Num (Tower s0 (Scalar (Tower s a)))
 =   Num (Tower s0 a)
 }}}
 by using the `type instance` twice... and ''that'' is a much more sensible
 constraint.  Turned out that the constraint solver was mis-orienting an
 equality so that, in effect, it reported a much less perspicuous (albeit
 still equivalent) version of constraint.

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



More information about the ghc-tickets mailing list