Copyright | (C) 2021 QBayLogic B.V. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
Random generation of unique variables and unique containers.
Synopsis
- genUnique :: forall m. MonadGen m => m Unique
- genUniqMap :: forall m k v. (MonadGen m, Uniquable k) => Range Int -> m k -> m v -> m (UniqMap v)
- sampleUniqMap :: forall m v. (Alternative m, MonadGen m, HasType v) => (v -> Bool) -> Type -> UniqMap v -> m (v, [Type])
- sampleAnyUniqMap :: forall m v. (Alternative m, MonadGen m, HasType v) => UniqMap v -> m (v, [Type])
- genUniqSet :: forall m v. (MonadGen m, Uniquable v) => Range Int -> m v -> m (UniqSet v)
- class Bias a where
- sampleUniqMapBiased :: forall m v. (Alternative m, MonadGen m, HasType v, Bias v) => (v -> Bool) -> Type -> UniqMap v -> m (v, [Type])
Documentation
genUniqMap :: forall m k v. (MonadGen m, Uniquable k) => Range Int -> m k -> m v -> m (UniqMap v) Source #
sampleUniqMap :: forall m v. (Alternative m, MonadGen m, HasType v) => (v -> Bool) -> Type -> UniqMap v -> m (v, [Type]) Source #
sampleAnyUniqMap :: forall m v. (Alternative m, MonadGen m, HasType v) => UniqMap v -> m (v, [Type]) Source #
Determine the bias of an item. This is used to set the weight of that item
so we can sample using the frequency
generator instead of
element
or choice
.
Where might you want to introduce such a bias? If there is a collection of
elements where there is a likeliness that real code would use certain values
more or less, we want to be able to capture this. An obvious example of this
is the TyConMap
, where without it every constructor would have an even
weighting, when in reality some (like Void#
or Addr#
are much less
likely to appear in code written by a Clash user).
sampleUniqMapBiased :: forall m v. (Alternative m, MonadGen m, HasType v, Bias v) => (v -> Bool) -> Type -> UniqMap v -> m (v, [Type]) Source #