Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Sample generators used for tests.
Synopsis
- type TermGen a = Gen (TermOf (Term TyName Name DefaultUni DefaultFun ()) a)
- data TermOf term a = TermOf {
- _termOfTerm ∷ term
- _termOfValue ∷ a
- genOverapplication ∷ TermGen Integer
- factorial ∷ Term TyName Name DefaultUni DefaultFun ()
- genFactorial ∷ TermGen Integer
- naiveFib ∷ Integer → Term TyName Name DefaultUni DefaultFun ()
- genNaiveFib ∷ TermGen Integer
- genNatRoundtrip ∷ TermGen Integer
- natSum ∷ Term TyName Name DefaultUni DefaultFun ()
- genScottListSum ∷ TermGen Integer
- genIfIntegers ∷ TermGen Integer
- fromInterestingTermGens ∷ (∀ a. KnownType (Term TyName Name DefaultUni DefaultFun ()) a ⇒ String → TermGen a → c) → [c]
Documentation
type TermGen a = Gen (TermOf (Term TyName Name DefaultUni DefaultFun ()) a) Source #
The type of terms-and-their-values generators.
A term
along with the corresponding Haskell value.
TermOf | |
|
Instances
(PrettyBy config a, PrettyBy config term) ⇒ PrettyBy config (TermOf term a) Source # | |
Foldable (TermOf term) Source # | |
Defined in PlutusCore.Generators.Hedgehog.TypedBuiltinGen fold ∷ Monoid m ⇒ TermOf term m → m Source # foldMap ∷ Monoid m ⇒ (a → m) → TermOf term a → m Source # foldMap' ∷ Monoid m ⇒ (a → m) → TermOf term a → m Source # foldr ∷ (a → b → b) → b → TermOf term a → b Source # foldr' ∷ (a → b → b) → b → TermOf term a → b Source # foldl ∷ (b → a → b) → b → TermOf term a → b Source # foldl' ∷ (b → a → b) → b → TermOf term a → b Source # foldr1 ∷ (a → a → a) → TermOf term a → a Source # foldl1 ∷ (a → a → a) → TermOf term a → a Source # toList ∷ TermOf term a → [a] Source # null ∷ TermOf term a → Bool Source # length ∷ TermOf term a → Int Source # elem ∷ Eq a ⇒ a → TermOf term a → Bool Source # maximum ∷ Ord a ⇒ TermOf term a → a Source # minimum ∷ Ord a ⇒ TermOf term a → a Source # | |
Traversable (TermOf term) Source # | |
Functor (TermOf term) Source # | |
genOverapplication ∷ TermGen Integer Source #
Generates application of a builtin that returns a function, immediately saturated afterwards.
ifThenElse {integer -> integer -> integer} (lessThanInteger i j) addInteger subtractInteger i j == if i < j then i + j else i - j
factorial ∷ Term TyName Name DefaultUni DefaultFun () Source #
i -> product [1 :: Integer .. i]
as a PLC term.
\(i : integer) -> product (enumFromTo 1 i)
genFactorial ∷ TermGen Integer Source #
Generate a term that computes the factorial of an integer
and return it
along with the factorial of the corresponding Integer
computed on the Haskell side.
naiveFib ∷ Integer → Term TyName Name DefaultUni DefaultFun () Source #
The naive exponential fibonacci function as a PLC term.
\(i0 : integer) -> fix {integer} {integer} (\(rec : integer -> integer) (i : integer) -> ifThenElse {integer} (lessThanEqInteger i 1) (\(u : unit) -> i) (\(u : unit) -> addInteger (rec (subtractInteger i 1)) (rec (subtractInteger i 2))) i0
genNaiveFib ∷ TermGen Integer Source #
Generate a term that computes the ith Fibonacci number and return it
along with the corresponding Integer
computed on the Haskell side.
natSum ∷ Term TyName Name DefaultUni DefaultFun () Source #
sumNat
as a PLC term.
genScottListSum ∷ TermGen Integer Source #
Generate a list of Integer
s, turn it into a Scott-encoded PLC List
(see List
),
sum elements of the list (see Sum
) and return it along with the sum of the original list.
genIfIntegers ∷ TermGen Integer Source #
Generate a boolean
and two integer
s and check whether if b then i1 else i2
means the same thing in Haskell and PLC. Terms are generated using genTermLoose
.
fromInterestingTermGens ∷ (∀ a. KnownType (Term TyName Name DefaultUni DefaultFun ()) a ⇒ String → TermGen a → c) → [c] Source #
Apply a function to all interesting generators and collect the results.