| Copyright | (c) Ben Weitzman 2018 | 
|---|---|
| License | MIT | 
| Maintainer | ben@costarastrolgoy.com | 
| Stability | experimental | 
| Portability | POSIX | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Control.Monad.Freer.Random
Description
Synopsis
- data Random typs a
 - random :: forall a typs r p. (Random a, FindInList a typs) => Eff (Random typs ': r) a
 - randomR :: forall a typs r p. (Random a, FindInList a typs) => (a, a) -> Eff (Random typs ': r) a
 - runRandom :: forall t r a. Member IO r => Eff (Random t ': r) a -> Eff r a
 - knownRandom :: forall typ a r v. a -> Eff (Random (a ': typ) ': r) v -> Eff (Random typ ': r) v
 - runRandomWithSeed :: forall typ r v. Int -> Eff (Random typ ': r) v -> Eff r v
 - silentRandom :: Eff (Random '[] ': r) v -> Eff r v
 - class FindInList a as
 
Documentation
random :: forall a typs r p. (Random a, FindInList a typs) => Eff (Random typs ': r) a Source #
Generate a single random value
randomR :: forall a typs r p. (Random a, FindInList a typs) => (a, a) -> Eff (Random typs ': r) a Source #
Generate a single random value in a range
runRandom :: forall t r a. Member IO r => Eff (Random t ': r) a -> Eff r a Source #
Use the IO effect to handle generation of random values
knownRandom :: forall typ a r v. a -> Eff (Random (a ': typ) ': r) v -> Eff (Random typ ': r) v Source #
Use a single given value as the "random" value. The given value is always used, even if it's
 outside the range given to randomR  
runRandomWithSeed :: forall typ r v. Int -> Eff (Random typ ': r) v -> Eff r v Source #
Use a seed + a PRNG to handle generation of random values.
silentRandom :: Eff (Random '[] ': r) v -> Eff r v Source #
Eliminate a Random effect that doesn't generate any values
class FindInList a as Source #
Find a type inside of a type level list. Used to write code that generates multiple types of random values that are polymorphic over the set of all random values that are generated.
getARandomNumber :: (FindInListInttyps) =>Eff(Randomtyps ': r)IntgetARandomNumber = random getARandomBool :: (FindInListBooltyps) =>Eff(Randomtyps ': r)BoolgetARandomBool = random getABoolAndInt :: (FindInListBooltyps,FindInListInttyps) =>Eff(Randomtyps ': r)IntgetABoolAndInt = do rInt <- getARandomNumber rBool <- getARandomBool if rBool then return rInt else return $ rInt + 1
Minimal complete definition
find
Instances
| FindInList a as => FindInList a (b ': as) Source # | |
Defined in Control.Monad.Freer.Random Methods find :: Elem a (b ': as)  | |
| FindInList a (a ': as) Source # | |
Defined in Control.Monad.Freer.Random Methods find :: Elem a (a ': as)  | |