bluefin-random-0.0.16.1: The Bluefin effect system, random generators
Safe HaskellNone
LanguageHaskell2010

Bluefin.Random

Synopsis

Handle

data Random g (e :: Effects) Source #

Instances

Instances details
Handle (Random g) Source # 
Instance details

Defined in Bluefin.Random

Methods

mapHandle :: forall (e :: Effects) (es :: Effects). e :> es => Random g e -> Random g es #

(e :> es, RandomGen g) => StatefulGen (Random g e) (Eff es) Source # 
Instance details

Defined in Bluefin.Random

Handlers

withInitStdGen Source #

Arguments

:: forall (e1 :: Effects) (es :: Effects) a. e1 :> es 
=> IOE e1 
-> (forall (e :: Effects). Random StdGen e -> Eff (e :& es) a) 
-> Eff es a

͘

The simplest way to handle a Bluefin Random effect. This is the handler you should use unless you know you have a particular need to use a RandomGen other than StdGen or you know you need to create a StdGen seed in a non-standard way.

Special purpose handlers

In the vast majority of cases you should use withInitStdGen and you won't have any need for these special purpose handlers.

evalRandom Source #

Arguments

:: forall g (es :: Effects) a. g 
-> (forall (e :: Effects). Random g e -> Eff (e :& es) a) 
-> Eff es a

͘

runRandom Source #

Arguments

:: forall g (es :: Effects) a. g 
-> (forall (e :: Effects). Random g e -> Eff (e :& es) a) 
-> Eff es (a, g)

͘

Effectful operations

To run random operations in Bluefin you should use the random operations in the System.Random.Stateful module from the random package. Here are their type signatures when restricted to Bluefin's Random:

uniformM ::
  (Uniform a, RandomGen g, e1 :> es) =>
  Random g e1 ->
  Eff es a
uniformRM ::
  (UniformRange a, RandomGen g, e1 :> es) =>
  (a, a) ->
  Random g e1 ->
  Eff es a
uniformListM ::
  (Uniform a, RandomGen g, e1 :> es) =>
  Int ->
  Random g e1 ->
  Eff es [a]
uniformListRM ::
  (UniformRange a, RandomGen g, e1 :> es) =>
  Int ->
  (a, a) ->
  Random g e1 ->
  Eff es [a]
uniformShuffleListM ::
  (RandomGen g, e1 :> es) =>
  [a] ->
  Random g e1 ->
  Eff es [a]
uniformByteArrayM ::
  (RandomGen g, e1 :> es) =>
  Bool ->
  Int ->
  Random g e1 ->
  Eff es ByteArray
uniformByteStringM ::
  (RandomGen g, e1 :> es) =>
  Int ->
  Random g e1 ->
  Eff es ByteString
uniformShortByteStringM ::
  (RandomGen g, e1 :> es) =>
  Int ->
  Random g e1 ->
  Eff es ShortByteString
uniformDouble01M ::
  (RandomGen g, e1 :> es) =>
  Random g e1 ->
  Eff es Double
uniformDoublePositive01M ::
  (RandomGen g, e1 :> es) =>
  Random g e1 ->
  Eff es Double
uniformFloat01M ::
  (RandomGen g, e1 :> es) =>
  Random g e1 ->
  Eff es Float
uniformFloatPositive01M ::
  (RandomGen g, e1 :> es) =>
  Random g e1 ->
  Eff es Float

Internal details

RandomPure is an internal detail that is used to implement a FrozenGen instance for Random. You may see it in error messages, so we include it here from completeness. You will most likely never need to use RandomPure directly.

data RandomPure g (e :: Effects) Source #

Instances

Instances details
RandomGen g => RandomGen (RandomPure g e) Source # 
Instance details

Defined in Bluefin.Random

(e :> es, RandomGen g) => FrozenGen (RandomPure g e) (Eff es) Source # 
Instance details

Defined in Bluefin.Random

Associated Types

type MutableGen (RandomPure g e) (Eff es) 
Instance details

Defined in Bluefin.Random

type MutableGen (RandomPure g e) (Eff es) = Random g e

Methods

freezeGen :: MutableGen (RandomPure g e) (Eff es) -> Eff es (RandomPure g e) #

modifyGen :: MutableGen (RandomPure g e) (Eff es) -> (RandomPure g e -> (a, RandomPure g e)) -> Eff es a #

overwriteGen :: MutableGen (RandomPure g e) (Eff es) -> RandomPure g e -> Eff es () #

type MutableGen (RandomPure g e) (Eff es) Source # 
Instance details

Defined in Bluefin.Random

type MutableGen (RandomPure g e) (Eff es) = Random g e