Skip to content

deriving Data, Typeable for empty data decls

Empty data decls are useful for things like phantom types. However, deriving (Data, Typeable) does not work with them, so if you want to use them with generics you must do something like the following:

data PredTag 

instance Typeable PredTag where
  typeOf _ = G.mkTyConApp (G.mkTyCon "PredTag") []

Surely GHC could derive this for us!

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information