one-liner-instances-0.1.3.0: Generics-based implementations for common typeclasses
Copyright(c) Justin Le 2021
LicenseBSD-3
Maintainerjustin@jle.im
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

System.Random.Stateful.OneLiner

Description

Derived methods for Uniform, 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 Uniform.

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

Since: 0.1.3.0

Synopsis

Single constructor

Newtype wrapper

newtype GUniform a Source #

If a is a data type with a single constructor whose fields are all instances of Uniform, then GUniform a has a Uniform 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 GUniformSum.

Constructors

GUniform 

Fields

Instances

Instances details
Functor GUniform Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

fmap :: (a -> b) -> GUniform a -> GUniform b #

(<$) :: a -> GUniform b -> GUniform a #

Foldable GUniform Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

fold :: Monoid m => GUniform m -> m #

foldMap :: Monoid m => (a -> m) -> GUniform a -> m #

foldMap' :: Monoid m => (a -> m) -> GUniform a -> m #

foldr :: (a -> b -> b) -> b -> GUniform a -> b #

foldr' :: (a -> b -> b) -> b -> GUniform a -> b #

foldl :: (b -> a -> b) -> b -> GUniform a -> b #

foldl' :: (b -> a -> b) -> b -> GUniform a -> b #

foldr1 :: (a -> a -> a) -> GUniform a -> a #

foldl1 :: (a -> a -> a) -> GUniform a -> a #

toList :: GUniform a -> [a] #

null :: GUniform a -> Bool #

length :: GUniform a -> Int #

elem :: Eq a => a -> GUniform a -> Bool #

maximum :: Ord a => GUniform a -> a #

minimum :: Ord a => GUniform a -> a #

sum :: Num a => GUniform a -> a #

product :: Num a => GUniform a -> a #

Traversable GUniform Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

traverse :: Applicative f => (a -> f b) -> GUniform a -> f (GUniform b) #

sequenceA :: Applicative f => GUniform (f a) -> f (GUniform a) #

mapM :: Monad m => (a -> m b) -> GUniform a -> m (GUniform b) #

sequence :: Monad m => GUniform (m a) -> m (GUniform a) #

Eq a => Eq (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

(==) :: GUniform a -> GUniform a -> Bool #

(/=) :: GUniform a -> GUniform a -> Bool #

Data a => Data (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GUniform a -> c (GUniform a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GUniform a) #

toConstr :: GUniform a -> Constr #

dataTypeOf :: GUniform a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GUniform a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GUniform a)) #

gmapT :: (forall b. Data b => b -> b) -> GUniform a -> GUniform a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GUniform a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GUniform a -> r #

