Hi,

I've been using Data.Dynamic but the Typeable requirement doesn't go
well with FFI declarations (which don't accept type contexts).

This is a little example of what I would like to do:

data MyDyn = MyDyn

myToDyn :: a -> MyDyn
myToDyn = unsafeCoerce

myFromDyn :: MyDyn -> a
myFromDyn = unsafeCoerce

-- this is a type I want to transform back and forth from dynamic
-- and store into lists etc etc ...

data MyType a b = MyType a b

-- This it's "abstract" Generic type (it's contructor should be  hidden)

data MyGenType = MyGenType MyDyn

mt2mgt :: MyType a b -> MyGenType
mt2mgt = MyGenType.myToDyn

mgt2mt :: MyGentype -> MyType a b
mgt2mt (MyGenType dyn) = myfromDyn dyn

The question is, ¿if only mt2mgt and mgt2mt are used by the user,
would the use of unsafeCoerce be dangerous?


Thanks in advance,

Alfonso Acosta
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to