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. -}
10 import NHC.FFI (Int8,Int16,Int32,Int64,Word8,Word16,Word32,Word64)
13 #define SIZED_TYPE(T,BS,S) \
15 ; INSTANCE_BITS(T,BS,S)
19 ; foreign import ccall nhc_prim/**/T/**/And :: T -> T -> T \
20 ; foreign import ccall nhc_prim/**/T/**/Or :: T -> T -> T \
21 ; foreign import ccall nhc_prim/**/T/**/Xor :: T -> T -> T \
22 ; foreign import ccall nhc_prim/**/T/**/Lsh :: T -> Int -> T \
23 ; foreign import ccall nhc_prim/**/T/**/Rsh :: T -> Int -> T \
24 ; foreign import ccall nhc_prim/**/T/**/Compl :: T -> T
27 #define INSTANCE_BITS(T,BS,S) \
28 ; instance Bits T where \
29 { (.&.) = nhc_prim/**/T/**/And \
30 ; (.|.) = nhc_prim/**/T/**/Or \
31 ; xor = nhc_prim/**/T/**/Xor \
32 ; complement = nhc_prim/**/T/**/Compl \
33 ; shiftL = nhc_prim/**/T/**/Lsh \
34 ; shiftR = nhc_prim/**/T/**/Rsh \
39 SIZED_TYPE(Int8,8,True)
40 SIZED_TYPE(Int16,16,True)
41 SIZED_TYPE(Int32,32,True)
42 SIZED_TYPE(Int64,64,True)
44 SIZED_TYPE(Word8,8,False)
45 SIZED_TYPE(Word16,16,False)
46 SIZED_TYPE(Word32,32,False)
47 SIZED_TYPE(Word64,64,False)