#1496: Newtypes and type families combine to produce inconsistent FC(X) axiom 
sets
----------------------------------------+-----------------------------------
    Reporter:  sorear                   |        Owner:  simonpj   
        Type:  bug                      |       Status:  new       
    Priority:  high                     |    Milestone:  6.8 branch
   Component:  Compiler (Type checker)  |      Version:  6.7       
    Severity:  critical                 |   Resolution:            
    Keywords:                           |   Difficulty:  Unknown   
          Os:  Unknown                  |     Testcase:            
Architecture:  Unknown                  |  
----------------------------------------+-----------------------------------
Comment (by Isaac Dupree):

 Replying to [comment:12 toms]:
 >    However, GADTs are definitely not functors.

 ...

 >    We can attempt to fix the situation by imposing conditions on the
 types involved in
 >    a newtype deriving:
 >      * generate the fmap code, and hence demand explicit Functor
 instances.
 >        We should be able to expect the compiler to eliminate any runtime
 overhead.

 From Frisby we have a data type that is a Functor and a GADT, but not a
 Functor in the way you and GHC expect:
 {{{
 data PE a where
 -- leaving out most of the constructors, but note especially PMap
     Char :: IntSet.IntSet -> PE Char
     Failure :: PE a
     Not :: PE a -> PE ()
     Then :: PE a -> PE b -> PE (a,b)
     PMap :: (a -> b) -> PE a -> PE b

 instance Functor PE where
     fmap = PMap
 }}}

 Applying the `fmap`-option would make interesting, type-correct code be
 generated that could not be optimized away (so the dictionaries couldn't
 be shared).

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

Reply via email to