-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Automatically generates Hashable instances with GHC.Generics. -- -- This package provides a GHC.Generics-based -- Data.Hashable.Generic.gHashWithSalt function which can be used -- for providing a hashWithSalt implementation. See the -- documentation for the gHashWithSalt function in the -- Data.Hashable.Generic module to get start. -- -- This package is heavily inspired by deepseq-generics, which you may -- also find useful. @package hashable-generics @version 1.1.2 module Data.Hashable.Generic -- | GHC.Generics-based hashWithSalt implementation -- -- This provides a generic hashWithSalt implementation for one -- type at a time. If the type of the value gHashWithSalt is asked -- to hash contains values of other types, those types have to provide -- Hashable instances. This also means that recursive types can -- only be used with gHashWithSalt if a Hashable instance -- has been defined as well (see examples below). -- -- The typical usage for gHashWithSalt is for reducing boilerplate -- code when defining Hashable instances for ordinary algebraic -- datatypes. See the code below for some simple usage examples: -- --
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import Data.Hashable
--   import Data.Hashable.Generic ( gHashWithSalt )
--   import GHC.Generics
--   
--   -- simple record
--   data Foo = Foo AccountId Name Address
--            deriving Generic
--   
--   type Address      = [String]
--   type Name         = String
--   newtype AccountId = AccountId Int
--   
--   instance Hashable AccountId
--   instance Hashable Foo where hashWithSalt = gHashWithSalt
--   
--   -- recursive list-like type
--   data N = Z | S N deriving Generic
--   
--   instance Hashable N where hashWithSalt = gHashWithSalt
--   
--   -- parametric and recursive type
--   data Bar a = Bar0 | Bar1 a | Bar2 (Bar a)
--              deriving Generic
--   
--   instance Hashable a => Hashable (Bar a) where hashWithSalt = gHashWithSalt
--   
-- -- Note: The GHashable type-class showing up in the type-signature -- is used internally and not exported on purpose currently gHashWithSalt :: (Generic a, GHashable (Rep a)) => Int -> a -> Int -- | The class of types that can be converted to a hash value. -- -- Minimal implementation: hash or hashWithSalt. class Hashable a hash :: Hashable a => a -> Int hashWithSalt :: Hashable a => Int -> a -> Int instance (GHashable a, GHashable b) => GHashable (a :+: b) instance (GHashable a, GHashable b) => GHashable (a :*: b) instance GHashable a => GHashable (M1 i c a) instance Hashable a => GHashable (K1 i a) instance GHashable U1