Muk.hs (673B)
1 2 -- | 3 -- Module: Urbit.Ob.Muk 4 -- Copyright: (c) 2019 Jared Tobin 5 -- License: MIT 6 -- 7 -- Maintainer: Jared Tobin <jared@jtobin.io> 8 -- Stability: unstable 9 -- Portability: ghc 10 -- 11 -- A specific murmur3 variant. 12 -- 13 -- Analogous to +muk in hoon.hoon. 14 15 module Urbit.Ob.Muk ( 16 muk 17 ) where 18 19 import Data.Bits 20 import qualified Data.ByteString.Char8 as B8 21 import Data.Char 22 import Data.Word (Word32) 23 import qualified Data.Hash.Murmur as M 24 25 -- | A specific murmur3 variant. 26 muk :: Word32 -> Word32 -> Word32 27 muk syd key = M.murmur3 syd kee where 28 kee = chr lo `B8.cons` chr hi `B8.cons` mempty 29 lo = fromIntegral (key .&. 0xFF) 30 hi = fromIntegral (key .&. 0xFF00 `div` 0x0100) 31