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

2011-11-17 Thread GHC
#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  |  
+---

Comment(by ocharles):

 Hi simon, thanks for the explanation.

 It's a shame that it can't work, as a newtype doesn't really cut it. Fwiw,
 the motivation of this ticket came from trying to abstract away Record
 declarations in HaskellDB with code that also uses type families.

 HaskellDB uses either `RecCons FieldType (Expr RetType)` or `RecCons
 FieldType RetType` depending on how a record is used/returned, and there
 doesn't seem to be a way to capture this with a type family, where I was
 trying to abstract Expr :: * - * away. However, this ticket isn't the
 right place for that discussion, so I'll move that to a mailing list :)

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

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


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

2011-11-15 Thread GHC
#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

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs