-- SPDX-FileCopyrightText: 2020 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

{-# OPTIONS_GHC -Wno-orphans #-}

module Util.Test.Arbitrary
  ( runGen
  ) where

import Prelude hiding (EQ, GT, LT)

import Test.QuickCheck
  (Arbitrary(..), Gen, choose, elements, frequency, oneof, resize, suchThatMap, vector)
import Test.QuickCheck.Arbitrary.ADT (ToADTArbitrary(..))
import Test.QuickCheck.Gen (unGen)
import Test.QuickCheck.Instances.ByteString ()
import Test.QuickCheck.Instances.Natural ()
import Test.QuickCheck.Instances.Semigroup ()
import Test.QuickCheck.Instances.Text ()
import Test.QuickCheck.Random (mkQCGen)

import Michelson.ErrorPos (InstrCallStack(..), LetName(..), Pos(..), SrcPos(..))
import Michelson.Untyped
  (Annotation, Contract'(..), Elt(..), EntriesOrder(..), ExpandedExtInstr, ExpandedOp(..),
  ExtInstrAbstract(..), InstrAbstract(..), InternalByteString(..), ParameterType(..),
  StackTypePattern(..), T(..), TyVar(..), Type(..), Value'(..), Var(..), mkAnnotation)
import Tezos.Core (Mutez(..))

instance Arbitrary InternalByteString where
  arbitrary :: Gen InternalByteString
arbitrary = ByteString -> InternalByteString
InternalByteString (ByteString -> InternalByteString)
-> Gen ByteString -> Gen InternalByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ByteString
forall a. Arbitrary a => Gen a
arbitrary

instance Arbitrary Var where
  arbitrary :: Gen Var
arbitrary = Text -> Var
Var (Text -> Var) -> Gen Text -> Gen Var
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
forall a. Arbitrary a => Gen a
arbitrary

instance Arbitrary TyVar where
  arbitrary :: Gen TyVar
arbitrary = [Gen TyVar] -> Gen TyVar
forall a. [Gen a] -> Gen a
oneof [Var -> TyVar
VarID (Var -> TyVar) -> Gen Var -> Gen TyVar
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Var
forall a. Arbitrary a => Gen a
arbitrary, Type -> TyVar
TyCon (Type -> TyVar) -> Gen Type -> Gen TyVar
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary]

instance Arbitrary StackTypePattern where
  arbitrary :: Gen StackTypePattern
arbitrary = [Gen StackTypePattern] -> Gen StackTypePattern
forall a. [Gen a] -> Gen a
oneof [StackTypePattern -> Gen StackTypePattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure StackTypePattern
StkEmpty, StackTypePattern -> Gen StackTypePattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure StackTypePattern
StkRest, TyVar -> StackTypePattern -> StackTypePattern
StkCons (TyVar -> StackTypePattern -> StackTypePattern)
-> Gen TyVar -> Gen (StackTypePattern -> StackTypePattern)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TyVar
forall a. Arbitrary a => Gen a
arbitrary Gen (StackTypePattern -> StackTypePattern)
-> Gen StackTypePattern -> Gen StackTypePattern
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen StackTypePattern
forall a. Arbitrary a => Gen a
arbitrary]

-- TODO extend Arbitrary ExpandedExtInstr with other constructors
instance Arbitrary ExpandedExtInstr where
  arbitrary :: Gen ExpandedExtInstr
arbitrary = [Gen ExpandedExtInstr] -> Gen ExpandedExtInstr
forall a. [Gen a] -> Gen a
oneof [StackTypePattern -> ExpandedExtInstr
forall op. StackTypePattern -> ExtInstrAbstract op
STACKTYPE (StackTypePattern -> ExpandedExtInstr)
-> Gen StackTypePattern -> Gen ExpandedExtInstr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen StackTypePattern
forall a. Arbitrary a => Gen a
arbitrary]

instance ToADTArbitrary Pos
instance Arbitrary Pos where
  arbitrary :: Gen Pos
arbitrary = Word -> Pos
Pos (Word -> Pos) -> Gen Word -> Gen Pos
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Word
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary SrcPos
instance Arbitrary SrcPos where
  arbitrary :: Gen SrcPos
arbitrary = (Pos -> Pos -> SrcPos) -> Gen Pos -> Gen Pos -> Gen SrcPos
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Pos -> Pos -> SrcPos
SrcPos Gen Pos
forall a. Arbitrary a => Gen a
arbitrary Gen Pos
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary LetName
instance Arbitrary LetName where
  arbitrary :: Gen LetName
arbitrary = Text -> LetName
LetName (Text -> LetName) -> Gen Text -> Gen LetName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen Text -> Gen Text
forall a. Int -> Gen a -> Gen a
resize 3 Gen Text
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary InstrCallStack
instance Arbitrary InstrCallStack where
  arbitrary :: Gen InstrCallStack
arbitrary = ([LetName] -> SrcPos -> InstrCallStack)
-> Gen [LetName] -> Gen SrcPos -> Gen InstrCallStack
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 [LetName] -> SrcPos -> InstrCallStack
InstrCallStack Gen [LetName]
genName Gen SrcPos
forall a. Arbitrary a => Gen a
arbitrary
    where
    genName :: Gen [LetName]
genName = [(Int, Gen [LetName])] -> Gen [LetName]
forall a. [(Int, Gen a)] -> Gen a
frequency [(80, [LetName] -> Gen [LetName]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []), (18, Int -> Gen [LetName]
forall a. Arbitrary a => Int -> Gen [a]
vector 1), (2, Int -> Gen [LetName]
forall a. Arbitrary a => Int -> Gen [a]
vector 2)]

instance ToADTArbitrary ExpandedOp
instance Arbitrary ExpandedOp where
  arbitrary :: Gen ExpandedOp
arbitrary = (InstrCallStack -> ExpandedOp -> ExpandedOp)
-> Gen InstrCallStack -> Gen ExpandedOp -> Gen ExpandedOp
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 InstrCallStack -> ExpandedOp -> ExpandedOp
WithSrcEx Gen InstrCallStack
forall a. Arbitrary a => Gen a
arbitrary (ExpandedInstr -> ExpandedOp
PrimEx (ExpandedInstr -> ExpandedOp)
-> Gen ExpandedInstr -> Gen ExpandedOp
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ExpandedInstr
forall a. Arbitrary a => Gen a
arbitrary)

instance ToADTArbitrary Mutez

instance ToADTArbitrary (Annotation tag)
instance Arbitrary (Annotation tag) where
  arbitrary :: Gen (Annotation tag)
arbitrary = Int -> Gen Text -> Gen Text
forall a. Int -> Gen a -> Gen a
resize 5 Gen Text
forall a. Arbitrary a => Gen a
arbitrary Gen Text
-> (Text -> Maybe (Annotation tag)) -> Gen (Annotation tag)
forall a b. Gen a -> (a -> Maybe b) -> Gen b
`suchThatMap` (Either Text (Annotation tag) -> Maybe (Annotation tag)
forall l r. Either l r -> Maybe r
rightToMaybe (Either Text (Annotation tag) -> Maybe (Annotation tag))
-> (Text -> Either Text (Annotation tag))
-> Text
-> Maybe (Annotation tag)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Either Text (Annotation tag)
forall k (a :: k). Text -> Either Text (Annotation a)
mkAnnotation)

smallSize :: Gen Int
smallSize :: Gen Int
smallSize = (Int, Int) -> Gen Int
forall a. Random a => (a, a) -> Gen a
choose (0, 3)

smallList :: Arbitrary a => Gen [a]
smallList :: Gen [a]
smallList = Gen Int
smallSize Gen Int -> (Int -> Gen [a]) -> Gen [a]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> Gen [a]
forall a. Arbitrary a => Int -> Gen [a]
vector

smallList1 :: Arbitrary a => Gen (NonEmpty a)
smallList1 :: Gen (NonEmpty a)
smallList1 = Gen [a]
forall a. Arbitrary a => Gen [a]
smallList Gen [a] -> ([a] -> Maybe (NonEmpty a)) -> Gen (NonEmpty a)
forall a b. Gen a -> (a -> Maybe b) -> Gen b
`suchThatMap` [a] -> Maybe (NonEmpty a)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty

instance Arbitrary EntriesOrder where
  arbitrary :: Gen EntriesOrder
arbitrary = [EntriesOrder] -> Gen EntriesOrder
forall a. [a] -> Gen a
elements [EntriesOrder
forall a. Bounded a => a
minBound .. EntriesOrder
forall a. Bounded a => a
maxBound]

instance (Arbitrary op, ToADTArbitrary op) => ToADTArbitrary (Contract' op)
instance (Arbitrary op) => Arbitrary (Contract' op) where
  arbitrary :: Gen (Contract' op)
arbitrary = ParameterType -> Type -> [op] -> EntriesOrder -> Contract' op
forall op.
ParameterType -> Type -> [op] -> EntriesOrder -> Contract' op
Contract (ParameterType -> Type -> [op] -> EntriesOrder -> Contract' op)
-> Gen ParameterType
-> Gen (Type -> [op] -> EntriesOrder -> Contract' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ParameterType
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> [op] -> EntriesOrder -> Contract' op)
-> Gen Type -> Gen ([op] -> EntriesOrder -> Contract' op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen ([op] -> EntriesOrder -> Contract' op)
-> Gen [op] -> Gen (EntriesOrder -> Contract' op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList Gen (EntriesOrder -> Contract' op)
-> Gen EntriesOrder -> Gen (Contract' op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen EntriesOrder
forall a. Arbitrary a => Gen a
arbitrary

instance (Arbitrary op, ToADTArbitrary op, Arbitrary (ExtInstrAbstract op)) => ToADTArbitrary (InstrAbstract op)
instance (Arbitrary op, Arbitrary (ExtInstrAbstract op)) => Arbitrary (InstrAbstract op) where
  arbitrary :: Gen (InstrAbstract op)
arbitrary =
    [Gen (InstrAbstract op)] -> Gen (InstrAbstract op)
forall a. [Gen a] -> Gen a
oneof
      [ ExtInstrAbstract op -> InstrAbstract op
forall op. ExtInstrAbstract op -> InstrAbstract op
EXT (ExtInstrAbstract op -> InstrAbstract op)
-> Gen (ExtInstrAbstract op) -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ExtInstrAbstract op)
forall a. Arbitrary a => Gen a
arbitrary
      , InstrAbstract op -> Gen (InstrAbstract op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrAbstract op
forall op. InstrAbstract op
DROP
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
DUP (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , InstrAbstract op -> Gen (InstrAbstract op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrAbstract op
forall op. InstrAbstract op
SWAP
      , VarAnn -> Type -> Value' op -> InstrAbstract op
forall op. VarAnn -> Type -> Value' op -> InstrAbstract op
PUSH (VarAnn -> Type -> Value' op -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> Value' op -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Value' op -> InstrAbstract op)
-> Gen Type -> Gen (Value' op -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Value' op -> InstrAbstract op)
-> Gen (Value' op) -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> InstrAbstract op
SOME (TypeAnn -> VarAnn -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> InstrAbstract op
NONE (TypeAnn -> VarAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> InstrAbstract op
UNIT (TypeAnn -> VarAnn -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , [op] -> [op] -> InstrAbstract op
forall op. [op] -> [op] -> InstrAbstract op
IF_NONE ([op] -> [op] -> InstrAbstract op)
-> Gen [op] -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , TypeAnn -> VarAnn -> FieldAnn -> FieldAnn -> InstrAbstract op
forall op.
TypeAnn -> VarAnn -> FieldAnn -> FieldAnn -> InstrAbstract op
PAIR (TypeAnn -> VarAnn -> FieldAnn -> FieldAnn -> InstrAbstract op)
-> Gen TypeAnn
-> Gen (VarAnn -> FieldAnn -> FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> FieldAnn -> FieldAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (FieldAnn -> FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> FieldAnn -> InstrAbstract op)
-> Gen FieldAnn -> Gen (FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> InstrAbstract op)
-> Gen FieldAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> FieldAnn -> InstrAbstract op
forall op. VarAnn -> FieldAnn -> InstrAbstract op
CAR (VarAnn -> FieldAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> InstrAbstract op)
-> Gen FieldAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> FieldAnn -> InstrAbstract op
forall op. VarAnn -> FieldAnn -> InstrAbstract op
CDR (VarAnn -> FieldAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> InstrAbstract op)
-> Gen FieldAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn
-> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op
forall op.
TypeAnn
-> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op
LEFT (TypeAnn
 -> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn
-> Gen (VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen VarAnn
-> Gen (FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen FieldAnn -> Gen (FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> Type -> InstrAbstract op)
-> Gen FieldAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn
-> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op
forall op.
TypeAnn
-> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op
RIGHT (TypeAnn
 -> VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn
-> Gen (VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen VarAnn
-> Gen (FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen FieldAnn -> Gen (FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> Type -> InstrAbstract op)
-> Gen FieldAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , [op] -> [op] -> InstrAbstract op
forall op. [op] -> [op] -> InstrAbstract op
IF_LEFT ([op] -> [op] -> InstrAbstract op)
-> Gen [op] -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , TypeAnn -> VarAnn -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> InstrAbstract op
NIL (TypeAnn -> VarAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
CONS (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , [op] -> [op] -> InstrAbstract op
forall op. [op] -> [op] -> InstrAbstract op
IF_CONS ([op] -> [op] -> InstrAbstract op)
-> Gen [op] -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SIZE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> InstrAbstract op
EMPTY_SET (TypeAnn -> VarAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op
EMPTY_MAP (TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Type -> InstrAbstract op)
-> Gen Type -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op
EMPTY_BIG_MAP (TypeAnn -> VarAnn -> Type -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Type -> InstrAbstract op)
-> Gen Type -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> [op] -> InstrAbstract op
forall op. VarAnn -> [op] -> InstrAbstract op
MAP (VarAnn -> [op] -> InstrAbstract op)
-> Gen VarAnn -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , [op] -> InstrAbstract op
forall op. [op] -> InstrAbstract op
ITER ([op] -> InstrAbstract op) -> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
MEM (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
GET (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
UPDATE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , [op] -> [op] -> InstrAbstract op
forall op. [op] -> [op] -> InstrAbstract op
IF ([op] -> [op] -> InstrAbstract op)
-> Gen [op] -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , [op] -> InstrAbstract op
forall op. [op] -> InstrAbstract op
LOOP ([op] -> InstrAbstract op) -> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , [op] -> InstrAbstract op
forall op. [op] -> InstrAbstract op
LOOP_LEFT ([op] -> InstrAbstract op) -> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , VarAnn -> Type -> Type -> [op] -> InstrAbstract op
forall op. VarAnn -> Type -> Type -> [op] -> InstrAbstract op
LAMBDA (VarAnn -> Type -> Type -> [op] -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> Type -> [op] -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Type -> [op] -> InstrAbstract op)
-> Gen Type -> Gen (Type -> [op] -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> [op] -> InstrAbstract op)
-> Gen Type -> Gen ([op] -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen ([op] -> InstrAbstract op)
-> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
EXEC (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
APPLY (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , [op] -> InstrAbstract op
forall op. [op] -> InstrAbstract op
DIP ([op] -> InstrAbstract op) -> Gen [op] -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [op]
forall a. Arbitrary a => Gen [a]
smallList
      , InstrAbstract op -> Gen (InstrAbstract op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure InstrAbstract op
forall op. InstrAbstract op
FAILWITH
      , VarAnn -> Type -> InstrAbstract op
forall op. VarAnn -> Type -> InstrAbstract op
CAST (VarAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
RENAME (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
PACK (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , TypeAnn -> VarAnn -> Type -> InstrAbstract op
forall op. TypeAnn -> VarAnn -> Type -> InstrAbstract op
UNPACK (TypeAnn -> VarAnn -> Type -> InstrAbstract op)
-> Gen TypeAnn -> Gen (VarAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
CONCAT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SLICE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
ISNAT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
ADD (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SUB (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
MUL (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
EDIV (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
ABS (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
NEG (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
LSL (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
LSR (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
OR (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
AND (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
XOR (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
NOT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
COMPARE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
EQ (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
NEQ (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
LT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
GT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
LE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
GE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
INT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> FieldAnn -> InstrAbstract op
forall op. VarAnn -> FieldAnn -> InstrAbstract op
SELF (VarAnn -> FieldAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (FieldAnn -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> InstrAbstract op)
-> Gen FieldAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> FieldAnn -> Type -> InstrAbstract op
forall op. VarAnn -> FieldAnn -> Type -> InstrAbstract op
CONTRACT (VarAnn -> FieldAnn -> Type -> InstrAbstract op)
-> Gen VarAnn -> Gen (FieldAnn -> Type -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> Type -> InstrAbstract op)
-> Gen FieldAnn -> Gen (Type -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> InstrAbstract op)
-> Gen Type -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
TRANSFER_TOKENS (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SET_DELEGATE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> VarAnn -> Contract' op -> InstrAbstract op
forall op. VarAnn -> VarAnn -> Contract' op -> InstrAbstract op
CREATE_CONTRACT (VarAnn -> VarAnn -> Contract' op -> InstrAbstract op)
-> Gen VarAnn -> Gen (VarAnn -> Contract' op -> InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (VarAnn -> Contract' op -> InstrAbstract op)
-> Gen VarAnn -> Gen (Contract' op -> InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Contract' op -> InstrAbstract op)
-> Gen (Contract' op) -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Contract' op)
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
IMPLICIT_ACCOUNT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
NOW (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
AMOUNT (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
BALANCE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
CHECK_SIGNATURE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SHA256 (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SHA512 (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
BLAKE2B (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
HASH_KEY (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SOURCE (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
SENDER (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      , VarAnn -> InstrAbstract op
forall op. VarAnn -> InstrAbstract op
ADDRESS (VarAnn -> InstrAbstract op)
-> Gen VarAnn -> Gen (InstrAbstract op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen VarAnn
forall a. Arbitrary a => Gen a
arbitrary
      ]

instance (Arbitrary op, ToADTArbitrary op) => ToADTArbitrary (Value' op)
instance (Arbitrary op) => Arbitrary (Value' op) where
  arbitrary :: Gen (Value' op)
arbitrary =
    [Gen (Value' op)] -> Gen (Value' op)
forall a. [Gen a] -> Gen a
oneof
      [ Integer -> Value' op
forall op. Integer -> Value' op
ValueInt (Integer -> Value' op) -> Gen Integer -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Integer
forall a. Arbitrary a => Gen a
arbitrary
      , MText -> Value' op
forall op. MText -> Value' op
ValueString (MText -> Value' op) -> Gen MText -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen MText
forall a. Arbitrary a => Gen a
arbitrary
      , InternalByteString -> Value' op
forall op. InternalByteString -> Value' op
ValueBytes (InternalByteString -> Value' op)
-> Gen InternalByteString -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen InternalByteString
forall a. Arbitrary a => Gen a
arbitrary
      , Value' op -> Gen (Value' op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value' op
forall op. Value' op
ValueUnit
      , Value' op -> Gen (Value' op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value' op
forall op. Value' op
ValueTrue
      , Value' op -> Gen (Value' op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value' op
forall op. Value' op
ValueFalse
      , Value' op -> Value' op -> Value' op
forall op. Value' op -> Value' op -> Value' op
ValuePair (Value' op -> Value' op -> Value' op)
-> Gen (Value' op) -> Gen (Value' op -> Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary Gen (Value' op -> Value' op) -> Gen (Value' op) -> Gen (Value' op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary
      , Value' op -> Value' op
forall op. Value' op -> Value' op
ValueLeft (Value' op -> Value' op) -> Gen (Value' op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary
      , Value' op -> Value' op
forall op. Value' op -> Value' op
ValueRight (Value' op -> Value' op) -> Gen (Value' op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary
      , Value' op -> Value' op
forall op. Value' op -> Value' op
ValueSome (Value' op -> Value' op) -> Gen (Value' op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary
      , Value' op -> Gen (Value' op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value' op
forall op. Value' op
ValueNone
      , Value' op -> Gen (Value' op)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value' op
forall op. Value' op
ValueNil
      , (NonEmpty $ Value' op) -> Value' op
forall op. (NonEmpty $ Value' op) -> Value' op
ValueSeq ((NonEmpty $ Value' op) -> Value' op)
-> Gen (NonEmpty $ Value' op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmpty $ Value' op)
forall a. Arbitrary a => Gen (NonEmpty a)
smallList1
      , (NonEmpty $ Elt op) -> Value' op
forall op. (NonEmpty $ Elt op) -> Value' op
ValueMap ((NonEmpty $ Elt op) -> Value' op)
-> Gen (NonEmpty $ Elt op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmpty $ Elt op)
forall a. Arbitrary a => Gen (NonEmpty a)
smallList1
      , NonEmpty op -> Value' op
forall op. NonEmpty op -> Value' op
ValueLambda (NonEmpty op -> Value' op) -> Gen (NonEmpty op) -> Gen (Value' op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmpty op)
forall a. Arbitrary a => Gen (NonEmpty a)
smallList1
      ]

instance (Arbitrary op, ToADTArbitrary op) => ToADTArbitrary (Elt op)
instance (Arbitrary op) => Arbitrary (Elt op) where
  arbitrary :: Gen (Elt op)
arbitrary = Value' op -> Value' op -> Elt op
forall op. Value' op -> Value' op -> Elt op
Elt (Value' op -> Value' op -> Elt op)
-> Gen (Value' op) -> Gen (Value' op -> Elt op)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary Gen (Value' op -> Elt op) -> Gen (Value' op) -> Gen (Elt op)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Value' op)
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary Type
instance Arbitrary Type where
  arbitrary :: Gen Type
arbitrary = T -> TypeAnn -> Type
Type (T -> TypeAnn -> Type) -> Gen T -> Gen (TypeAnn -> Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen T
forall a. Arbitrary a => Gen a
arbitrary Gen (TypeAnn -> Type) -> Gen TypeAnn -> Gen Type
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary ParameterType
instance Arbitrary ParameterType where
  arbitrary :: Gen ParameterType
arbitrary = Type -> RootAnn -> ParameterType
ParameterType (Type -> RootAnn -> ParameterType)
-> Gen Type -> Gen (RootAnn -> ParameterType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (RootAnn -> ParameterType) -> Gen RootAnn -> Gen ParameterType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen RootAnn
forall a. Arbitrary a => Gen a
arbitrary

-- | @getRareT k@ generates 'T' producing anything big once per @1 / (k + 1)@
-- invocation.
genRareType :: Word -> Gen Type
genRareType :: Word -> Gen Type
genRareType k :: Word
k = T -> TypeAnn -> Type
Type (T -> TypeAnn -> Type) -> Gen T -> Gen (TypeAnn -> Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Word -> Gen T
genRareT Word
k Gen (TypeAnn -> Type) -> Gen TypeAnn -> Gen Type
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen TypeAnn
forall a. Arbitrary a => Gen a
arbitrary

instance ToADTArbitrary T
instance Arbitrary T where
  arbitrary :: Gen T
arbitrary =
    [Gen T] -> Gen T
forall a. [Gen a] -> Gen a
oneof
      [ T -> Gen T
forall (f :: * -> *) a. Applicative f => a -> f a
pure T
TKey
      , T -> Gen T
forall (f :: * -> *) a. Applicative f => a -> f a
pure T
TUnit
      , T -> Gen T
forall (f :: * -> *) a. Applicative f => a -> f a
pure T
TSignature
      , Type -> T
TOption (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , Type -> T
TList (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , Type -> T
TSet (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , T -> Gen T
forall (f :: * -> *) a. Applicative f => a -> f a
pure T
TOperation
      , Type -> T
TContract (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , FieldAnn -> FieldAnn -> Type -> Type -> T
TPair (FieldAnn -> FieldAnn -> Type -> Type -> T)
-> Gen FieldAnn -> Gen (FieldAnn -> Type -> Type -> T)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> Type -> Type -> T)
-> Gen FieldAnn -> Gen (Type -> Type -> T)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Type -> T) -> Gen Type -> Gen (Type -> T)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Word -> Gen Type
genRareType 5 Gen (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Word -> Gen Type
genRareType 5
      , FieldAnn -> FieldAnn -> Type -> Type -> T
TOr (FieldAnn -> FieldAnn -> Type -> Type -> T)
-> Gen FieldAnn -> Gen (FieldAnn -> Type -> Type -> T)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (FieldAnn -> Type -> Type -> T)
-> Gen FieldAnn -> Gen (Type -> Type -> T)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FieldAnn
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> Type -> T) -> Gen Type -> Gen (Type -> T)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Word -> Gen Type
genRareType 5 Gen (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Word -> Gen Type
genRareType 5
      , Type -> Type -> T
TLambda (Type -> Type -> T) -> Gen Type -> Gen (Type -> T)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Word -> Gen Type
genRareType 5 Gen (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Word -> Gen Type
genRareType 5
      , Type -> Type -> T
TMap (Type -> Type -> T) -> Gen Type -> Gen (Type -> T)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      , Type -> Type -> T
TBigMap (Type -> Type -> T) -> Gen Type -> Gen (Type -> T)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Type
forall a. Arbitrary a => Gen a
arbitrary Gen (Type -> T) -> Gen Type -> Gen T
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Type
forall a. Arbitrary a => Gen a
arbitrary
      ]

-- | @getRareT k@ generates 'Type' producing anything big once per @1 / (k + 1)@
-- invocation.
--
-- Useful to avoid exponensial growth.
genRareT :: Word -> Gen T
genRareT :: Word -> Gen T
genRareT k :: Word
k = [(Int, Gen T)] -> Gen T
forall a. [(Int, Gen a)] -> Gen a
frequency [(1, Gen T
forall a. Arbitrary a => Gen a
arbitrary), (Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
k, T -> Gen T
forall (f :: * -> *) a. Applicative f => a -> f a
pure T
TUnit)]

-- | Run given generator deterministically.
runGen :: Int -> Gen a -> a
runGen :: Int -> Gen a -> a
runGen seed :: Int
seed gen :: Gen a
gen = Gen a -> QCGen -> Int -> a
forall a. Gen a -> QCGen -> Int -> a
unGen Gen a
gen (Int -> QCGen
mkQCGen Int
seed) 10