-- |
-- Module: Covenant.Prim
-- Copyright: (C) MLabs 2025
-- License: Apache 2.0
-- Maintainer: koz@mlabs.city, sean@mlabs.city
--
-- Contains definitions relating to Plutus primitive functions in Covenant
-- programs.
--
-- = Note
--
-- In the 1.0.0 release, we didn't include non-flat builtin types, specifically
-- pairs, lists and @Data@. Thus, the primops that operate on, or produce, these
-- are not currently included.
--
-- @since 1.0.0
module Covenant.Prim
  ( OneArgFunc (..),
    typeOneArgFunc,
    TwoArgFunc (..),
    typeTwoArgFunc,
    ThreeArgFunc (..),
    typeThreeArgFunc,
    -- SixArgFunc (..),
    -- typeSixArgFunc,
  )
where

import Covenant.DeBruijn (DeBruijn (Z))
import Covenant.Index (ix0)
import Covenant.Type
  ( AbstractTy,
    CompT (Comp0, Comp1),
    CompTBody (ReturnT, (:--:>)),
    ValT,
    boolT,
    byteStringT,
    g1T,
    g2T,
    integerT,
    mlResultT,
    stringT,
    tyvar,
    unitT,
  )
import Test.QuickCheck (Arbitrary (arbitrary), elements)

-- | All one-argument primitives provided by Plutus.
--
-- = Note
--
-- We exclude the @MkNilData@ and @MkNilPairData@ primitives from this list for
-- several reasons. For clarity, we list these below. Firstly, the reason why
-- these primitives still exist at all is historical: Plutus now has the ability
-- to directly \'lift\' empty list constants into itself. Secondly, while these
-- primitives /could/ still be used instead of direct lifts, there is never a
-- reason to prefer them, as they are less efficient than embedding a constant
-- directly. Thirdly, their naive typings would end up with overdetermined type
-- variables - consider the typing of @MkNilData@:
--
-- @forall a . () -> ![a]@
--
-- For all of these reasons, we do not represent these primitives in the ASG.
--
-- @since 1.0.0
data OneArgFunc
  = LengthOfByteString
  | Sha2_256
  | Sha3_256
  | Blake2b_256
  | EncodeUtf8
  | DecodeUtf8
  | --  | FstPair
    --  |  SndPair
    --  | HeadList
    --  | TailList
    --  | NullList
    --  | MapData
    --  | ListData
    --  | IData
    --  | BData
    --  | UnConstrData
    --  | UnMapData
    --  | UnListData
    --  | UnIData
    --  | UnBData
    --  | SerialiseData
    BLS12_381_G1_neg
  | BLS12_381_G1_compress
  | BLS12_381_G1_uncompress
  | BLS12_381_G2_neg
  | BLS12_381_G2_compress
  | BLS12_381_G2_uncompress
  | Keccak_256
  | Blake2b_224
  | ComplementByteString
  | CountSetBits
  | FindFirstSetBit
  | Ripemd_160
  deriving stock
    ( -- | @since 1.0.0
      OneArgFunc -> OneArgFunc -> Bool
(OneArgFunc -> OneArgFunc -> Bool)
-> (OneArgFunc -> OneArgFunc -> Bool) -> Eq OneArgFunc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OneArgFunc -> OneArgFunc -> Bool
== :: OneArgFunc -> OneArgFunc -> Bool
$c/= :: OneArgFunc -> OneArgFunc -> Bool
/= :: OneArgFunc -> OneArgFunc -> Bool
Eq,
      -- | @since 1.0.0
      Eq OneArgFunc
Eq OneArgFunc =>
(OneArgFunc -> OneArgFunc -> Ordering)
-> (OneArgFunc -> OneArgFunc -> Bool)
-> (OneArgFunc -> OneArgFunc -> Bool)
-> (OneArgFunc -> OneArgFunc -> Bool)
-> (OneArgFunc -> OneArgFunc -> Bool)
-> (OneArgFunc -> OneArgFunc -> OneArgFunc)
-> (OneArgFunc -> OneArgFunc -> OneArgFunc)
-> Ord OneArgFunc
OneArgFunc -> OneArgFunc -> Bool
OneArgFunc -> OneArgFunc -> Ordering
OneArgFunc -> OneArgFunc -> OneArgFunc
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: OneArgFunc -> OneArgFunc -> Ordering
compare :: OneArgFunc -> OneArgFunc -> Ordering
$c< :: OneArgFunc -> OneArgFunc -> Bool
< :: OneArgFunc -> OneArgFunc -> Bool
$c<= :: OneArgFunc -> OneArgFunc -> Bool
<= :: OneArgFunc -> OneArgFunc -> Bool
$c> :: OneArgFunc -> OneArgFunc -> Bool
> :: OneArgFunc -> OneArgFunc -> Bool
$c>= :: OneArgFunc -> OneArgFunc -> Bool
>= :: OneArgFunc -> OneArgFunc -> Bool
$cmax :: OneArgFunc -> OneArgFunc -> OneArgFunc
max :: OneArgFunc -> OneArgFunc -> OneArgFunc
$cmin :: OneArgFunc -> OneArgFunc -> OneArgFunc
min :: OneArgFunc -> OneArgFunc -> OneArgFunc
Ord,
      -- | @since 1.0.0
      Int -> OneArgFunc -> ShowS
[OneArgFunc] -> ShowS
OneArgFunc -> String
(Int -> OneArgFunc -> ShowS)
-> (OneArgFunc -> String)
-> ([OneArgFunc] -> ShowS)
-> Show OneArgFunc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OneArgFunc -> ShowS
showsPrec :: Int -> OneArgFunc -> ShowS
$cshow :: OneArgFunc -> String
show :: OneArgFunc -> String
$cshowList :: [OneArgFunc] -> ShowS
showList :: [OneArgFunc] -> ShowS
Show
    )

-- | Does not shrink.
--
-- @since 1.0.0
instance Arbitrary OneArgFunc where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen OneArgFunc
arbitrary =
    [OneArgFunc] -> Gen OneArgFunc
forall a. HasCallStack => [a] -> Gen a
elements
      [ OneArgFunc
LengthOfByteString,
        OneArgFunc
Sha2_256,
        OneArgFunc
Sha3_256,
        OneArgFunc
Blake2b_256,
        OneArgFunc
EncodeUtf8,
        OneArgFunc
DecodeUtf8,
        -- FstPair,
        -- SndPair,
        -- HeadList,
        -- TailList,
        -- NullList,
        -- MapData,
        -- ListData,
        -- IData,
        -- BData,
        -- UnConstrData,
        -- UnMapData,
        -- UnListData,
        -- UnIData,
        -- UnBData,
        -- SerialiseData,
        OneArgFunc
BLS12_381_G1_neg,
        OneArgFunc
BLS12_381_G1_compress,
        OneArgFunc
BLS12_381_G1_uncompress,
        OneArgFunc
BLS12_381_G2_neg,
        OneArgFunc
BLS12_381_G2_compress,
        OneArgFunc
BLS12_381_G2_uncompress,
        OneArgFunc
Keccak_256,
        OneArgFunc
Blake2b_224,
        OneArgFunc
ComplementByteString,
        OneArgFunc
CountSetBits,
        OneArgFunc
FindFirstSetBit,
        OneArgFunc
Ripemd_160
      ]

-- | Produce the type of a single-argument primop.
--
-- @since 1.0.0
typeOneArgFunc :: OneArgFunc -> CompT AbstractTy
typeOneArgFunc :: OneArgFunc -> CompT AbstractTy
typeOneArgFunc = \case
  OneArgFunc
LengthOfByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  OneArgFunc
Sha2_256 -> CompT AbstractTy
hashingT
  OneArgFunc
Sha3_256 -> CompT AbstractTy
hashingT
  OneArgFunc
Blake2b_256 -> CompT AbstractTy
hashingT
  OneArgFunc
EncodeUtf8 -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
stringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  OneArgFunc
DecodeUtf8 -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
stringT
  OneArgFunc
BLS12_381_G1_neg -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
g1T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g1T
  OneArgFunc
BLS12_381_G1_compress -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
g1T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  OneArgFunc
BLS12_381_G1_uncompress -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g1T
  OneArgFunc
