never executed always true always false
    1 
    2 
    3 -- | Computing fingerprints of values serializeable with GHC's \"Binary\" module.
    4 module GHC.Iface.Recomp.Binary
    5   ( -- * Computing fingerprints
    6     fingerprintBinMem
    7   , computeFingerprint
    8   , putNameLiterally
    9   ) where
   10 
   11 import GHC.Prelude
   12 
   13 import GHC.Utils.Fingerprint
   14 import GHC.Utils.Binary
   15 import GHC.Types.Name
   16 import GHC.Utils.Panic.Plain
   17 
   18 fingerprintBinMem :: BinHandle -> IO Fingerprint
   19 fingerprintBinMem bh = withBinBuffer bh f
   20   where
   21     f bs =
   22         -- we need to take care that we force the result here
   23         -- lest a reference to the ByteString may leak out of
   24         -- withBinBuffer.
   25         let fp = fingerprintByteString bs
   26         in fp `seq` return fp
   27 
   28 computeFingerprint :: (Binary a)
   29                    => (BinHandle -> Name -> IO ())
   30                    -> a
   31                    -> IO Fingerprint
   32 computeFingerprint put_nonbinding_name a = do
   33     bh <- fmap set_user_data $ openBinMem (3*1024) -- just less than a block
   34     put_ bh a
   35     fingerprintBinMem bh
   36   where
   37     set_user_data bh =
   38       setUserData bh $ newWriteState put_nonbinding_name putNameLiterally putFS
   39 
   40 -- | Used when we want to fingerprint a structure without depending on the
   41 -- fingerprints of external Names that it refers to.
   42 putNameLiterally :: BinHandle -> Name -> IO ()
   43 putNameLiterally bh name = assert (isExternalName name) $ do
   44     put_ bh $! nameModule name
   45     put_ bh $! nameOccName name