
On 12/9/06, Taral
On 12/9/06, Alfonso Acosta
wrote: I've been using Data.Dynamic but the Typeable requirement doesn't go well with FFI declarations (which don't accept type contexts).
Can you be a little more specific?
Functions like this one are not directy exportable myfunc :: (Tyeable a, Typeable b) => MyType a b ...
mt2mgt :: MyType a b -> MyGenType mt2mgt = MyGenType.myToDyn
mgt2mt :: MyGentype -> MyType a b mgt2mt (MyGenType dyn) = myfromDyn dyn
mgt2mt . mt2mgt :: MyType a b -> MyType c d
Yes, it's dangerous. The reason Dynamic requires Typeable is to be able to check that you're casting Dynamic back to the original type.
Uhm thinking about it right now I realized that mgt2mt is hidden to the user, so I guess it wouldn't be dangerous if transformations like the following one are not. MyType Int Char ---> MyGenType ----> MyType a b So to summarize, Is transforming a monomorphic type to it's polymorphic equivalent through unsafeCoerce a dangerous operation?