BLS12_381_G2_neg -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
g2T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g2T
  OneArgFunc
BLS12_381_G2_compress -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
g2T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  OneArgFunc
BLS12_381_G2_uncompress -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g2T
  OneArgFunc
Keccak_256 -> CompT AbstractTy
hashingT
  OneArgFunc
Blake2b_224 -> CompT AbstractTy
hashingT
  OneArgFunc
ComplementByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  OneArgFunc
CountSetBits -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  OneArgFunc
FindFirstSetBit -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  OneArgFunc
Ripemd_160 -> CompT AbstractTy
hashingT
  where
    hashingT :: CompT AbstractTy
    hashingT :: CompT AbstractTy
hashingT = CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT

-- | All two-argument primitives provided by Plutus.
--
-- @since 1.0.0
data TwoArgFunc
  = AddInteger
  | SubtractInteger
  | MultiplyInteger
  | DivideInteger
  | QuotientInteger
  | RemainderInteger
  | ModInteger
  | EqualsInteger
  | LessThanInteger
  | LessThanEqualsInteger
  | AppendByteString
  | ConsByteString
  | IndexByteString
  | EqualsByteString
  | LessThanByteString
  | LessThanEqualsByteString
  | AppendString
  | EqualsString
  | ChooseUnit
  | Trace
  | -- | MkCons
    -- | ConstrData
    -- | EqualsData
    -- | MkPairData
    BLS12_381_G1_add
  | BLS12_381_G1_scalarMul
  | BLS12_381_G1_equal
  | BLS12_381_G1_hashToGroup
  | BLS12_381_G2_add
  | BLS12_381_G2_scalarMul
  | BLS12_381_G2_equal
  | BLS12_381_G2_hashToGroup
  | BLS12_381_millerLoop
  | BLS12_381_mulMlResult
  | BLS12_381_finalVerify
  | ByteStringToInteger
  | ReadBit
  | ReplicateByte
  | ShiftByteString
  | RotateByteString
  deriving stock
    ( -- | @since 1.0.0
      TwoArgFunc -> TwoArgFunc -> Bool
(TwoArgFunc -> TwoArgFunc -> Bool)
-> (TwoArgFunc -> TwoArgFunc -> Bool) -> Eq TwoArgFunc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TwoArgFunc -> TwoArgFunc -> Bool
== :: TwoArgFunc -> TwoArgFunc -> Bool
$c/= :: TwoArgFunc -> TwoArgFunc -> Bool
/= :: TwoArgFunc -> TwoArgFunc -> Bool
Eq,
      -- | @since 1.0.0
      Eq TwoArgFunc
Eq TwoArgFunc =>
(TwoArgFunc -> TwoArgFunc -> Ordering)
-> (TwoArgFunc -> TwoArgFunc -> Bool)
-> (TwoArgFunc -> TwoArgFunc -> Bool)
-> (TwoArgFunc -> TwoArgFunc -> Bool)
-> (TwoArgFunc -> TwoArgFunc -> Bool)
-> (TwoArgFunc -> TwoArgFunc -> TwoArgFunc)
-> (TwoArgFunc -> TwoArgFunc -> TwoArgFunc)
-> Ord TwoArgFunc
TwoArgFunc -> TwoArgFunc -> Bool
TwoArgFunc -> TwoArgFunc -> Ordering
TwoArgFunc -> TwoArgFunc -> TwoArgFunc
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TwoArgFunc -> TwoArgFunc -> Ordering
compare :: TwoArgFunc -> TwoArgFunc -> Ordering
$c< :: TwoArgFunc -> TwoArgFunc -> Bool
< :: TwoArgFunc -> TwoArgFunc -> Bool
$c<= :: TwoArgFunc -> TwoArgFunc -> Bool
<= :: TwoArgFunc -> TwoArgFunc -> Bool
$c> :: TwoArgFunc -> TwoArgFunc -> Bool
> :: TwoArgFunc -> TwoArgFunc -> Bool
$c>= :: TwoArgFunc -> TwoArgFunc -> Bool
>= :: TwoArgFunc -> TwoArgFunc -> Bool
$cmax :: TwoArgFunc -> TwoArgFunc -> TwoArgFunc
max :: TwoArgFunc -> TwoArgFunc -> TwoArgFunc
$cmin :: TwoArgFunc -> TwoArgFunc -> TwoArgFunc
min :: TwoArgFunc -> TwoArgFunc -> TwoArgFunc
Ord,
      -- | @since 1.0.0
      Int -> TwoArgFunc -> ShowS
[TwoArgFunc] -> ShowS
TwoArgFunc -> String
(Int -> TwoArgFunc -> ShowS)
-> (TwoArgFunc -> String)
-> ([TwoArgFunc] -> ShowS)
-> Show TwoArgFunc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TwoArgFunc -> ShowS
showsPrec :: Int -> TwoArgFunc -> ShowS
$cshow :: TwoArgFunc -> String
show :: TwoArgFunc -> String
$cshowList :: [TwoArgFunc] -> ShowS
showList :: [TwoArgFunc] -> ShowS
Show
    )

