[GHC] #5633: TypeFamilies don't seem to play with LIberalTypeSynonyms

GHC cvs-ghc at haskell.org
Tue Nov 15 17:47:28 CET 2011


#5633: TypeFamilies don't seem to play with LIberalTypeSynonyms
----------------------------------------+-----------------------------------
  Reporter:  ocharles                   |          Owner:                                  
      Type:  bug                        |         Status:  closed                          
  Priority:  normal                     |      Milestone:                                  
 Component:  Compiler                   |        Version:  7.0.4                           
Resolution:  invalid                    |       Keywords:  TypeFamilies LiberalTypeSynonyms
  Testcase:                             |      Blockedby:                                  
Difficulty:                             |             Os:  Linux                           
  Blocking:                             |   Architecture:  x86                             
   Failure:  GHC rejects valid program  |  
----------------------------------------+-----------------------------------
Changes (by simonpj):

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


Comment:

 The first program works because of a non-Haskell98 feature of GHC.
 Fundamentally,
 type synonyms, and type families, must be fully applied.  However with
 LiberalTypeSynonyms, GHC fully expands "outer" type synonyms before
 checking for the full application of "inner" ones.  In this example, we
 start
 with
 {{{
      foo : Generic Int Id
 }}}
 where `Id` is not fully applied.  However, if `Generic` is a type synonym
 we expand it before making the check, so it's now like
 {{{
      foo :: Id Int
 }}}
 and lo, `Id` is fully applies.

 Now, type synonyms are easy to apply on the fly; it's another thing
 entirely with type families, which can "get stuck" (ie not reduce)
 if their arguments are no sufficiently informative  Moreover, you can
 pattern match on their arguments.  For example, if you wrote
 {{{
         type instance Generic Int Maybe = Bool
 }}}
 would you expect that to work, with `Maybe` not matching against `Id`?
 Presumably not.

 The pure type synonyms can always reduce, and never do pattern
 matching, so these issue do not arise.  I can't see an easy way to
 lift the restriction.

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



More information about the Glasgow-haskell-bugs mailing list