I am trying to make a reified (using Data.Reflection) type an instance of Typeable.
newtype Zq q = Zq Int
I can derive a Typeable1 instance for Zq, but this comes with the implicit constraint (Typeable q). I want to use a value of type Zq q in a function which requires the argument to be Typeable. So there are a few questions:
- Is there any way to make a reified type
Typeable? - If not, is there any way to modify the existing library to allow for this?
- In general, which types can be made
Typeable? It seems that by usingDeriveDataTypeableandStandaloneDeriving, any concrete type I can think of (aside from a temporary type like the reified type) can be an instance.
EDIT Code snippet of what I'm talking about:
f = reify (42::Int) (\ (_::Proxy q) ->
let x = Zq 15 :: Zq q -- x = 15 mod 42
in ...
I would like Zq q, where q is the reified type, to be an instance of Typeable. The only way I know to do this is to make q Typeable as well. Of course, if I reify 42 to q1 and then reify 43 to q2, these should not be equal types. On the other hand, I realize I cannot expect two different type variables which reify the same value to have equal TypeReps (even though in practice they are identical).