-- | Does not shrink.
--
-- @since 1.0.0
instance Arbitrary TwoArgFunc where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TwoArgFunc
arbitrary =
    [TwoArgFunc] -> Gen TwoArgFunc
forall a. HasCallStack => [a] -> Gen a
elements
      [ TwoArgFunc
AddInteger,
        TwoArgFunc
SubtractInteger,
        TwoArgFunc
MultiplyInteger,
        TwoArgFunc
DivideInteger,
        TwoArgFunc
QuotientInteger,
        TwoArgFunc
RemainderInteger,
        TwoArgFunc
ModInteger,
        TwoArgFunc
EqualsInteger,
        TwoArgFunc
LessThanInteger,
        TwoArgFunc
LessThanEqualsInteger,
        TwoArgFunc
AppendByteString,
        TwoArgFunc
ConsByteString,
        TwoArgFunc
IndexByteString,
        TwoArgFunc
EqualsByteString,
        TwoArgFunc
LessThanByteString,
        TwoArgFunc
LessThanEqualsByteString,
        TwoArgFunc
AppendString,
        TwoArgFunc
EqualsString,
        TwoArgFunc
ChooseUnit,
        TwoArgFunc
Trace,
        -- MkCons,
        -- ConstrData,
        -- EqualsData,
        -- MkPairData,
        TwoArgFunc
BLS12_381_G1_add,
        TwoArgFunc
BLS12_381_G1_scalarMul,
        TwoArgFunc
BLS12_381_G1_equal,
        TwoArgFunc
BLS12_381_G1_hashToGroup,
        TwoArgFunc
BLS12_381_G2_add,
        TwoArgFunc
BLS12_381_G2_scalarMul,
        TwoArgFunc
BLS12_381_G2_equal,
        TwoArgFunc
BLS12_381_G2_hashToGroup,
        TwoArgFunc
BLS12_381_millerLoop,
        TwoArgFunc
BLS12_381_mulMlResult,
        TwoArgFunc
BLS12_381_finalVerify,
        TwoArgFunc
ByteStringToInteger,
        TwoArgFunc
ReadBit,
        TwoArgFunc
ReplicateByte,
        TwoArgFunc
ShiftByteString,
        TwoArgFunc
RotateByteString
      ]

-- | Produce the type of a two-argument primop.
--
-- @since 1.0.0
typeTwoArgFunc :: TwoArgFunc -> CompT AbstractTy
typeTwoArgFunc :: TwoArgFunc -> CompT AbstractTy
typeTwoArgFunc = \case
  TwoArgFunc
AddInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
SubtractInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
MultiplyInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
DivideInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
QuotientInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
RemainderInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
ModInteger -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
EqualsInteger -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
LessThanInteger -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
LessThanEqualsInteger -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
AppendByteString -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
ConsByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
IndexByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
EqualsByteString -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
LessThanByteString -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
LessThanEqualsByteString -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
AppendString -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
stringT
  TwoArgFunc
EqualsString -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
stringT
  TwoArgFunc
ChooseUnit -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp1 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
unitT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0 ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT (DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0)
  TwoArgFunc
