Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What *isn't* Typeable in GHC 7.8?

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.

like image 931
crockeea Avatar asked Jun 02 '14 15:06

crockeea


2 Answers

GHC.TypeLits.Symbol and Nat are not Typeable. See https://ghc.haskell.org/trac/ghc/ticket/9111

like image 154
aavogt Avatar answered Oct 21 '22 12:10

aavogt


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.

like image 33
J. Abrahamson Avatar answered Oct 21 '22 12:10

J. Abrahamson