Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
PlutusCore.Generators.QuickCheck.ShrinkTypes
Description
This module defines the type shrinker. The shrinking order isn't specified, so the shrinker may or may not behave correctly, we don't really know. If shrinking ever loops, feel free to kill this module or reverse-engineer the shrinker and fix the problem.
Synopsis
- minimalType ∷ Kind () → Type TyName DefaultUni ()
- fixKind ∷ HasCallStack ⇒ TypeCtx → Type TyName DefaultUni () → Kind () → Type TyName DefaultUni ()
- shrinkKindAndType ∷ HasCallStack ⇒ TypeCtx → (Kind (), Type TyName DefaultUni ()) → [(Kind (), Type TyName DefaultUni ())]
- shrinkType ∷ HasCallStack ⇒ TypeCtx → Type TyName DefaultUni () → [Type TyName DefaultUni ()]
- shrinkTypeAtKind ∷ HasCallStack ⇒ TypeCtx → Kind () → Type TyName DefaultUni () → [Type TyName DefaultUni ()]
Documentation
minimalType ∷ Kind () → Type TyName DefaultUni () Source #
Give a unique "least" (intentionally vaguely specified by "shrinking order") type of that kind. Note: this function requires care and attention to not get a shrinking loop. If you think you need to mess with this function: 0. First, you *must* read the note Note [Avoiding Shrinking Loops] 1. You're probably wrong, think again and 2. If you're sure you're not wrong you need to be very careful and test the shrinking to make sure you don't get in a loop. 3. Finally, you *must* read the note Note [Avoiding Shrinking Loops]
fixKind ∷ HasCallStack ⇒ TypeCtx → Type TyName DefaultUni () → Kind () → Type TyName DefaultUni () Source #
Take a type in a context and a target kind and try adjust the type to have the target kind.
If can't make the adjusting successful, return the minimalType
of the target kind.
Precondition: new kind is smaller or equal to old kind of the type.
Complies with the implicit shrinking order.
TODO (later): also allow changing which context it's valid in
shrinkKindAndType ∷ HasCallStack ⇒ TypeCtx → (Kind (), Type TyName DefaultUni ()) → [(Kind (), Type TyName DefaultUni ())] Source #
Shrink a well-kinded type in a context to new types, possibly with new kinds. The new kinds are guaranteed to be smaller than or equal to the old kind. TODO: also shrink to new context need old context and new context
shrinkType ∷ HasCallStack ⇒ TypeCtx → Type TyName DefaultUni () → [Type TyName DefaultUni ()] Source #
Shrink a type in a context assuming that it is of kind *.
shrinkTypeAtKind ∷ HasCallStack ⇒ TypeCtx → Kind () → Type TyName DefaultUni () → [Type TyName DefaultUni ()] Source #
Shrink a type of a given kind in a given context in a way that keeps its kind