gmapQ :: (forall d. Data d => d -> u) -> GUniform a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> GUniform a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> GUniform a -> m (GUniform a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GUniform a -> m (GUniform a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GUniform a -> m (GUniform a) #

Ord a => Ord (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

compare :: GUniform a -> GUniform a -> Ordering #

(<) :: GUniform a -> GUniform a -> Bool #

(<=) :: GUniform a -> GUniform a -> Bool #

(>) :: GUniform a -> GUniform a -> Bool #

(>=) :: GUniform a -> GUniform a -> Bool #

max :: GUniform a -> GUniform a -> GUniform a #

min :: GUniform a -> GUniform a -> GUniform a #

Read a => Read (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Show a => Show (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

showsPrec :: Int -> GUniform a -> ShowS #

show :: GUniform a -> String #

showList :: [GUniform a] -> ShowS #

Generic (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Associated Types

type Rep (GUniform a) :: Type -> Type #

Methods

from :: GUniform a -> Rep (GUniform a) x #

to :: Rep (GUniform a) x -> GUniform a #

(ADTRecord a, Constraints a Uniform) => Uniform (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

uniformM :: StatefulGen g m => g -> m (GUniform a) #

(ADTRecord a, Constraints a UniformRange) => UniformRange (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

uniformRM :: StatefulGen g m => (GUniform a, GUniform a) -> g -> m (GUniform a) #

type Rep (GUniform a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

type Rep (GUniform a) = D1 ('MetaData "GUniform" "System.Random.Stateful.OneLiner" "one-liner-instances-0.1.3.0-KGYaKgOm9Pn8Wcz4AhCIIX" 'True) (C1 ('MetaCons "GUniform" 'PrefixI 'True) (S1 ('MetaSel ('Just "getGUniform") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Generics-derived methods

gUniformM :: forall a g m. (ADTRecord a, Constraints a Uniform, StatefulGen g m) => g -> m a Source #

gUniformRM :: forall a g m. (ADTRecord a, Constraints a UniformRange, StatefulGen g m) => (a, a) -> g -> m a Source #

gUniformListM :: forall a g m. (ADTRecord a, Constraints a Uniform, StatefulGen g m) => Int -> g -> m [a] Source #

gRandomM :: forall a g m r. (ADTRecord a, Constraints a Random, RandomGenM g r m) => g -> m a Source #

Uses the Random instance instead of the Uniform instance.

gRandomRM :: forall a g m r. (ADTRecord a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a Source #

Uses the Random instance instead of the Uniform instance.

Multiple constructor

Newtype wrapper

newtype GUniformSum a Source #

If a is a data type whose fields are all instances of Uniform, then GUniform a has a Uniform instance.

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

A version of GUniform that works for data types with multiple constructors. If your type has only one constructor, it might be more performant to use GUniform.

Note that the "ranged" variants are partial: if given a range of items made with different constructors, will be error!

Constructors

GUniformSum 

Fields

Instances

Instances details
Functor GUniformSum Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

fmap :: (a -> b) -> GUniformSum a -> GUniformSum b #

(<$) :: a -> GUniformSum b -> GUniformSum a #

Foldable GUniformSum Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

fold :: Monoid m => GUniformSum m -> m #

foldMap :: Monoid m => (a -> m) -> GUniformSum a -> m #

foldMap' :: Monoid m => (a -> m) -> GUniformSum a -> m #

foldr :: (a -> b -> b) -> b -> GUniformSum a -> b #

foldr' :: (a -> b -> b) -> b -> GUniformSum a -> b #

foldl :: (b -> a -> b) -> b -> GUniformSum a -> b #

foldl' :: (b -> a -> b) -> b -> GUniformSum a -> b #

foldr1 :: (a -> a -> a) -> GUniformSum a -> a #

foldl1 :: (a -> a -> a) -> GUniformSum a -> a #

toList :: GUniformSum a -> [a] #

null :: GUniformSum a -> Bool #

length :: GUniformSum a -> Int #

elem :: Eq a => a -> GUniformSum a -> Bool #

maximum :: Ord a => GUniformSum a -> a #

minimum :: Ord a => GUniformSum a -> a #

sum :: Num a => GUniformSum a -> a #

product :: Num a => GUniformSum a -> a #

Traversable GUniformSum Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

traverse :: Applicative f => (a -> f b) -> GUniformSum a -> f (GUniformSum b) #

sequenceA :: Applicative f => GUniformSum (f a) -> f (GUniformSum a) #

mapM :: Monad m => (a -> m b) -> GUniformSum a -> m (GUniformSum b) #

sequence :: Monad m => GUniformSum (m a) -> m (GUniformSum a) #

Eq a => Eq (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Data a => Data (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GUniformSum a -> c (GUniformSum a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GUniformSum a) #

toConstr :: GUniformSum a -> Constr #

dataTypeOf :: GUniformSum a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GUniformSum a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GUniformSum a)) #

gmapT :: (forall b. Data b => b -> b) -> GUniformSum a -> GUniformSum a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GUniformSum a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GUniformSum a -> r #

gmapQ :: (forall d. Data d => d -> u) -> GUniformSum a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> GUniformSum a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> GUniformSum a -> m (GUniformSum a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GUniformSum a -> m (GUniformSum a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GUniformSum a -> m (GUniformSum a) #

Ord a => Ord (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Read a => Read (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Show a => Show (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Generic (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Associated Types

type Rep (GUniformSum a) :: Type -> Type #

Methods

from :: GUniformSum a -> Rep (GUniformSum a) x #

to :: Rep (GUniformSum a) x -> GUniformSum a #

(ADT a, Constraints a Uniform) => Uniform (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

Methods

uniformM :: StatefulGen g m => g -> m (GUniformSum a) #

(ADT a, Constraints a UniformRange) => UniformRange (GUniformSum a) Source #

Note that this is partial: the range limits must have the same constructors.

Instance details

Defined in System.Random.Stateful.OneLiner

Methods

uniformRM :: StatefulGen g m => (GUniformSum a, GUniformSum a) -> g -> m (GUniformSum a) #

type Rep (GUniformSum a) Source # 
Instance details

Defined in System.Random.Stateful.OneLiner

type Rep (GUniformSum a) = D1 ('MetaData "GUniformSum" "System.Random.Stateful.OneLiner" "one-liner-instances-0.1.3.0-KGYaKgOm9Pn8Wcz4AhCIIX" 'True) (C1 ('MetaCons "GUniformSum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getGUniformSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Generics-derived methods

gUniformSumM :: forall a g m. (ADT a, Constraints a Uniform, StatefulGen g m) => g -> m a Source #

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

gUniformRSumM :: forall a g m. (ADT a, Constraints a UniformRange, StatefulGen g m) => (a, a) -> g -> m a Source #

randomR implemented by sequencing randomR between all components.

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

gUniformSumListM :: forall a g m. (ADT a, Constraints a Uniform, StatefulGen g m) => Int -> g -> m [a] Source #

gRandomSumM :: forall a g m r. (ADT a, Constraints a Random, RandomGenM g r m) => g -> m a Source #

Uses the Random instance instead of the Uniform instance.

gRandomRSumM :: forall a g m r. (ADT a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a Source #

Uses the Random instance instead of the Uniform instance.