[GHC] #7812: Ambiguity check too eager with unconstrained type variable

GHC cvs-ghc at haskell.org
Mon Apr 8 20:17:23 CEST 2013


#7812: Ambiguity check too eager with unconstrained type variable
--------------------------------------+-------------------------------------
  Reporter:  goldfire                 |          Owner:                  
      Type:  bug                      |         Status:  closed          
  Priority:  normal                   |      Milestone:                  
 Component:  Compiler (Type checker)  |        Version:  7.7             
Resolution:  invalid                  |       Keywords:  AmbiguityCheck  
        Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown             |     Difficulty:  Unknown         
  Testcase:                           |      Blockedby:                  
  Blocking:                           |        Related:                  
--------------------------------------+-------------------------------------
Changes (by goldfire):

  * status:  new => closed
  * resolution:  => invalid


Comment:

 I have figured out a suitable workaround. Instead of using a type family
 application in a return type, just have the function return
 {{{[result]}}}. Then, use a type family to optionally create an equality
 constraint for {{{result}}}.

 {{{
 type family MapOuttable (f :: *) (list :: [*]) (result :: *) :: Constraint
 type instance MapOuttable f '[] result = ()
 type instance MapOuttable f '[elt] result = (Applicable f elt, result ~
 Apply f elt)
 type instance MapOuttable f (h1 ': h2 ': t) result =
   ( Applicable f h1
   , Apply f h1 ~ Apply f h2
   , MapOuttable f (h2 ': t) result
   , result ~ Apply f h1 )

 hMapOut :: MapOuttable f list a => f -> HList list -> [a]
 hMapOut _ HNil = []
 hMapOut f (HCons elt HNil) = [apply f elt]
 hMapOut f (HCons h t@(HCons _ _)) = apply f h : hMapOut f t
 }}}

 Given this workaround -- which should always be available in the case I'm
 thinking of -- I will close the ticket.

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



More information about the ghc-tickets mailing list