I'm working with the author of syntactic to add support for a wide variety of types. I proposed using type lists to allow any type to be used, the dev proposed a cleaner solution that allows use with any instance of Typeable
.
I know (at least the current version) of Data.Reflection
doesn't support Typeable
reified types in GHC 7.8, but at least they proposed a workaround using lens
.
My question is about the original proposal for the library: aside from (some forms of) reified types, what other types in GHC 7.8 cannot be made an instance of Typeable
? If these types are sufficiently strange/rare, it could suffice to use the clean solution that requires Typeable
, but if there are [other] commonly used types that aren't Typeable
, the type list would be the more general solution.
GHC.TypeLits.Symbol
and Nat
are not Typeable. See https://ghc.haskell.org/trac/ghc/ticket/9111
Typeable
breaks abstraction of data types: the concrete structure of anything Typeable
can be queried even if it's constructors are hidden.
Most dangerously this means that types constructed via Typeable
leak information which may lead to improper use.
So, generally, types which are to be thought of as abstract cannot be Typeable
. A similar game and dance is played with role annotations since GeneralizedNewtypeDeriving
is a kind of reflection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With