module Main where import Control.Monad import Control.Monad.Instances import Data.Bits import Data.Int import Data.Word import qualified Data.ByteString as B #if defined(CHASH) import System.IO.Unsafe import Foreign.C.Types import Foreign.C.String foreign import ccall "ctest.h hash" chash :: CString -> Int -> IO Int32 hashByteString :: B.ByteString -> Int32 hashByteString s = unsafePerformIO $ B.useAsCStringLen s $ \(cstr, len) -> chash cstr len #else import HashByteString #endif main :: IO () main = do s <- B.readFile "test.input" putStrLn (show $ hashByteString s)