Trace -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp1 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
stringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0 ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT (DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0)
  TwoArgFunc
BLS12_381_G1_add -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
g1T
  TwoArgFunc
BLS12_381_G1_scalarMul -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
g1T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g1T
  TwoArgFunc
BLS12_381_G1_equal -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
g1T
  TwoArgFunc
BLS12_381_G1_hashToGroup -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g1T
  TwoArgFunc
BLS12_381_G2_add -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
g2T
  TwoArgFunc
BLS12_381_G2_scalarMul -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
g2T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g2T
  TwoArgFunc
BLS12_381_G2_equal -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
forall a. ValT a
g2T
  TwoArgFunc
BLS12_381_G2_hashToGroup -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
g2T
  TwoArgFunc
BLS12_381_millerLoop -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
g1T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
g2T ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
mlResultT
  TwoArgFunc
BLS12_381_mulMlResult -> ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
forall a. ValT a
mlResultT
  TwoArgFunc
BLS12_381_finalVerify -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
mlResultT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
mlResultT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
boolT
  TwoArgFunc
ByteStringToInteger -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
boolT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  TwoArgFunc
ReadBit -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
boolT
  TwoArgFunc
ReplicateByte -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
ShiftByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  TwoArgFunc
RotateByteString -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
forall a. ValT a
byteStringT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  where
    combineT :: ValT AbstractTy -> CompT AbstractTy
    combineT :: ValT AbstractTy -> CompT AbstractTy
combineT ValT AbstractTy
t = CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
t ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
t ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
t
    compareT :: ValT AbstractTy -> CompT AbstractTy
    compareT :: ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
t = CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy
t ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
t ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
boolT

-- | All three-argument primitives provided by Plutus.
--
-- @since 1.0.0
data ThreeArgFunc
  = VerifyEd25519Signature
  | VerifyEcdsaSecp256k1Signature
  | VerifySchnorrSecp256k1Signature
  | IfThenElse
  | -- | ChooseList
    -- | CaseList
    IntegerToByteString
  | AndByteString
  | OrByteString
  | XorByteString
  | -- | WriteBits
    ExpModInteger
  deriving stock
    ( -- | @since 1.0.0
      ThreeArgFunc -> ThreeArgFunc -> Bool
(ThreeArgFunc -> ThreeArgFunc -> Bool)
-> (ThreeArgFunc -> ThreeArgFunc -> Bool) -> Eq ThreeArgFunc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ThreeArgFunc -> ThreeArgFunc -> Bool
== :: ThreeArgFunc -> ThreeArgFunc -> Bool
$c/= :: ThreeArgFunc -> ThreeArgFunc -> Bool
/= :: ThreeArgFunc -> ThreeArgFunc -> Bool
Eq,
      -- | @since 1.0.0
      Eq ThreeArgFunc
Eq ThreeArgFunc =>
(ThreeArgFunc -> ThreeArgFunc -> Ordering)
-> (ThreeArgFunc -> ThreeArgFunc -> Bool)
-> (ThreeArgFunc -> ThreeArgFunc -> Bool)
-> (ThreeArgFunc -> ThreeArgFunc -> Bool)
-> (ThreeArgFunc -> ThreeArgFunc -> Bool)
-> (ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc)
-> (ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc)
-> Ord ThreeArgFunc
ThreeArgFunc -> ThreeArgFunc -> Bool
ThreeArgFunc -> ThreeArgFunc -> Ordering
ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ThreeArgFunc -> ThreeArgFunc -> Ordering
compare :: ThreeArgFunc -> ThreeArgFunc -> Ordering
$c< :: ThreeArgFunc -> ThreeArgFunc -> Bool
< :: ThreeArgFunc -> ThreeArgFunc -> Bool
$c<= :: ThreeArgFunc -> ThreeArgFunc -> Bool
<= :: ThreeArgFunc -> ThreeArgFunc -> Bool
$c> :: ThreeArgFunc -> ThreeArgFunc -> Bool
> :: ThreeArgFunc -> ThreeArgFunc -> Bool
$c>= :: ThreeArgFunc -> ThreeArgFunc -> Bool
>= :: ThreeArgFunc -> ThreeArgFunc -> Bool
$cmax :: ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc
max :: ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc
$cmin :: ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc
min :: ThreeArgFunc -> ThreeArgFunc -> ThreeArgFunc
Ord,
      -- | @since 1.0.0
      Int -> ThreeArgFunc -> ShowS
[ThreeArgFunc] -> ShowS
ThreeArgFunc -> String
(Int -> ThreeArgFunc -> ShowS)
-> (ThreeArgFunc -> String)
-> ([ThreeArgFunc] -> ShowS)
-> Show ThreeArgFunc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ThreeArgFunc -> ShowS
showsPrec :: Int -> ThreeArgFunc -> ShowS
$cshow :: ThreeArgFunc -> String
show :: ThreeArgFunc -> String
$cshowList :: [ThreeArgFunc] -> ShowS
showList :: [ThreeArgFunc] -> ShowS
Show
    )

