(Redirecting to ghc-bugs.)

Krasimir, Praki

| The issue reported by Praki looks like a GHC bug to me.

I have compiled the two modules below with 6.8.3 and with the HEAD; both are 
fine.  If you have a reproducible case that fails, do please submit a Trac 
report.

With HEAD you do need to add a type signature to useVariant :: Variant -> IO 
(), but then it's fine.  The code I used is below.


Simon

| The smallest test case is at the end. (VarType a) is a GADT and
| Variant wraps the VarType with a value of type a. The definitions of
| Variant and VarType require ExistentialQuantification and GADTs
| extensions and I have declared them. The problem is when someone try
| to use them.
|
| If the client code is compiled without any extensions turned on the
| error message is:
|
| >> test.hs:35:47:
| >>     Couldn't match expected type `IDispatch a'
| >>            against inferred type `a1'
| >>       `a1' is a rigid type variable bound by
| >>            the constructor `Variant' at test.hs:34:22
| >>     In the second argument of `getMethodID', namely `idisp'
| >>     In a 'do' expression: dispId <- getMethodID "ExecQuery" idisp
| >>     In the expression:
| >>         do dispId <- getMethodID "ExecQuery" idisp
| >>            return ()
|
| This suggests that the compiler understands that Variant is an
| existential type but doesn't understand that VarType is a GADT. If the
| code is compiled with -fglasgow-exts then everything works fine. Why
| the compiler always understands existential types and not GADT. For me
| this is unfair against GADT. Shouldn't the compiler always understand
| GADT as well provided that they are already defined somewhere?
|
| Best Regards,
|   Krasimir
|
| ------------------------------------------------------------------------------
| -- Implementation of Variant
| ------------------------------------------------------------------------------
|
| {-# LANGUAGE ExistentialQuantification, GADTs #-}
| module Variant where
|
| data VarType a where
|   VT_DISPATCH :: VarType IDispatch
|
| data IDispatch = IDispatch
|
| data Variant = forall a . Variant (VarType a) a
|
|
| ------------------------------------------------------------------------------
| -- Use of Variant
| ------------------------------------------------------------------------------
|
| import Variant
|
| useIDispatch :: IDispatch -> IO ()
| useIDispatch _ = putStrLn "useIDispatch"
|
| useVariant :: Variant -> IO ()
| useVariant (Variant VT_DISPATCH idisp) = useIDispatch idisp
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to