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 {-# SPECIALISE instance Hashable [Char] #-}
47 instance (Hashable a, Hashable b) => Hashable (a,b) where
48 hash (a,b) = hash a + 3 * hash b
50 instance (Hashable a, Hashable b, Hashable c) => Hashable (a,b,c) where
51 hash (a,b,c) = hash a + 3 * hash b + 5 * hash c
53 instance (Hashable a, Hashable b, Hashable c, Hashable d) => Hashable (a,b,c,d) where
54 hash (a,b,c,d) = hash a + 3 * hash b + 5 * hash c + 7 * hash d
56 instance (Hashable a, Hashable b, Hashable c, Hashable d, Hashable e) => Hashable (a,b,c,d,e) where
57 hash (a,b,c,d,e) = hash a + 3 * hash b + 5 * hash c + 7 * hash d + 9 * hash e
59 instance Hashable Bool where
63 instance (Integral a, Hashable a) => Hashable (Ratio a) where
64 hash x = hash (denominator x) + hash (numerator x)
66 instance (RealFloat a, Hashable a) => Hashable (Complex a) where
67 hash (x :+ y) = hash x + hash y
70 instance (Hashable a, Hashable b) => Hashable (Assoc a b) where
71 hash (x := y) = hash x + hash y
74 instance (Ix a) => Hashable (Array a b) where
78 instance Hashable Request where
81 instance Hashable Response where
84 instance Hashable IOError where
93 else (-h) `rem` maxhash