[Haskell-cafe] Unboxing VT_VARIANT in hscom

Krasimir Angelov kr.angelov at gmail.com
Tue Aug 19 04:49:28 EDT 2008


This looks like a GHC bug to me. I am pretty sure that this worked
before. Variant is defined like this:

data Variant = forall a . Variant (VarType a) a

data VarType a where
   ....
   VT_DISPATCH  :: VarType (IDispatch ())

>From this it clear that val is of type (IDispatch ()) because the
VarType has value VT_DISPATCH. A workaround is to add explicit type
singnature for val:

someFunc (Variant VT_DISPATCH val) query = do
    dispId <- getMethodID "MethodName"  (val :: IDispatch ())

I don't know why this doesn't work without the signature.

Regards,
   Krasimir


On Tue, Aug 19, 2008 at 7:09 AM, Praki Prakash <praki.prakash at gmail.com> wrote:
> I am a Haskell newbie trying to do COM automation using Haskell. I am using
> hscom (Krasimir's implementation of COM automation). I have run into a problem
> and need some help.
>
> I have a Variant returned from a COM method invocation. When I print it, it
> shows up as below.
>
> Variant VT_DISPATCH <interface 0x00039f00>
>
> I need to invoke methods on the wrapped interface. My attempt to unbox it as
> below runs into 'rigid type' error.
>
> someFunc (Variant VT_DISPATCH val) query = do
>  dispId <- getMethodID "MethodName"  val
>
> The code above generates this error.
>
>    Couldn't match expected type `IDispatch a'
>           against inferred type `a1'
>      `a1' is a rigid type variable bound by...
>
> I am probably missing something pretty basic. Any help on this is greatly
> appreciated!
>
> Thanks
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list