-- | Does not shrink.
--
-- @since 1.0.0
instance Arbitrary ThreeArgFunc where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ThreeArgFunc
arbitrary =
    [ThreeArgFunc] -> Gen ThreeArgFunc
forall a. HasCallStack => [a] -> Gen a
elements
      [ ThreeArgFunc
VerifyEd25519Signature,
        ThreeArgFunc
VerifyEcdsaSecp256k1Signature,
        ThreeArgFunc
VerifySchnorrSecp256k1Signature,
        ThreeArgFunc
IfThenElse,
        -- ChooseList,
        -- CaseList,
        ThreeArgFunc
IntegerToByteString,
        ThreeArgFunc
AndByteString,
        ThreeArgFunc
OrByteString,
        ThreeArgFunc
XorByteString,
        -- WriteBits,
        ThreeArgFunc
ExpModInteger
      ]

-- | Produce the type of a three-argument primop.
--
-- @since 1.0.0
typeThreeArgFunc :: ThreeArgFunc -> CompT AbstractTy
typeThreeArgFunc :: ThreeArgFunc -> CompT AbstractTy
typeThreeArgFunc = \case
  ThreeArgFunc
VerifyEd25519Signature -> CompT AbstractTy
signatureT
  ThreeArgFunc
VerifyEcdsaSecp256k1Signature -> CompT AbstractTy
signatureT
  ThreeArgFunc
VerifySchnorrSecp256k1Signature -> CompT AbstractTy
signatureT
  ThreeArgFunc
IfThenElse ->
    CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp1 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
      ValT AbstractTy
forall a. ValT a
boolT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT (DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0)
  ThreeArgFunc
IntegerToByteString ->
    CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
      ValT AbstractTy
forall a. ValT a
boolT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT
  ThreeArgFunc
AndByteString -> CompT AbstractTy
bitwiseT
  ThreeArgFunc
OrByteString -> CompT AbstractTy
bitwiseT
  ThreeArgFunc
XorByteString -> CompT AbstractTy
bitwiseT
  ThreeArgFunc
ExpModInteger ->
    CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
      ValT AbstractTy
forall a. ValT a
integerT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
integerT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
integerT
  where
    signatureT :: CompT AbstractTy
    signatureT :: CompT AbstractTy
signatureT =
      CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
        ValT AbstractTy
forall a. ValT a
byteStringT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
boolT
    bitwiseT :: CompT AbstractTy
    bitwiseT :: CompT AbstractTy
bitwiseT =
      CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp0 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
        ValT AbstractTy
forall a. ValT a
boolT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
forall a. ValT a
byteStringT
          ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
forall a. ValT a
byteStringT

{-
-- | All six-argument primitives provided by Plutus.
--
-- @since 1.0.0
data SixArgFunc
  = ChooseData
  | CaseData
  deriving stock
    ( -- | @since 1.0.0
      Eq,
      -- | @since 1.0.0
      Ord,
      -- | @since 1.0.0
      Show
    )

-- | Does not shrink.
--
-- @since 1.0.0
instance Arbitrary SixArgFunc where
  {-# INLINEABLE arbitrary #-}
  arbitrary = elements [ChooseData, CaseData]
-}