File: Typeable.h

package info (click to toggle)
hugs98 98.200311-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,964 kB
  • ctags: 8,084
  • sloc: ansic: 67,521; haskell: 61,497; xml: 4,566; sh: 3,264; cpp: 1,936; yacc: 1,094; makefile: 915; cs: 883; sed: 10
file content (25 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* ----------------------------------------------------------------------------
 * Macros to help make Typeable instances.
 * -------------------------------------------------------------------------- */

#define INSTANCE_TYPEABLE0(tycon,tcname,str) \
tcname = mkTyCon str; \
instance Typeable tycon where { typeOf _ = mkAppTy tcname [] }

#define INSTANCE_TYPEABLE1(tycon,tcname,str) \
tcname = mkTyCon str; \
instance Typeable a => Typeable (tycon a) where { \
  typeOf x = mkAppTy tcname [typeOf ((undefined :: tycon a -> a) x) ] }

#define INSTANCE_TYPEABLE2(tycon,tcname,str) \
tcname = mkTyCon str; \
instance (Typeable a, Typeable b) => Typeable (tycon a b) where { \
  typeOf x = mkAppTy tcname [typeOf ((undefined :: tycon a b -> a) x), \
			     typeOf ((undefined :: tycon a b -> b) x)] }

#define INSTANCE_TYPEABLE3(tycon,tcname,str) \
tcname = mkTyCon str; \
instance (Typeable a, Typeable b, Typeable c) => Typeable (tycon a b c) where {\
  typeOf a = mkAppTy tcname [typeOf ((undefined :: tycon a b c -> a) a), \
			     typeOf ((undefined :: tycon a b c -> b) a), \
			     typeOf ((undefined :: tycon a b c -> c) a)] }