#5015: Can't unsafeCoerce a GADT with a coercion
---------------------------------+------------------------------------------
    Reporter:  TristanAllwood    |       Owner:                         
        Type:  bug               |      Status:  new                    
    Priority:  normal            |   Component:  Compiler (Type checker)
     Version:  7.0.2             |    Keywords:                         
    Testcase:                    |   Blockedby:                         
          Os:  Unknown/Multiple  |    Blocking:                         
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown           
---------------------------------+------------------------------------------

Comment(by diatchki):

 This is not a bug, GHC is working as expected.

 The constructor {{{E}}} has a polymorphic type, which is automatically
 instantiated when you use it.  This means that every use of {{{E}}} will
 be at a monomorphic type of the form {{{a0 -> E}}} for some type {{{a0}}}
 and, one the side, GHC has to check that {{{Blah a0 ~ Int}}}.

 In these examples there is no reason to believe that {{{Blah a0}}} is
 {{{Int}}}, which is what the type error says.  You could fix this by
 specifying the instantiation type explicitly.  For example,
 {{{unsafeCoerce (E :: Int -> E)}}} will probably type-check (although it
 will probably crash if you tried to use it).

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to