Copyright | (c) Justin Le 2021 |
---|---|
License | BSD-3 |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
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
- newtype GUniform a = GUniform {
- getGUniform :: a
- gUniformM :: forall a g m. (ADTRecord a, Constraints a Uniform, StatefulGen g m) => g -> m a
- gUniformRM :: forall a g m. (ADTRecord a, Constraints a UniformRange, StatefulGen g m) => (a, a) -> g -> m a
- gUniformListM :: forall a g m. (ADTRecord a, Constraints a Uniform, StatefulGen g m) => Int -> g -> m [a]
- gRandomM :: forall a g m r. (ADTRecord a, Constraints a Random, RandomGenM g r m) => g -> m a
- gRandomRM :: forall a g m r. (ADTRecord a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a
- newtype GUniformSum a = GUniformSum {
- getGUniformSum :: a
- gUniformSumM :: forall a g m. (ADT a, Constraints a Uniform, StatefulGen g m) => g -> m a
- gUniformRSumM :: forall a g m. (ADT a, Constraints a UniformRange, StatefulGen g m) => (a, a) -> g -> m a
- gUniformSumListM :: forall a g m. (ADT a, Constraints a Uniform, StatefulGen g m) => Int -> g -> m [a]
- gRandomSumM :: forall a g m r. (ADT a, Constraints a Random, RandomGenM g r m) => g -> m a
- gRandomRSumM :: forall a g m r. (ADT a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a
Single constructor
Newtype wrapper
If a
is a data type with a single constructor whose fields are all
instances of Uniform
, then
has a GUniform
aUniform
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
.
GUniform | |
|
Instances
Functor GUniform Source # | |
Foldable GUniform Source # | |
Defined in System.Random.Stateful.OneLiner 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 # elem :: Eq a => a -> GUniform a -> Bool # maximum :: Ord a => GUniform a -> a # minimum :: Ord a => GUniform a -> a # | |
Traversable GUniform Source # | |
Defined in System.Random.Stateful.OneLiner | |
Eq a => Eq (GUniform a) Source # | |
Data a => Data (GUniform a) Source # | |
Defined in System.Random.Stateful.OneLiner 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 # | |
Defined in System.Random.Stateful.OneLiner | |
Read a => Read (GUniform a) Source # | |
Show a => Show (GUniform a) Source # | |
Generic (GUniform a) Source # | |
(ADTRecord a, Constraints a Uniform) => Uniform (GUniform a) Source # | |
Defined in System.Random.Stateful.OneLiner uniformM :: StatefulGen g m => g -> m (GUniform a) # | |
(ADTRecord a, Constraints a UniformRange) => UniformRange (GUniform a) Source # | |
Defined in System.Random.Stateful.OneLiner | |
type Rep (GUniform a) Source # | |
Defined in System.Random.Stateful.OneLiner |
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 #
gRandomRM :: forall a g m r. (ADTRecord a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a Source #
Multiple constructor
Newtype wrapper
newtype GUniformSum a Source #
If a
is a data type whose fields are all instances of Uniform
, then
has a GUniform
aUniform
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
!
Instances
Generics-derived methods
gUniformSumM :: forall a g m. (ADT a, Constraints a Uniform, StatefulGen g m) => g -> m a Source #
gUniformRSumM :: forall a g m. (ADT a, Constraints a UniformRange, StatefulGen g m) => (a, a) -> g -> m a Source #
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 #
gRandomRSumM :: forall a g m r. (ADT a, Constraints a Random, RandomGenM g r m) => (a, a) -> g -> m a Source #