1 /* -----------------------------------------------------------------------------
2 * $Id: Dynamic.h,v 1.1 2001/06/28 14:15:04 simonmar Exp $
4 * Macros to help make Typeable instances.
5 * -------------------------------------------------------------------------- */
7 #define INSTANCE_TYPEABLE0(tycon,tcname,str) \
8 tcname = mkTyCon str; \
9 instance Typeable tycon where { typeOf _ = mkAppTy tcname [] }
11 #define INSTANCE_TYPEABLE1(tycon,tcname,str) \
12 tcname = mkTyCon str; \
13 instance Typeable a => Typeable (tycon a) where { \
14 typeOf x = mkAppTy tcname [typeOf ((undefined :: tycon a -> a) x) ] }
16 #define INSTANCE_TYPEABLE2(tycon,tcname,str) \
17 tcname = mkTyCon str; \
18 instance (Typeable a, Typeable b) => Typeable (tycon a b) where { \
19 typeOf x = mkAppTy tcname [typeOf ((undefined :: tycon a b -> a) x), \
20 typeOf ((undefined :: tycon a b -> b) x)] }
22 #define INSTANCE_TYPEABLE3(tycon,tcname,str) \
23 tcname = mkTyCon str; \
24 instance (Typeable a, Typeable b, Typeable c) => Typeable (tycon a b c) where {\
25 typeOf a = mkAppTy tcname [typeOf ((undefined :: tycon a b c -> a) a), \
26 typeOf ((undefined :: tycon a b c -> b) a), \
27 typeOf ((undefined :: tycon a b c -> c) a)] }