2 -- This module just adds instances of Bits for Int/Word[8,16,32,64]
3 ( Int8, Int16, Int32, Int64
4 , Word8, Word16, Word32, Word64
7 {- Note explicit braces and semicolons here - layout is corrupted by cpp. -}
9 {import NHC.FFI (Int8,Int16,Int32,Int64,Word8,Word16,Word32,Word64)
12 #define SIZED_TYPE(T,BS,S) \
14 ; INSTANCE_BITS(T,BS,S)
18 ; foreign import ccall nhc_prim##T##And :: T -> T -> T \
19 ; foreign import ccall nhc_prim##T##Or :: T -> T -> T \
20 ; foreign import ccall nhc_prim##T##Xor :: T -> T -> T \
21 ; foreign import ccall nhc_prim##T##Lsh :: T -> Int -> T \
22 ; foreign import ccall nhc_prim##T##Rsh :: T -> Int -> T \
23 ; foreign import ccall nhc_prim##T##Compl :: T -> T
26 #define INSTANCE_BITS(T,BS,S) \
27 ; instance Bits T where \
28 { (.&.) = nhc_prim##T##And \
29 ; (.|.) = nhc_prim##T##Or \
30 ; xor = nhc_prim##T##Xor \
31 ; complement = nhc_prim##T##Compl \
32 ; shiftL = nhc_prim##T##Lsh \
33 ; shiftR = nhc_prim##T##Rsh \
38 SIZED_TYPE(Int8,8,True)
39 SIZED_TYPE(Int16,16,True)
40 SIZED_TYPE(Int32,32,True)
41 SIZED_TYPE(Int64,64,True)
43 SIZED_TYPE(Word8,8,False)
44 SIZED_TYPE(Word16,16,False)
45 SIZED_TYPE(Word32,32,False)
46 SIZED_TYPE(Word64,64,False)