Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype RollingHash (b :: Nat) = RollingHash {}
- asRollingHashOf :: RollingHash b -> Proxy b -> RollingHash b
- isPrimitiveRootRH :: Int -> Bool
- genPrimitiveRootRH :: RandomGen g => g -> Int
- withPrimitiveRootRH :: RandomGen g => g -> (forall b. KnownNat b => Proxy b -> a) -> a
Documentation
newtype RollingHash (b :: Nat) Source #
modulo 2^61-1
b
should be a primitive root of 2^61-1
Instances
asRollingHashOf :: RollingHash b -> Proxy b -> RollingHash b Source #
isPrimitiveRootRH :: Int -> Bool Source #
check if g
is a primitive root of 2^61-1
.
>>>
isPrimitiveRootRH 2047
True>>>
take 10 $ filter isPrimitiveRootRH [2..]
[37,43,55,69,74,86,110,123,133,138]
genPrimitiveRootRH :: RandomGen g => g -> Int Source #
Generate a primitive root of 2^61-1
.
>>>
genPrimitiveRootRH (mkStdGen 123)
1600615663002506808>>>
isPrimitiveRootRH 1600615663002506808
True
withPrimitiveRootRH :: RandomGen g => g -> (forall b. KnownNat b => Proxy b -> a) -> a Source #
>>>
withPrimitiveRootRH (mkStdGen 123) $ \proxy -> getRollingHash $ 456 `asRollingHashOf` proxy
456