never executed always true always false
    1 
    2 {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
    3 
    4 -- ----------------------------------------------------------------------------
    5 --
    6 --  (c) The University of Glasgow 2006
    7 --
    8 -- Fingerprints for recompilation checking and ABI versioning.
    9 --
   10 -- https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/recompilation-avoidance
   11 --
   12 -- ----------------------------------------------------------------------------
   13 
   14 module GHC.Utils.Fingerprint (
   15         readHexFingerprint,
   16         fingerprintByteString,
   17         -- * Re-exported from GHC.Fingerprint
   18         Fingerprint(..), fingerprint0,
   19         fingerprintFingerprints,
   20         fingerprintData,
   21         fingerprintString,
   22         getFileHash
   23    ) where
   24 
   25 import GHC.Prelude
   26 
   27 import Foreign
   28 import GHC.IO
   29 import Numeric          ( readHex )
   30 
   31 import qualified Data.ByteString as BS
   32 import qualified Data.ByteString.Unsafe as BS
   33 
   34 import GHC.Fingerprint
   35 
   36 -- useful for parsing the output of 'md5sum', should we want to do that.
   37 readHexFingerprint :: String -> Fingerprint
   38 readHexFingerprint s = Fingerprint w1 w2
   39  where (s1,s2) = splitAt 16 s
   40        [(w1,"")] = readHex s1
   41        [(w2,"")] = readHex (take 16 s2)
   42 
   43 fingerprintByteString :: BS.ByteString -> Fingerprint
   44 fingerprintByteString bs = unsafeDupablePerformIO $
   45   BS.unsafeUseAsCStringLen bs $ \(ptr, len) -> fingerprintData (castPtr ptr) len