one-liner-instances-0.1.3.0: Generics-based implementations for common typeclasses

System.Random.OneLiner

Description

Derived methods for Random, using Generics.OneLiner and GHC.Generics.

Can be used for any types (deriving Generic) made with a single constructor, where every field is an instance of Random.

Also includes a newtype wrapper that imbues any such data type with instant Random instances, which can one day be used with DerivingVia syntax to derive instances automatically.

Since: 0.1.2.1

Synopsis

# Single constructor

## Newtype wrapper

newtype GRandom a Source #

If a is a data type with a single constructor whose fields are all instances of Random, then GRandom a has a Random instance.

Will one day be able to be used with DerivingVia syntax, to derive instances automatically.

Only works with data types with single constructors. If you need it to work with types of multiple constructors, consider GRandomSum.

Since: 0.1.2.1

Constructors

 GRandom FieldsgetGRandom :: a

#### Instances

Instances details

## Generics-derived methods

gRandomRSum :: forall a g. (ADT a, Constraints a Random, RandomGen g) => (a, a) -> g -> (a, g) Source #

randomR implemented by sequencing randomR between all components.

If given a range of items made with different constructors, will be error!

Since: 0.1.2.1

gRandomSum :: forall a g. (ADT a, Constraints a Random, RandomGen g) => g -> (a, g) Source #

random implemented by selecting a random constructor and sequencing random for all components.

Since: 0.1.2.1

gRandomRSums :: forall a g. (ADT a, Constraints a Random, RandomGen g) => (a, a) -> g -> [a] Source #

randomRs implemented by repeatedly calling gRandomRSum.

If given a range of items made with different constructors, will be error!

Since: 0.1.2.1

gRandomSums :: forall a g. (ADT a, Constraints a Random, RandomGen g) => g -> [a] Source #

randoms implemented by repeatedly calling gRandomSum.

Since: 0.1.2.1

gRandomRIOSum :: forall a. (ADT a, Constraints a Random) => (a, a) -> IO a Source #

randomRIO implemented by calling gRandomRSum on the global seed.

If given a range of items made with different constructors, will be error!

Since: 0.1.2.1

gRandomIOSum :: forall a. (ADT a, Constraints a Random) => IO a Source #

randomIO implemented by calling gRandom on the global seed.