#2899: GADT type inference with existentials
------------------------------------+---------------------------------------
Reporter:  jochemb                  |          Owner:                         
    Type:  bug                      |         Status:  new                    
Priority:  normal                   |      Component:  Compiler (Type checker)
 Version:  6.10.1                   |       Severity:  normal                 
Keywords:  GADT, existential types  |       Testcase:                         
      Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple       
------------------------------------+---------------------------------------
 The following code works in GHC 6.8.2:

 {{{
 {-# OPTIONS -fglasgow-exts #-}
 module Test where

 data Existential = forall a. Ex (GADT a)

 data GADT :: * -> * where
         GCon :: Int -> GADT ()

 -- g :: Existential -> Int
 g (Ex (GCon x)) = x
 }}}

 The compiler correctly infers the type of x in the definition of g, and
 correctly infers the type of g.

 In GHC 6.10.1, however, this fails with:
 {{{
 Test.hs:10:12:
     GADT pattern match with non-rigid result type `t'
       Solution: add a type signature
     In the definition of `g': g (Ex (GCon x)) = x
 Failed, modules loaded: none.
 }}}

 The solution, to include the type signature of g (that I have commented
 out), works, but why can't GHC figure out the type of g? GHC 6.8.2 could!

 An equivalent version with a non-GADT instead, works correctly:
 {{{
 data GADT a = GCon Int
 }}}

 Ticket #2206 might be related.

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