Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class Monad m ⇒ MonadGenError m where
- genError ∷ HasCallStack ⇒ NonEmpty String → m a
- fatalError ∷ HasCallStack ⇒ NonEmpty String → m a
- explain ∷ HasCallStack ⇒ NonEmpty String → m a → m a
- genError1 ∷ MonadGenError m ⇒ String → m a
- fatalError1 ∷ MonadGenError m ⇒ String → m a
- explain1 ∷ MonadGenError m ⇒ String → m a → m a
- data GE a
- catGEs ∷ MonadGenError m ⇒ [GE a] → m [a]
- fromGE ∷ (NonEmpty String → a) → GE a → a
- errorGE ∷ GE a → a
- isOk ∷ GE a → Bool
- runGE ∷ MonadGenError m ⇒ GE r → m r
- fromGEProp ∷ Testable p ⇒ GE p → Property
- fromGEDiscard ∷ Testable p ⇒ GE p → Property
- headGE ∷ Foldable t ⇒ t a → GE a
- listFromGE ∷ GE [a] → [a]
- data GenMode
- newtype GenT m a = GenT {}
- strictGen ∷ GenT m a → Gen (m a)
- genFromGenT ∷ GenT GE a → Gen a
- resizeT ∷ (Int → Int) → GenT m a → GenT m a
- pureGen ∷ Applicative m ⇒ Gen a → GenT m a
- listOfT ∷ MonadGenError m ⇒ GenT GE a → GenT m [a]
- listOfUntilLenT ∷ MonadGenError m ⇒ GenT GE a → Int → (Int → Bool) → GenT m [a]
- vectorOfT ∷ MonadGenError m ⇒ Int → GenT GE a → GenT m [a]
- suchThatT ∷ MonadGenError m ⇒ GenT m a → (a → Bool) → GenT m a
- suchThatWithTryT ∷ MonadGenError m ⇒ Int → GenT m a → (a → Bool) → GenT m a
- scaleT ∷ (Int → Int) → GenT m a → GenT m a
- getMode ∷ Applicative m ⇒ GenT m GenMode
- withMode ∷ GenMode → GenT m a → GenT m a
- oneofT ∷ MonadGenError m ⇒ [GenT GE a] → GenT m a
- frequencyT ∷ MonadGenError m ⇒ [(Int, GenT GE a)] → GenT m a
- chooseT ∷ (Random a, Ord a, Show a, MonadGenError m) ⇒ (a, a) → GenT m a
- sizeT ∷ Monad m ⇒ GenT m Int
- inspect ∷ ∀ m x. MonadGenError m ⇒ GenT GE x → GenT m (GE x)
- tryGenT ∷ MonadGenError m ⇒ GenT GE a → GenT m (Maybe a)
- catchGenT ∷ MonadGenError m ⇒ GenT GE a → GenT m (Either (NonEmpty String) a)
- catchGen ∷ GenT GE a → Gen (Either (NonEmpty String) a)
- firstGenT ∷ ∀ m a. MonadGenError m ⇒ [GenT GE a] → GenT m (Either [NonEmpty String] a)
- liftGen ∷ ∀ x. (∀ m. MonadGenError m ⇒ GenT m x) → GenT GE x
- dropGen ∷ MonadGenError m ⇒ GenT GE a → GenT m a
- frequency2 ∷ ∀ m a. MonadGenError m ⇒ (Int, GenT GE a) → (Int, GenT GE a) → GenT m a
- push ∷ ∀ m a. MonadGenError m ⇒ [String] → GenT GE a → GenT m a
- pushGE ∷ ∀ a. [String] → GE a → GE a
Documentation
class Monad m ⇒ MonadGenError m where Source #
A class for different types of errors with a stack of explain
calls to
narrow down problems. The (NE.NonEmpty String) means one cannot cause an
Error without at least 1 string to explain it.
genError ∷ HasCallStack ⇒ NonEmpty String → m a Source #
fatalError ∷ HasCallStack ⇒ NonEmpty String → m a Source #
explain ∷ HasCallStack ⇒ NonEmpty String → m a → m a Source #
Instances
MonadGenError GE Source # | |
Defined in Constrained.GenT | |
MonadGenError m ⇒ MonadGenError (GenT m) Source # | |
Defined in Constrained.GenT |
genError1 ∷ MonadGenError m ⇒ String → m a Source #
genError with one line of explanation
fatalError1 ∷ MonadGenError m ⇒ String → m a Source #
fatalError with one line of explanation
explain1 ∷ MonadGenError m ⇒ String → m a → m a Source #
explain with one line of explanation
The Gen Error monad, distinguishes between fatal errors and non-fatal errors.
FatalError [NonEmpty String] (NonEmpty String) | |
GenError [NonEmpty String] (NonEmpty String) | |
Result [NonEmpty String] a |
catGEs ∷ MonadGenError m ⇒ [GE a] → m [a] Source #
runGE ∷ MonadGenError m ⇒ GE r → m r Source #
listFromGE ∷ GE [a] → [a] Source #
Turn a `GE [a]` to `[a]`, genError
goes to `[]` and fatalError
to error
.
Generation mode - how strict are we about requiring the generator to succeed. This is necessary because sometimes failing to find a value means there is an actual problem (a generator _should_ be satisfiable but for whatever buggy reason it isn't) and sometimes failing to find a value just means there are no values. The latter case is very relevant when you're generating e.g. lists or sets of values that can be empty.
listOfUntilLenT ∷ MonadGenError m ⇒ GenT GE a → Int → (Int → Bool) → GenT m [a] Source #
Generate a list of elements of length at most goalLen
, but accepting failure
to get that many elements so long as validLen
is true.
TODO: possibly one could return "more, fewer, ok" in the validLen
instead
of Bool
suchThatWithTryT ∷ MonadGenError m ⇒ Int → GenT m a → (a → Bool) → GenT m a Source #
frequencyT ∷ MonadGenError m ⇒ [(Int, GenT GE a)] → GenT m a Source #
inspect ∷ ∀ m x. MonadGenError m ⇒ GenT GE x → GenT m (GE x) Source #
Always succeeds, but returns the internal GE structure for analysis
tryGenT ∷ MonadGenError m ⇒ GenT GE a → GenT m (Maybe a) Source #
Ignore all kinds of Errors, by squashing them into Nothing
firstGenT ∷ ∀ m a. MonadGenError m ⇒ [GenT GE a] → GenT m (Either [NonEmpty String] a) Source #
Return the first successfull result from a list of computations, if they all fail return a list of the error messages from each one.
frequency2 ∷ ∀ m a. MonadGenError m ⇒ (Int, GenT GE a) → (Int, GenT GE a) → GenT m a Source #
Run one of the actions with frequency proportional to the count. If it fails, run the other.