3 -- Hash a value. Hashing produces an Int of
10 instance Hashable Char where
13 instance Hashable Int where
16 instance Hashable Integer where
17 hash x = fromInteger x
19 instance Hashable Float where
22 instance Hashable Double where
25 instance Hashable Bin where
29 instance Hashable File where
33 instance Hashable () where
36 instance Hashable (a -> b) where
39 instance Hashable a => Hashable [a] where
41 where f :: (Hashable a) => [a] -> Int -> Int
43 f (c:cs) r = f cs (3*r + hash c)
45 #if defined(__OVERLAPPING_INSTANCES__)
46 instance Hashable [Char] where
48 where f :: String -> Int -> Int
50 f (c:cs) r = f cs (3*r + ord c)
53 instance (Hashable a, Hashable b) => Hashable (a,b) where
54 hash (a,b) = hash a + 3 * hash b
56 instance (Hashable a, Hashable b, Hashable c) => Hashable (a,b,c) where
57 hash (a,b,c) = hash a + 3 * hash b + 5 * hash c
59 instance (Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a,b,c,d) where
60 hash (a,b,c,d) = hash a + 3 * hash b + 5 * hash c + 7 * hash d
62 instance (Hashable a, Hashable b, Hashable c, Hashable d, Hashable e) => Hashable (a,b,c,d,e) where
63 hash (a,b,c,d,e) = hash a + 3 * hash b + 5 * hash c + 7 * hash d + 9 * hash e
65 instance Hashable Bool where
69 instance (Integral a, Hashable a) => Hashable (Ratio a) where
70 hash x = hash (denominator x) + hash (numerator x)
72 instance (RealFloat a, Hashable a) => Hashable (Complex a) where
73 hash (x :+ y) = hash x + hash y
76 instance (Hashable a, Hashable b) => Hashable (Assoc a b) where
77 hash (x := y) = hash x + hash y
80 instance (Ix a) => Hashable (Array a b) where
84 instance Hashable Request where
87 instance Hashable Response where
90 instance Hashable IOError where
99 else (-h) `rem` maxhash