Copyright | Copyright (c) 2014-2015 Christopher Chalmers <c.chalmers@me.com> |
---|---|
License | BSD3 |
Maintainer | Christopher Chalmers <c.chalmers@me.com> |
Stability | experimental |
Portability | CPP |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Classes for working with random numbers along with utility functions. In a future release this module may disappear and use another module for this functionality.
Synopsis
- class Monad m => Generator g m where
- class Variate a where
- uniformW8 :: Generator g m => g -> m Word8
- uniformW16 :: Generator g m => g -> m Word16
- uniformW32 :: Generator g m => g -> m Word32
- uniformW64 :: Generator g m => g -> m Word64
- uniformI8 :: Generator g m => g -> m Int8
- uniformI16 :: Generator g m => g -> m Int16
- uniformI32 :: Generator g m => g -> m Int32
- uniformI64 :: Generator g m => g -> m Int64
- uniformF :: Generator g m => g -> m Float
- uniformD :: Generator g m => g -> m Double
- uniformBool :: Generator g m => g -> m Bool
- uniformRW8 :: Generator g m => (Word8, Word8) -> g -> m Word8
- uniformRW16 :: Generator g m => (Word16, Word16) -> g -> m Word16
- uniformRW32 :: Generator g m => (Word32, Word32) -> g -> m Word32
- uniformRW64 :: Generator g m => (Word64, Word64) -> g -> m Word64
- uniformRI8 :: Generator g m => (Int8, Int8) -> g -> m Int8
- uniformRI16 :: Generator g m => (Int16, Int16) -> g -> m Int16
- uniformRI32 :: Generator g m => (Int32, Int32) -> g -> m Int32
- uniformRI64 :: Generator g m => (Int64, Int64) -> g -> m Int64
- uniformRF :: Generator g m => (Float, Float) -> g -> m Float
- uniformRD :: Generator g m => (Double, Double) -> g -> m Double
- uniformRBool :: Generator g m => (Bool, Bool) -> g -> m Bool
- uniformBW8 :: Generator g m => Word8 -> g -> m Word8
- uniformBW16 :: Generator g m => Word16 -> g -> m Word16
- uniformBW32 :: Generator g m => Word32 -> g -> m Word32
- uniformBW64 :: Generator g m => Word64 -> g -> m Word64
- uniformBI8 :: Generator g m => Int8 -> g -> m Int8
- uniformBI16 :: Generator g m => Int16 -> g -> m Int16
- uniformBI32 :: Generator g m => Int32 -> g -> m Int32
- uniformBI64 :: Generator g m => Int64 -> g -> m Int64
- uniformBF :: Generator g m => Float -> g -> m Float
- uniformBD :: Generator g m => Double -> g -> m Double
- uniformBBool :: Generator g m => Bool -> g -> m Bool
- type family Unsigned a :: Type
- wordsTo64Bit :: Integral a => Word32 -> Word32 -> a
- wordToBool :: Word32 -> Bool
- wordToFloat :: Word32 -> Float
- wordsToDouble :: Word32 -> Word32 -> Double
- sysRandom :: IO Word64
Classes
class Monad m => Generator g m where Source #
uniform1 :: (Word32 -> a) -> g -> m a Source #
uniform2 :: (Word32 -> Word32 -> a) -> g -> m a Source #
uniform1B :: Integral a => (Word32 -> a) -> Word32 -> g -> m a Source #
Instances
Generator Gen IO Source # | |
(PrimMonad m, s ~ PrimState m) => Generator (Gen s) m Source # | |
(PrimMonad m, s ~ PrimState m) => Generator (Gen s) m Source # | |
(PrimMonad m, s ~ PrimState m) => Generator (Gen s) m Source # | |
(PrimMonad m, s ~ PrimState m) => Generator (Gen s) m Source # | |
(PrimMonad m, s ~ PrimState m) => Generator (Gen s) m Source # | |
class Variate a where Source #
uniform :: Generator g m => g -> m a Source #
Generate a uniformly distributed random vairate.
- Use entire range for integral types.
- Use (0,1] range for floating types.
uniformR :: Generator g m => (a, a) -> g -> m a Source #
Generate a uniformly distributed random vairate in the given range.
- Use inclusive range for integral types.
- Use (a,b] range for floating types.
uniformB :: Generator g m => a -> g -> m a Source #
Generate a uniformly distributed random vairate in the range
[0,b). For integral types the bound must be less than the max bound
of Word32
(4294967295). Behaviour is undefined for negative
bounds.
Instances
Variate Int16 Source # | |
Variate Int32 Source # | |
Variate Int64 Source # | |
Variate Int8 Source # | |
Variate Word16 Source # | |
Variate Word32 Source # | |
Variate Word64 Source # | |
Variate Word8 Source # | |
Variate Bool Source # | |
Variate Double Source # | |
Variate Float Source # | |
Variate Int Source # | |
Variate Word Source # | |
(Variate a, Variate b) => Variate (a, b) Source # | |
(Variate a, Variate b, Variate c) => Variate (a, b, c) Source # | |
(Variate a, Variate b, Variate c, Variate d) => Variate (a, b, c, d) Source # | |
Type restricted versions
uniform
uniformW16 :: Generator g m => g -> m Word16 Source #
uniformW32 :: Generator g m => g -> m Word32 Source #
uniformW64 :: Generator g m => g -> m Word64 Source #
uniformI16 :: Generator g m => g -> m Int16 Source #
uniformI32 :: Generator g m => g -> m Int32 Source #
uniformI64 :: Generator g m => g -> m Int64 Source #
uniformBool :: Generator g m => g -> m Bool Source #
uniformR
uniformB
Utilities
type family Unsigned a :: Type Source #
Instances
type Unsigned Int16 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Int32 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Int64 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Int8 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Word16 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Word32 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Word64 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Word8 Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Int Source # | |
Defined in System.Random.PCG.Class | |
type Unsigned Word Source # | |
Defined in System.Random.PCG.Class |
wordToBool :: Word32 -> Bool Source #
wordToFloat :: Word32 -> Float Source #