-- |
-- 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.
--
-- @since 1.0.0
module Covenant.Prim
  ( OneArgFunc (..),
    typeOneArgFunc,
    TwoArgFunc (..),
    typeTwoArgFunc,
    ThreeArgFunc (..),
    typeThreeArgFunc,
    SixArgFunc (..),
    typeSixArgFunc,
  )
where

import Covenant.DeBruijn (DeBruijn (S, Z))
import Covenant.Index (ix0, ix1)
import Covenant.Type
  ( AbstractTy,
    CompT (Comp0, Comp1, Comp2),
    CompTBody (ReturnT, (:--:>)),
    ValT (ThunkT),
    boolT,
    byteStringT,
    dataType1T,
    dataType2T,
    dataTypeT,
    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.
--
-- 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
  | -- | @since 1.1.0
    FstPair
  | -- | @since 1.1.0
    SndPair
  | -- | @since 1.1.0
    HeadList
  | -- | @since 1.1.0
    TailList
  | -- | @since 1.1.0
    NullList
  | -- | @since 1.1.0
    MapData
  | -- | @since 1.1.0
    ListData
  | -- | @since 1.1.0
    IData
  | -- | @since 1.1.0
    BData
  | -- | @since 1.1.0
    UnConstrData
  | -- | @since 1.1.0
    UnMapData
  | -- | @since 1.1.0
    UnListData
  | -- | @since 1.1.0
    UnIData
  | -- | @since 1.1.0
    UnBData
  | -- | @since 1.1.0
    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,
        OneArgFunc
FstPair,
        OneArgFunc
SndPair,
        OneArgFunc
HeadList,
        OneArgFunc
TailList,
        OneArgFunc
NullList,
        OneArgFunc
MapData,
        OneArgFunc
ListData,
        OneArgFunc
IData,
        OneArgFunc
BData,
        OneArgFunc
UnConstrData,
        OneArgFunc
UnMapData,
        OneArgFunc
UnListData,
        OneArgFunc
UnIData,
        OneArgFunc
UnBData,
        OneArgFunc
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
FstPair -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp2 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
aT ValT AbstractTy
bT 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
aT
  OneArgFunc
SndPair -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp2 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
aT ValT AbstractTy
bT 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
bT
  OneArgFunc
HeadList -> 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 -> ValT AbstractTy
listT ValT AbstractTy
aT 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
aT
  OneArgFunc
TailList -> 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 -> ValT AbstractTy
listT ValT AbstractTy
aT 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 -> ValT AbstractTy
listT ValT AbstractTy
aT)
  OneArgFunc
NullList -> 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 -> ValT AbstractTy
listT ValT AbstractTy
aT 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
  OneArgFunc
MapData -> 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 -> ValT AbstractTy
listT (ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
dataT ValT AbstractTy
dataT) 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
dataT
  OneArgFunc
ListData -> 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 -> ValT AbstractTy
listT ValT AbstractTy
dataT 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
dataT
  OneArgFunc
IData -> 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 -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
dataT
  OneArgFunc
BData -> 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
dataT
  OneArgFunc
UnConstrData -> 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
dataT 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 -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
forall a. ValT a
integerT (ValT AbstractTy -> ValT AbstractTy
listT ValT AbstractTy
dataT))
  OneArgFunc
UnMapData -> 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
dataT 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 -> ValT AbstractTy
listT (ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
dataT ValT AbstractTy
dataT))
  OneArgFunc
UnListData -> 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
dataT 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 -> ValT AbstractTy
listT ValT AbstractTy
dataT)
  OneArgFunc
UnIData -> 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
dataT 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
UnBData -> 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
dataT 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
SerialiseData -> 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
dataT 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_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
  | -- | @since 1.1.0
    MkCons
  | -- | @since 1.1.0
    ConstrData
  | -- | @since 1.1.0
    EqualsData
  | -- | @since 1.1.0
    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,
        TwoArgFunc
MkCons,
        TwoArgFunc
