Skip to content

Commit dfebc76

Browse files
authored
Merge pull request #124 from andrewthad/higher_kinded_classes
Higher kinded classes
2 parents a5bb09f + b6b9f6d commit dfebc76

File tree

8 files changed

+462
-81
lines changed

8 files changed

+462
-81
lines changed

Data/Hashable.hs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ module Data.Hashable
7070
, unhashed
7171
) where
7272

73-
import Data.String (IsString(..))
74-
import Data.Typeable (Typeable)
75-
import Data.Foldable (Foldable(foldr))
7673
import Data.Hashable.Class
74+
7775
#ifdef GENERICS
7876
import Data.Hashable.Generic ()
7977
#endif
@@ -212,32 +210,3 @@ import Data.Hashable.Generic ()
212210
-- > hashWithSalt s (Months n) = s `hashWithSalt`
213211
-- > (2::Int) `hashWithSalt` n
214212

215-
-- | A hashable value along with the result of the 'hash' function.
216-
data Hashed a = Hashed a {-# UNPACK #-} !Int
217-
deriving (Typeable,Show)
218-
219-
-- | Wrap a hashable value, caching the 'hash' function result.
220-
hashed :: Hashable a => a -> Hashed a
221-
hashed a = Hashed a (hash a)
222-
223-
-- | Unwrap hashed value.
224-
unhashed :: Hashed a -> a
225-
unhashed (Hashed a _) = a
226-
227-
-- | Uses precomputed hash to detect inequality faster
228-
instance Eq a => Eq (Hashed a) where
229-
Hashed a ha == Hashed b hb = ha == hb && a == b
230-
231-
instance Ord a => Ord (Hashed a) where
232-
Hashed a _ `compare` Hashed b _ = a `compare` b
233-
234-
instance Hashable a => Hashable (Hashed a) where
235-
hashWithSalt = defaultHashWithSalt
236-
hash (Hashed _ h) = h
237-
238-
instance (IsString a, Hashable a) => IsString (Hashed a) where
239-
fromString s = let r = fromString s in Hashed r (hash r)
240-
241-
instance Foldable Hashed where
242-
foldr f acc (Hashed a _) = f a acc
243-

0 commit comments

Comments
 (0)