ConstrData,
        TwoArgFunc
EqualsData,
        TwoArgFunc
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
:--:> ValT AbstractTy
aT 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
aT
  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
:--:> ValT AbstractTy
aT 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
aT
  TwoArgFunc
MkCons -> 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
aT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> ValT AbstractTy
listT ValT AbstractTy
aT 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 -> ValT AbstractTy
listT ValT AbstractTy
aT)
  TwoArgFunc
ConstrData -> 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 -> ValT AbstractTy
listT ValT AbstractTy
dataT 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
dataT
  TwoArgFunc
EqualsData -> ValT AbstractTy -> CompT AbstractTy
compareT ValT AbstractTy
dataT
  TwoArgFunc
MkPairData -> 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
dataT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
dataT 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 -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
dataT ValT AbstractTy
dataT)
  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
  | -- | @since 1.1.0
    ChooseList
  | -- | @since 1.1.0
    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,
        ThreeArgFunc
ChooseList,
        ThreeArgFunc
CaseList,
        ThreeArgFunc
IntegerToByteString,
        ThreeArgFunc
AndByteString,
        ThreeArgFunc
OrByteString,
        ThreeArgFunc
XorByteString,
        ThreeArgFunc
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
:--:> ValT AbstractTy
aT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT 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
aT
  ThreeArgFunc
ChooseList -> CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp2 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$ ValT AbstractTy -> ValT AbstractTy
listT ValT AbstractTy
aT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
bT ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
bT 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
bT
  ThreeArgFunc
CaseList ->
    CompTBody AbstractTy -> CompT AbstractTy
forall a. CompTBody a -> CompT a
Comp2 (CompTBody AbstractTy -> CompT AbstractTy)
-> CompTBody AbstractTy -> CompT AbstractTy
forall a b. (a -> b) -> a -> b
$
      ValT AbstractTy
bT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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
aTOuter ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> ValT AbstractTy
listT ValT AbstractTy
aTOuter 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
bTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy -> ValT AbstractTy
listT ValT AbstractTy
aT
        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
bT
  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
WriteBits ->
    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 -> ValT AbstractTy
listT 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
boolT 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
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.1.0
data SixArgFunc
  = ChooseData
  | CaseData
  deriving stock
    ( -- | @since 1.0.0
      SixArgFunc -> SixArgFunc -> Bool
(SixArgFunc -> SixArgFunc -> Bool)
-> (SixArgFunc -> SixArgFunc -> Bool) -> Eq SixArgFunc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SixArgFunc -> SixArgFunc -> Bool
== :: SixArgFunc -> SixArgFunc -> Bool
$c/= :: SixArgFunc -> SixArgFunc -> Bool
/= :: SixArgFunc -> SixArgFunc -> Bool
Eq,
      -- | @since 1.0.0
      Eq SixArgFunc
Eq SixArgFunc =>
(SixArgFunc -> SixArgFunc -> Ordering)
-> (SixArgFunc -> SixArgFunc -> Bool)
-> (SixArgFunc -> SixArgFunc -> Bool)
-> (SixArgFunc -> SixArgFunc -> Bool)
-> (SixArgFunc -> SixArgFunc -> Bool)
-> (SixArgFunc -> SixArgFunc -> SixArgFunc)
-> (SixArgFunc -> SixArgFunc -> SixArgFunc)
-> Ord SixArgFunc
SixArgFunc -> SixArgFunc -> Bool
SixArgFunc -> SixArgFunc -> Ordering
SixArgFunc -> SixArgFunc -> SixArgFunc
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 :: SixArgFunc -> SixArgFunc -> Ordering
compare :: SixArgFunc -> SixArgFunc -> Ordering
$c< :: SixArgFunc -> SixArgFunc -> Bool
< :: SixArgFunc -> SixArgFunc -> Bool
$c<= :: SixArgFunc -> SixArgFunc -> Bool
<= :: SixArgFunc -> SixArgFunc -> Bool
$c> :: SixArgFunc -> SixArgFunc -> Bool
> :: SixArgFunc -> SixArgFunc -> Bool
$c>= :: SixArgFunc -> SixArgFunc -> Bool
>= :: SixArgFunc -> SixArgFunc -> Bool
$cmax :: SixArgFunc -> SixArgFunc -> SixArgFunc
max :: SixArgFunc -> SixArgFunc -> SixArgFunc
$cmin :: SixArgFunc -> SixArgFunc -> SixArgFunc
min :: SixArgFunc -> SixArgFunc -> SixArgFunc
Ord,
      -- | @since 1.0.0
      Int -> SixArgFunc -> ShowS
[SixArgFunc] -> ShowS
SixArgFunc -> String
(Int -> SixArgFunc -> ShowS)
-> (SixArgFunc -> String)
-> ([SixArgFunc] -> ShowS)
-> Show SixArgFunc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SixArgFunc -> ShowS
showsPrec :: Int -> SixArgFunc -> ShowS
$cshow :: SixArgFunc -> String
show :: SixArgFunc -> String
$cshowList :: [SixArgFunc] -> ShowS
showList :: [SixArgFunc] -> ShowS
Show
    )

-- | Does not shrink.
--
-- @since 1.1.0
instance Arbitrary SixArgFunc where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen SixArgFunc
arbitrary = [SixArgFunc] -> Gen SixArgFunc
forall a. HasCallStack => [a] -> Gen a
elements [SixArgFunc
ChooseData, SixArgFunc
CaseData]

-- | Produce the type of a six-argument primop.
--
-- @since 1.1.0
typeSixArgFunc :: SixArgFunc -> CompT AbstractTy
typeSixArgFunc :: SixArgFunc -> CompT AbstractTy
typeSixArgFunc = \case
  SixArgFunc
ChooseData ->
    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
dataT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
aT
        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
aT
  SixArgFunc
CaseData ->
    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
$
      CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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 -> ValT AbstractTy
listT ValT AbstractTy
dataT 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
aTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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 -> ValT AbstractTy
listT (ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT ValT AbstractTy
dataT ValT AbstractTy
dataT) 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
aTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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 -> ValT AbstractTy
listT ValT AbstractTy
dataT 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
aTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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 -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a
ReturnT ValT AbstractTy
aTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> CompT AbstractTy -> ValT AbstractTy
forall a. CompT a -> ValT a
ThunkT (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
aTOuter)
        ValT AbstractTy -> CompTBody AbstractTy -> CompTBody AbstractTy
forall a. ValT a -> CompTBody a -> CompTBody a
:--:> ValT AbstractTy
dataT
        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
aT

-- Helpers

dataT :: ValT AbstractTy
dataT :: ValT AbstractTy
dataT = TyName -> ValT AbstractTy
forall a. TyName -> ValT a
dataTypeT TyName
"Data"

listT :: ValT AbstractTy -> ValT AbstractTy
listT :: ValT AbstractTy -> ValT AbstractTy
listT = TyName -> ValT AbstractTy -> ValT AbstractTy
dataType1T TyName
"List"

pairT :: ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT :: ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
pairT = TyName -> ValT AbstractTy -> ValT AbstractTy -> ValT AbstractTy
dataType2T TyName
"Pair"

aT :: ValT AbstractTy
aT :: ValT AbstractTy
aT = DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0

aTOuter :: ValT AbstractTy
aTOuter :: ValT AbstractTy
aTOuter = DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar (DeBruijn -> DeBruijn
S DeBruijn
Z) Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix0

bT :: ValT AbstractTy
bT :: ValT AbstractTy
bT = DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar DeBruijn
Z Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix1

bTOuter :: ValT AbstractTy
bTOuter :: ValT AbstractTy
bTOuter = DeBruijn -> Index "tyvar" -> ValT AbstractTy
tyvar (DeBruijn -> DeBruijn
S DeBruijn
Z) Index "tyvar"
forall (ofWhat :: Symbol). Index ofWhat
ix1