{-# LANGUAGE DeriveAnyClass     #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE TypeApplications   #-}
-- This ensures that we don't put *anything* about these functions into the interface
-- file, otherwise GHC can be clever about the ones that are always error, even though
-- they're NOINLINE!
{-# OPTIONS_GHC -O0 #-}
-- | This module contains the special Haskell names that are used to map to builtin types or functions
-- in Plutus Core.
--
-- Most users should not use this module directly, but rather use 'PlutusTx.Builtins'.
module PlutusTx.Builtins.Internal where

import Codec.Serialise
import Control.DeepSeq (NFData)
import Crypto qualified
import Data.ByteArray qualified as BA
import Data.ByteString as BS
import Data.ByteString.Hash qualified as Hash
import Data.Coerce (coerce)
import Data.Data
import Data.Hashable (Hashable (..))
import Data.Maybe (fromMaybe)
import Data.Text as Text (Text, empty)
import Data.Text.Encoding as Text (decodeUtf8, encodeUtf8)
import GHC.Generics (Generic)
import PlutusCore.Data qualified as PLC
import PlutusTx.Utils (mustBeReplaced)
import Prettyprinter (Pretty (..), viaShow)

{-
We do not use qualified import because the whole module contains off-chain code
which is replaced later with on-chain implementations by the plutus-tx-plugin.
-}
import Prelude as Haskell

{- Note [Builtin name definitions]
The builtins here have definitions so they can be used in off-chain code too.

However they *must* be replaced by the compiler when used in Plutus Tx code, so
in particular they must *not* be inlined, otherwise we can't spot them to replace
them.
-}

{- Note [Delaying error]
The Plutus Core 'error' builtin is of type 'forall a . a', but the
one we expose here is of type 'forall a . () -> a'.

This is because it's hard to get the evaluation order right with
the non-delayed version - it's easy to end up with it getting thrown
unconditionally, or before some other effect (e.g. tracing). On the other
hand, it's much easier to work with the delayed version.

But why not just define that in the library? i.e.

    error = \_ -> Builtins.error

The answer is that GHC is eager to inline and reduce this function, which
does the Wrong Thing. We can't stop GHC doing this (at the moment), but
for most of our functions it's not a *semantic* problem. Here, however,
it is a problem. So we just expose the delayed version as the builtin.
-}

{-# NOINLINE error #-}
error :: BuiltinUnit -> a
error :: BuiltinUnit -> a
error = String -> BuiltinUnit -> a
forall a. String -> a
mustBeReplaced String
"error"

{-
BOOL
-}

newtype BuiltinBool = BuiltinBool Bool deriving stock Typeable BuiltinBool
DataType
Constr
Typeable BuiltinBool
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinBool -> c BuiltinBool)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BuiltinBool)
-> (BuiltinBool -> Constr)
-> (BuiltinBool -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BuiltinBool))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BuiltinBool))
-> ((forall b. Data b => b -> b) -> BuiltinBool -> BuiltinBool)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r)
-> (forall u. (forall d. Data d => d -> u) -> BuiltinBool -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinBool -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool)
-> Data BuiltinBool
BuiltinBool -> DataType
BuiltinBool -> Constr
(forall b. Data b => b -> b) -> BuiltinBool -> BuiltinBool
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinBool -> c BuiltinBool
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinBool
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BuiltinBool -> u
forall u. (forall d. Data d => d -> u) -> BuiltinBool -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinBool
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinBool -> c BuiltinBool
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinBool)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinBool)
$cBuiltinBool :: Constr
$tBuiltinBool :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
gmapMp :: (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
gmapM :: (forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinBool -> m BuiltinBool
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinBool -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BuiltinBool -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinBool -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BuiltinBool -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinBool -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinBool -> BuiltinBool
$cgmapT :: (forall b. Data b => b -> b) -> BuiltinBool -> BuiltinBool
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinBool)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinBool)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BuiltinBool)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinBool)
dataTypeOf :: BuiltinBool -> DataType
$cdataTypeOf :: BuiltinBool -> DataType
toConstr :: BuiltinBool -> Constr
$ctoConstr :: BuiltinBool -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinBool
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinBool
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinBool -> c BuiltinBool
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinBool -> c BuiltinBool
$cp1Data :: Typeable BuiltinBool
Data

{-# NOINLINE true #-}
true :: BuiltinBool
true :: BuiltinBool
true = Bool -> BuiltinBool
coerce Bool
True

{-# NOINLINE false #-}
false :: BuiltinBool
false :: BuiltinBool
false = Bool -> BuiltinBool
coerce Bool
False

{-# NOINLINE ifThenElse #-}
ifThenElse :: BuiltinBool -> a -> a -> a
ifThenElse :: BuiltinBool -> a -> a -> a
ifThenElse (BuiltinBool Bool
b) a
x a
y = if Bool
b then a
x else a
y

{-
UNIT
-}

newtype BuiltinUnit = BuiltinUnit () deriving stock Typeable BuiltinUnit
DataType
Constr
Typeable BuiltinUnit
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinUnit -> c BuiltinUnit)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BuiltinUnit)
-> (BuiltinUnit -> Constr)
-> (BuiltinUnit -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BuiltinUnit))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BuiltinUnit))
-> ((forall b. Data b => b -> b) -> BuiltinUnit -> BuiltinUnit)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r)
-> (forall u. (forall d. Data d => d -> u) -> BuiltinUnit -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinUnit -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit)
-> Data BuiltinUnit
BuiltinUnit -> DataType
BuiltinUnit -> Constr
(forall b. Data b => b -> b) -> BuiltinUnit -> BuiltinUnit
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinUnit -> c BuiltinUnit
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinUnit
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BuiltinUnit -> u
forall u. (forall d. Data d => d -> u) -> BuiltinUnit -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinUnit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinUnit -> c BuiltinUnit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinUnit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinUnit)
$cBuiltinUnit :: Constr
$tBuiltinUnit :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
gmapMp :: (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
gmapM :: (forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinUnit -> m BuiltinUnit
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinUnit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BuiltinUnit -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinUnit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BuiltinUnit -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinUnit -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinUnit -> BuiltinUnit
$cgmapT :: (forall b. Data b => b -> b) -> BuiltinUnit -> BuiltinUnit
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinUnit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinUnit)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BuiltinUnit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinUnit)
dataTypeOf :: BuiltinUnit -> DataType
$cdataTypeOf :: BuiltinUnit -> DataType
toConstr :: BuiltinUnit -> Constr
$ctoConstr :: BuiltinUnit -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinUnit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinUnit
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinUnit -> c BuiltinUnit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinUnit -> c BuiltinUnit
$cp1Data :: Typeable BuiltinUnit
Data

{-# NOINLINE unitval #-}
unitval :: BuiltinUnit
unitval :: BuiltinUnit
unitval = () -> BuiltinUnit
BuiltinUnit ()

{-# NOINLINE chooseUnit #-}
chooseUnit :: BuiltinUnit -> a -> a
chooseUnit :: BuiltinUnit -> a -> a
chooseUnit (BuiltinUnit ()) a
a = a
a

{-
INTEGER
-}

type BuiltinInteger = Integer

{-# NOINLINE addInteger #-}
addInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
addInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
addInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Num BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Num a => a -> a -> a
(+) @Integer)

{-# NOINLINE subtractInteger #-}
subtractInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
subtractInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
subtractInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce ((-) @Integer)

{-# NOINLINE multiplyInteger #-}
multiplyInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
multiplyInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
multiplyInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Num BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Num a => a -> a -> a
(*) @Integer)

{-# NOINLINE divideInteger #-}
divideInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
divideInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
divideInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Integral BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Integral a => a -> a -> a
div @Integer)

{-# NOINLINE modInteger #-}
modInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
modInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
modInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Integral BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Integral a => a -> a -> a
mod @Integer)

{-# NOINLINE quotientInteger #-}
quotientInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
quotientInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
quotientInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Integral BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Integral a => a -> a -> a
quot @Integer)

{-# NOINLINE remainderInteger #-}
remainderInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
remainderInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinInteger
remainderInteger = (BuiltinInteger -> BuiltinInteger -> BuiltinInteger)
-> BuiltinInteger -> BuiltinInteger -> BuiltinInteger
coerce (Integral BuiltinInteger =>
BuiltinInteger -> BuiltinInteger -> BuiltinInteger
forall a. Integral a => a -> a -> a
rem @Integer)

{-# NOINLINE lessThanInteger #-}
lessThanInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
lessThanInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
lessThanInteger = (BuiltinInteger -> BuiltinInteger -> Bool)
-> BuiltinInteger -> BuiltinInteger -> BuiltinBool
coerce (Ord BuiltinInteger => BuiltinInteger -> BuiltinInteger -> Bool
forall a. Ord a => a -> a -> Bool
(<) @Integer)

{-# NOINLINE lessThanEqualsInteger #-}
lessThanEqualsInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
lessThanEqualsInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
lessThanEqualsInteger = (BuiltinInteger -> BuiltinInteger -> Bool)
-> BuiltinInteger -> BuiltinInteger -> BuiltinBool
coerce (Ord BuiltinInteger => BuiltinInteger -> BuiltinInteger -> Bool
forall a. Ord a => a -> a -> Bool
(<=) @Integer)

{-# NOINLINE equalsInteger #-}
equalsInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
equalsInteger :: BuiltinInteger -> BuiltinInteger -> BuiltinBool
equalsInteger = (BuiltinInteger -> BuiltinInteger -> Bool)
-> BuiltinInteger -> BuiltinInteger -> BuiltinBool
coerce (Eq BuiltinInteger => BuiltinInteger -> BuiltinInteger -> Bool
forall a. Eq a => a -> a -> Bool
(==) @Integer)

{-
BYTESTRING
-}

-- | An opaque type representing Plutus Core ByteStrings.
newtype BuiltinByteString = BuiltinByteString ByteString
  deriving stock ((forall x. BuiltinByteString -> Rep BuiltinByteString x)
-> (forall x. Rep BuiltinByteString x -> BuiltinByteString)
-> Generic BuiltinByteString
forall x. Rep BuiltinByteString x -> BuiltinByteString
forall x. BuiltinByteString -> Rep BuiltinByteString x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuiltinByteString x -> BuiltinByteString
$cfrom :: forall x. BuiltinByteString -> Rep BuiltinByteString x
Generic, Typeable BuiltinByteString
DataType
Constr
Typeable BuiltinByteString
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> BuiltinByteString
    -> c BuiltinByteString)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BuiltinByteString)
-> (BuiltinByteString -> Constr)
-> (BuiltinByteString -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BuiltinByteString))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BuiltinByteString))
-> ((forall b. Data b => b -> b)
    -> BuiltinByteString -> BuiltinByteString)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> BuiltinByteString -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinByteString -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BuiltinByteString -> m BuiltinByteString)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinByteString -> m BuiltinByteString)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinByteString -> m BuiltinByteString)
-> Data BuiltinByteString
BuiltinByteString -> DataType
BuiltinByteString -> Constr
(forall b. Data b => b -> b)
-> BuiltinByteString -> BuiltinByteString
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinByteString -> c BuiltinByteString
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinByteString
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> BuiltinByteString -> u
forall u. (forall d. Data d => d -> u) -> BuiltinByteString -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinByteString
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinByteString -> c BuiltinByteString
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinByteString)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinByteString)
$cBuiltinByteString :: Constr
$tBuiltinByteString :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
gmapMp :: (forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
gmapM :: (forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BuiltinByteString -> m BuiltinByteString
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinByteString -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> BuiltinByteString -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinByteString -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BuiltinByteString -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinByteString -> r
gmapT :: (forall b. Data b => b -> b)
-> BuiltinByteString -> BuiltinByteString
$cgmapT :: (forall b. Data b => b -> b)
-> BuiltinByteString -> BuiltinByteString
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinByteString)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinByteString)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BuiltinByteString)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinByteString)
dataTypeOf :: BuiltinByteString -> DataType
$cdataTypeOf :: BuiltinByteString -> DataType
toConstr :: BuiltinByteString -> Constr
$ctoConstr :: BuiltinByteString -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinByteString
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinByteString
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinByteString -> c BuiltinByteString
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinByteString -> c BuiltinByteString
$cp1Data :: Typeable BuiltinByteString
Data)
  deriving newtype (Int -> BuiltinByteString -> ShowS
[BuiltinByteString] -> ShowS
BuiltinByteString -> String
(Int -> BuiltinByteString -> ShowS)
-> (BuiltinByteString -> String)
-> ([BuiltinByteString] -> ShowS)
-> Show BuiltinByteString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuiltinByteString] -> ShowS
$cshowList :: [BuiltinByteString] -> ShowS
show :: BuiltinByteString -> String
$cshow :: BuiltinByteString -> String
showsPrec :: Int -> BuiltinByteString -> ShowS
$cshowsPrec :: Int -> BuiltinByteString -> ShowS
Haskell.Show, BuiltinByteString -> BuiltinByteString -> Bool
(BuiltinByteString -> BuiltinByteString -> Bool)
-> (BuiltinByteString -> BuiltinByteString -> Bool)
-> Eq BuiltinByteString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuiltinByteString -> BuiltinByteString -> Bool
$c/= :: BuiltinByteString -> BuiltinByteString -> Bool
== :: BuiltinByteString -> BuiltinByteString -> Bool
$c== :: BuiltinByteString -> BuiltinByteString -> Bool
Haskell.Eq, Eq BuiltinByteString
Eq BuiltinByteString
-> (BuiltinByteString -> BuiltinByteString -> Ordering)
-> (BuiltinByteString -> BuiltinByteString -> Bool)
-> (BuiltinByteString -> BuiltinByteString -> Bool)
-> (BuiltinByteString -> BuiltinByteString -> Bool)
-> (BuiltinByteString -> BuiltinByteString -> Bool)
-> (BuiltinByteString -> BuiltinByteString -> BuiltinByteString)
-> (BuiltinByteString -> BuiltinByteString -> BuiltinByteString)
-> Ord BuiltinByteString
BuiltinByteString -> BuiltinByteString -> Bool
BuiltinByteString -> BuiltinByteString -> Ordering
BuiltinByteString -> BuiltinByteString -> BuiltinByteString
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
min :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
$cmin :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
max :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
$cmax :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
>= :: BuiltinByteString -> BuiltinByteString -> Bool
$c>= :: BuiltinByteString -> BuiltinByteString -> Bool
> :: BuiltinByteString -> BuiltinByteString -> Bool
$c> :: BuiltinByteString -> BuiltinByteString -> Bool
<= :: BuiltinByteString -> BuiltinByteString -> Bool
$c<= :: BuiltinByteString -> BuiltinByteString -> Bool
< :: BuiltinByteString -> BuiltinByteString -> Bool
$c< :: BuiltinByteString -> BuiltinByteString -> Bool
compare :: BuiltinByteString -> BuiltinByteString -> Ordering
$ccompare :: BuiltinByteString -> BuiltinByteString -> Ordering
$cp1Ord :: Eq BuiltinByteString
Haskell.Ord, b -> BuiltinByteString -> BuiltinByteString
NonEmpty BuiltinByteString -> BuiltinByteString
BuiltinByteString -> BuiltinByteString -> BuiltinByteString
(BuiltinByteString -> BuiltinByteString -> BuiltinByteString)
-> (NonEmpty BuiltinByteString -> BuiltinByteString)
-> (forall b.
    Integral b =>
    b -> BuiltinByteString -> BuiltinByteString)
-> Semigroup BuiltinByteString
forall b. Integral b => b -> BuiltinByteString -> BuiltinByteString
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> BuiltinByteString -> BuiltinByteString
$cstimes :: forall b. Integral b => b -> BuiltinByteString -> BuiltinByteString
sconcat :: NonEmpty BuiltinByteString -> BuiltinByteString
$csconcat :: NonEmpty BuiltinByteString -> BuiltinByteString
<> :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
$c<> :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
Haskell.Semigroup, Semigroup BuiltinByteString
BuiltinByteString
Semigroup BuiltinByteString
-> BuiltinByteString
-> (BuiltinByteString -> BuiltinByteString -> BuiltinByteString)
-> ([BuiltinByteString] -> BuiltinByteString)
-> Monoid BuiltinByteString
[BuiltinByteString] -> BuiltinByteString
BuiltinByteString -> BuiltinByteString -> BuiltinByteString
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [BuiltinByteString] -> BuiltinByteString
$cmconcat :: [BuiltinByteString] -> BuiltinByteString
mappend :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
$cmappend :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
mempty :: BuiltinByteString
$cmempty :: BuiltinByteString
$cp1Monoid :: Semigroup BuiltinByteString
Haskell.Monoid)
  deriving newtype (Int -> BuiltinByteString -> Int
BuiltinByteString -> Int
(Int -> BuiltinByteString -> Int)
-> (BuiltinByteString -> Int) -> Hashable BuiltinByteString
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: BuiltinByteString -> Int
$chash :: BuiltinByteString -> Int
hashWithSalt :: Int -> BuiltinByteString -> Int
$chashWithSalt :: Int -> BuiltinByteString -> Int
Hashable, Decoder s BuiltinByteString
Decoder s [BuiltinByteString]
[BuiltinByteString] -> Encoding
BuiltinByteString -> Encoding
(BuiltinByteString -> Encoding)
-> (forall s. Decoder s BuiltinByteString)
-> ([BuiltinByteString] -> Encoding)
-> (forall s. Decoder s [BuiltinByteString])
-> Serialise BuiltinByteString
forall s. Decoder s [BuiltinByteString]
forall s. Decoder s BuiltinByteString
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [BuiltinByteString]
$cdecodeList :: forall s. Decoder s [BuiltinByteString]
encodeList :: [BuiltinByteString] -> Encoding
$cencodeList :: [BuiltinByteString] -> Encoding
decode :: Decoder s BuiltinByteString
$cdecode :: forall s. Decoder s BuiltinByteString
encode :: BuiltinByteString -> Encoding
$cencode :: BuiltinByteString -> Encoding
Serialise, BuiltinByteString -> ()
(BuiltinByteString -> ()) -> NFData BuiltinByteString
forall a. (a -> ()) -> NFData a
rnf :: BuiltinByteString -> ()
$crnf :: BuiltinByteString -> ()
NFData, BuiltinByteString -> Int
BuiltinByteString -> Ptr p -> IO ()
BuiltinByteString -> (Ptr p -> IO a) -> IO a
(BuiltinByteString -> Int)
-> (forall p a. BuiltinByteString -> (Ptr p -> IO a) -> IO a)
-> (forall p. BuiltinByteString -> Ptr p -> IO ())
-> ByteArrayAccess BuiltinByteString
forall p. BuiltinByteString -> Ptr p -> IO ()
forall ba.
(ba -> Int)
-> (forall p a. ba -> (Ptr p -> IO a) -> IO a)
-> (forall p. ba -> Ptr p -> IO ())
-> ByteArrayAccess ba
forall p a. BuiltinByteString -> (Ptr p -> IO a) -> IO a
copyByteArrayToPtr :: BuiltinByteString -> Ptr p -> IO ()
$ccopyByteArrayToPtr :: forall p. BuiltinByteString -> Ptr p -> IO ()
withByteArray :: BuiltinByteString -> (Ptr p -> IO a) -> IO a
$cwithByteArray :: forall p a. BuiltinByteString -> (Ptr p -> IO a) -> IO a
length :: BuiltinByteString -> Int
$clength :: BuiltinByteString -> Int
BA.ByteArrayAccess, Eq BuiltinByteString
Ord BuiltinByteString
Monoid BuiltinByteString
ByteArrayAccess BuiltinByteString
Eq BuiltinByteString
-> Ord BuiltinByteString
-> Monoid BuiltinByteString
-> ByteArrayAccess BuiltinByteString
-> (forall p a.
    Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString))
-> ByteArray BuiltinByteString
Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString)
forall ba.
Eq ba
-> Ord ba
-> Monoid ba
-> ByteArrayAccess ba
-> (forall p a. Int -> (Ptr p -> IO a) -> IO (a, ba))
-> ByteArray ba
forall p a. Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString)
allocRet :: Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString)
$callocRet :: forall p a. Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString)
$cp4ByteArray :: ByteArrayAccess BuiltinByteString
$cp3ByteArray :: Monoid BuiltinByteString
$cp2ByteArray :: Ord BuiltinByteString
$cp1ByteArray :: Eq BuiltinByteString
BA.ByteArray)

instance Pretty BuiltinByteString where
    pretty :: BuiltinByteString -> Doc ann
pretty = BuiltinByteString -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow

{-# NOINLINE appendByteString #-}
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
appendByteString (BuiltinByteString ByteString
b1) (BuiltinByteString ByteString
b2) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString -> ByteString
BS.append ByteString
b1 ByteString
b2

{-# NOINLINE consByteString #-}
consByteString :: BuiltinInteger -> BuiltinByteString -> BuiltinByteString
consByteString :: BuiltinInteger -> BuiltinByteString -> BuiltinByteString
consByteString BuiltinInteger
n (BuiltinByteString ByteString
b) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ Word8 -> ByteString -> ByteString
BS.cons (BuiltinInteger -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral BuiltinInteger
n) ByteString
b

{-# NOINLINE sliceByteString #-}
sliceByteString :: BuiltinInteger -> BuiltinInteger -> BuiltinByteString -> BuiltinByteString
sliceByteString :: BuiltinInteger
-> BuiltinInteger -> BuiltinByteString -> BuiltinByteString
sliceByteString BuiltinInteger
start BuiltinInteger
n (BuiltinByteString ByteString
b) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
BS.take (BuiltinInteger -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral BuiltinInteger
n) (Int -> ByteString -> ByteString
BS.drop (BuiltinInteger -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral BuiltinInteger
start) ByteString
b)

{-# NOINLINE lengthOfByteString #-}
lengthOfByteString :: BuiltinByteString -> BuiltinInteger
lengthOfByteString :: BuiltinByteString -> BuiltinInteger
lengthOfByteString (BuiltinByteString ByteString
b) = Int -> BuiltinInteger
forall a. Integral a => a -> BuiltinInteger
toInteger (Int -> BuiltinInteger) -> Int -> BuiltinInteger
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
BS.length ByteString
b

{-# NOINLINE indexByteString #-}
indexByteString :: BuiltinByteString -> BuiltinInteger -> BuiltinInteger
indexByteString :: BuiltinByteString -> BuiltinInteger -> BuiltinInteger
indexByteString (BuiltinByteString ByteString
b) BuiltinInteger
i = Word8 -> BuiltinInteger
forall a. Integral a => a -> BuiltinInteger
toInteger (Word8 -> BuiltinInteger) -> Word8 -> BuiltinInteger
forall a b. (a -> b) -> a -> b
$ ByteString -> Int -> Word8
BS.index ByteString
b (BuiltinInteger -> Int
forall a. Num a => BuiltinInteger -> a
fromInteger BuiltinInteger
i)

{-# NOINLINE emptyByteString #-}
emptyByteString :: BuiltinByteString
emptyByteString :: BuiltinByteString
emptyByteString = ByteString -> BuiltinByteString
BuiltinByteString ByteString
BS.empty

{-# NOINLINE sha2_256 #-}
sha2_256 :: BuiltinByteString -> BuiltinByteString
sha2_256 :: BuiltinByteString -> BuiltinByteString
sha2_256 (BuiltinByteString ByteString
b) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
Hash.sha2 ByteString
b

{-# NOINLINE sha3_256 #-}
sha3_256 :: BuiltinByteString -> BuiltinByteString
sha3_256 :: BuiltinByteString -> BuiltinByteString
sha3_256 (BuiltinByteString ByteString
b) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
Hash.sha3 ByteString
b

{-# NOINLINE blake2b_256 #-}
blake2b_256 :: BuiltinByteString -> BuiltinByteString
blake2b_256 :: BuiltinByteString -> BuiltinByteString
blake2b_256 (BuiltinByteString ByteString
b) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString
Hash.blake2b ByteString
b

{-# NOINLINE verifySignature #-}
verifySignature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> BuiltinBool
verifySignature :: BuiltinByteString
-> BuiltinByteString -> BuiltinByteString -> BuiltinBool
verifySignature (BuiltinByteString ByteString
pubKey) (BuiltinByteString ByteString
message) (BuiltinByteString ByteString
signature) =
  Bool -> BuiltinBool
coerce (Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False (ByteString -> ByteString -> ByteString -> Maybe Bool
forall (f :: * -> *).
Alternative f =>
ByteString -> ByteString -> ByteString -> f Bool
Crypto.verifySignature ByteString
pubKey ByteString
message ByteString
signature))

{-# NOINLINE equalsByteString #-}
equalsByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
equalsByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
equalsByteString (BuiltinByteString ByteString
b1) (BuiltinByteString ByteString
b2) = Bool -> BuiltinBool
coerce (Bool -> BuiltinBool) -> Bool -> BuiltinBool
forall a b. (a -> b) -> a -> b
$ (ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
(==) @ByteString) ByteString
b1 ByteString
b2

{-# NOINLINE lessThanByteString #-}
lessThanByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
lessThanByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
lessThanByteString (BuiltinByteString ByteString
b1) (BuiltinByteString ByteString
b2) = Bool -> BuiltinBool
coerce (Bool -> BuiltinBool) -> Bool -> BuiltinBool
forall a b. (a -> b) -> a -> b
$ (ByteString -> ByteString -> Bool
forall a. Ord a => a -> a -> Bool
(<) @ByteString) ByteString
b1 ByteString
b2

{-# NOINLINE lessThanEqualsByteString #-}
lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinBool
lessThanEqualsByteString (BuiltinByteString ByteString
b1) (BuiltinByteString ByteString
b2) = Bool -> BuiltinBool
coerce (Bool -> BuiltinBool) -> Bool -> BuiltinBool
forall a b. (a -> b) -> a -> b
$ (ByteString -> ByteString -> Bool
forall a. Ord a => a -> a -> Bool
(<=) @ByteString) ByteString
b1 ByteString
b2

{-# NOINLINE decodeUtf8 #-}
decodeUtf8 :: BuiltinByteString -> BuiltinString
decodeUtf8 :: BuiltinByteString -> BuiltinString
decodeUtf8 (BuiltinByteString ByteString
b) = Text -> BuiltinString
BuiltinString (Text -> BuiltinString) -> Text -> BuiltinString
forall a b. (a -> b) -> a -> b
$ ByteString -> Text
Text.decodeUtf8 ByteString
b

{-
STRING
-}

newtype BuiltinString = BuiltinString Text
    deriving stock Typeable BuiltinString
DataType
Constr
Typeable BuiltinString
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinString -> c BuiltinString)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BuiltinString)
-> (BuiltinString -> Constr)
-> (BuiltinString -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BuiltinString))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BuiltinString))
-> ((forall b. Data b => b -> b) -> BuiltinString -> BuiltinString)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinString -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinString -> r)
-> (forall u. (forall d. Data d => d -> u) -> BuiltinString -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinString -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString)
-> Data BuiltinString
BuiltinString -> DataType
BuiltinString -> Constr
(forall b. Data b => b -> b) -> BuiltinString -> BuiltinString
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinString -> c BuiltinString
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinString
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BuiltinString -> u
forall u. (forall d. Data d => d -> u) -> BuiltinString -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinString
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinString -> c BuiltinString
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinString)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinString)
$cBuiltinString :: Constr
$tBuiltinString :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
gmapMp :: (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
gmapM :: (forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinString -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BuiltinString -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinString -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BuiltinString -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinString -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinString -> BuiltinString
$cgmapT :: (forall b. Data b => b -> b) -> BuiltinString -> BuiltinString
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinString)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinString)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BuiltinString)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinString)
dataTypeOf :: BuiltinString -> DataType
$cdataTypeOf :: BuiltinString -> DataType
toConstr :: BuiltinString -> Constr
$ctoConstr :: BuiltinString -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinString
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinString
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinString -> c BuiltinString
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinString -> c BuiltinString
$cp1Data :: Typeable BuiltinString
Data
    deriving newtype (Int -> BuiltinString -> ShowS
[BuiltinString] -> ShowS
BuiltinString -> String
(Int -> BuiltinString -> ShowS)
-> (BuiltinString -> String)
-> ([BuiltinString] -> ShowS)
-> Show BuiltinString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuiltinString] -> ShowS
$cshowList :: [BuiltinString] -> ShowS
show :: BuiltinString -> String
$cshow :: BuiltinString -> String
showsPrec :: Int -> BuiltinString -> ShowS
$cshowsPrec :: Int -> BuiltinString -> ShowS
Haskell.Show, BuiltinString -> BuiltinString -> Bool
(BuiltinString -> BuiltinString -> Bool)
-> (BuiltinString -> BuiltinString -> Bool) -> Eq BuiltinString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuiltinString -> BuiltinString -> Bool
$c/= :: BuiltinString -> BuiltinString -> Bool
== :: BuiltinString -> BuiltinString -> Bool
$c== :: BuiltinString -> BuiltinString -> Bool
Haskell.Eq, Eq BuiltinString
Eq BuiltinString
-> (BuiltinString -> BuiltinString -> Ordering)
-> (BuiltinString -> BuiltinString -> Bool)
-> (BuiltinString -> BuiltinString -> Bool)
-> (BuiltinString -> BuiltinString -> Bool)
-> (BuiltinString -> BuiltinString -> Bool)
-> (BuiltinString -> BuiltinString -> BuiltinString)
-> (BuiltinString -> BuiltinString -> BuiltinString)
-> Ord BuiltinString
BuiltinString -> BuiltinString -> Bool
BuiltinString -> BuiltinString -> Ordering
BuiltinString -> BuiltinString -> BuiltinString
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
min :: BuiltinString -> BuiltinString -> BuiltinString
$cmin :: BuiltinString -> BuiltinString -> BuiltinString
max :: BuiltinString -> BuiltinString -> BuiltinString
$cmax :: BuiltinString -> BuiltinString -> BuiltinString
>= :: BuiltinString -> BuiltinString -> Bool
$c>= :: BuiltinString -> BuiltinString -> Bool
> :: BuiltinString -> BuiltinString -> Bool
$c> :: BuiltinString -> BuiltinString -> Bool
<= :: BuiltinString -> BuiltinString -> Bool
$c<= :: BuiltinString -> BuiltinString -> Bool
< :: BuiltinString -> BuiltinString -> Bool
$c< :: BuiltinString -> BuiltinString -> Bool
compare :: BuiltinString -> BuiltinString -> Ordering
$ccompare :: BuiltinString -> BuiltinString -> Ordering
$cp1Ord :: Eq BuiltinString
Haskell.Ord)

{-# NOINLINE appendString #-}
appendString :: BuiltinString -> BuiltinString -> BuiltinString
appendString :: BuiltinString -> BuiltinString -> BuiltinString
appendString (BuiltinString Text
s1) (BuiltinString Text
s2) = Text -> BuiltinString
BuiltinString (Text
s1 Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s2)

{-# NOINLINE emptyString #-}
emptyString :: BuiltinString
emptyString :: BuiltinString
emptyString = Text -> BuiltinString
BuiltinString Text
Text.empty

{-# NOINLINE equalsString #-}
equalsString :: BuiltinString -> BuiltinString -> BuiltinBool
equalsString :: BuiltinString -> BuiltinString -> BuiltinBool
equalsString (BuiltinString Text
s1) (BuiltinString Text
s2) = Bool -> BuiltinBool
coerce (Bool -> BuiltinBool) -> Bool -> BuiltinBool
forall a b. (a -> b) -> a -> b
$ (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
(==) @Text) Text
s1 Text
s2

{-# NOINLINE trace #-}
trace :: BuiltinString -> a -> a
trace :: BuiltinString -> a -> a
trace BuiltinString
_ a
x = a
x

{-# NOINLINE encodeUtf8 #-}
encodeUtf8 :: BuiltinString -> BuiltinByteString
encodeUtf8 :: BuiltinString -> BuiltinByteString
encodeUtf8 (BuiltinString Text
s) = ByteString -> BuiltinByteString
BuiltinByteString (ByteString -> BuiltinByteString)
-> ByteString -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
Text.encodeUtf8 Text
s

{-
PAIR
-}

newtype BuiltinPair a b = BuiltinPair (a, b)
    deriving stock Typeable (BuiltinPair a b)
DataType
Constr
Typeable (BuiltinPair a b)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b))
-> (BuiltinPair a b -> Constr)
-> (BuiltinPair a b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (BuiltinPair a b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (BuiltinPair a b)))
-> ((forall b. Data b => b -> b)
    -> BuiltinPair a b -> BuiltinPair a b)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> BuiltinPair a b -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinPair a b -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BuiltinPair a b -> m (BuiltinPair a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinPair a b -> m (BuiltinPair a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinPair a b -> m (BuiltinPair a b))
-> Data (BuiltinPair a b)
BuiltinPair a b -> DataType
BuiltinPair a b -> Constr
(forall b. Data b => b -> b) -> BuiltinPair a b -> BuiltinPair a b
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinPair a b))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> BuiltinPair a b -> u
forall u. (forall d. Data d => d -> u) -> BuiltinPair a b -> [u]
forall a b. (Data a, Data b) => Typeable (BuiltinPair a b)
forall a b. (Data a, Data b) => BuiltinPair a b -> DataType
forall a b. (Data a, Data b) => BuiltinPair a b -> Constr
forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> BuiltinPair a b -> BuiltinPair a b
forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> BuiltinPair a b -> u
forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> BuiltinPair a b -> [u]
forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b)
forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinPair a b))
forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinPair a b))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinPair a b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinPair a b))
$cBuiltinPair :: Constr
$tBuiltinPair :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
$cgmapMo :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
gmapMp :: (forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
$cgmapMp :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
gmapM :: (forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
$cgmapM :: forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d)
-> BuiltinPair a b -> m (BuiltinPair a b)
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinPair a b -> u
$cgmapQi :: forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> BuiltinPair a b -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinPair a b -> [u]
$cgmapQ :: forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> BuiltinPair a b -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
$cgmapQr :: forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
$cgmapQl :: forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinPair a b -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinPair a b -> BuiltinPair a b
$cgmapT :: forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> BuiltinPair a b -> BuiltinPair a b
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinPair a b))
$cdataCast2 :: forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinPair a b))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (BuiltinPair a b))
$cdataCast1 :: forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinPair a b))
dataTypeOf :: BuiltinPair a b -> DataType
$cdataTypeOf :: forall a b. (Data a, Data b) => BuiltinPair a b -> DataType
toConstr :: BuiltinPair a b -> Constr
$ctoConstr :: forall a b. (Data a, Data b) => BuiltinPair a b -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b)
$cgunfold :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinPair a b)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b)
$cgfoldl :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinPair a b -> c (BuiltinPair a b)
$cp1Data :: forall a b. (Data a, Data b) => Typeable (BuiltinPair a b)
Data
    deriving newtype (Int -> BuiltinPair a b -> ShowS
[BuiltinPair a b] -> ShowS
BuiltinPair a b -> String
(Int -> BuiltinPair a b -> ShowS)
-> (BuiltinPair a b -> String)
-> ([BuiltinPair a b] -> ShowS)
-> Show (BuiltinPair a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> BuiltinPair a b -> ShowS
forall a b. (Show a, Show b) => [BuiltinPair a b] -> ShowS
forall a b. (Show a, Show b) => BuiltinPair a b -> String
showList :: [BuiltinPair a b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [BuiltinPair a b] -> ShowS
show :: BuiltinPair a b -> String
$cshow :: forall a b. (Show a, Show b) => BuiltinPair a b -> String
showsPrec :: Int -> BuiltinPair a b -> ShowS
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> BuiltinPair a b -> ShowS
Haskell.Show, BuiltinPair a b -> BuiltinPair a b -> Bool
(BuiltinPair a b -> BuiltinPair a b -> Bool)
-> (BuiltinPair a b -> BuiltinPair a b -> Bool)
-> Eq (BuiltinPair a b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b.
(Eq a, Eq b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
/= :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c/= :: forall a b.
(Eq a, Eq b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
== :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c== :: forall a b.
(Eq a, Eq b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
Haskell.Eq, Eq (BuiltinPair a b)
Eq (BuiltinPair a b)
-> (BuiltinPair a b -> BuiltinPair a b -> Ordering)
-> (BuiltinPair a b -> BuiltinPair a b -> Bool)
-> (BuiltinPair a b -> BuiltinPair a b -> Bool)
-> (BuiltinPair a b -> BuiltinPair a b -> Bool)
-> (BuiltinPair a b -> BuiltinPair a b -> Bool)
-> (BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b)
-> (BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b)
-> Ord (BuiltinPair a b)
BuiltinPair a b -> BuiltinPair a b -> Bool
BuiltinPair a b -> BuiltinPair a b -> Ordering
BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
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
forall a b. (Ord a, Ord b) => Eq (BuiltinPair a b)
forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Ordering
forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
min :: BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
$cmin :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
max :: BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
$cmax :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> BuiltinPair a b
>= :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c>= :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
> :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c> :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
<= :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c<= :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
< :: BuiltinPair a b -> BuiltinPair a b -> Bool
$c< :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Bool
compare :: BuiltinPair a b -> BuiltinPair a b -> Ordering
$ccompare :: forall a b.
(Ord a, Ord b) =>
BuiltinPair a b -> BuiltinPair a b -> Ordering
$cp1Ord :: forall a b. (Ord a, Ord b) => Eq (BuiltinPair a b)
Haskell.Ord)

{-# NOINLINE fst #-}
fst :: BuiltinPair a b -> a
fst :: BuiltinPair a b -> a
fst (BuiltinPair (a
a, b
_)) = a
a

{-# NOINLINE snd #-}
snd :: BuiltinPair a b -> b
snd :: BuiltinPair a b -> b
snd (BuiltinPair (a
_, b
b)) = b
b

{-# NOINLINE mkPairData #-}
mkPairData :: BuiltinData -> BuiltinData -> BuiltinPair BuiltinData BuiltinData
mkPairData :: BuiltinData -> BuiltinData -> BuiltinPair BuiltinData BuiltinData
mkPairData BuiltinData
d1 BuiltinData
d2 = (BuiltinData, BuiltinData) -> BuiltinPair BuiltinData BuiltinData
forall a b. (a, b) -> BuiltinPair a b
BuiltinPair (BuiltinData
d1, BuiltinData
d2)

{-
LIST
-}

newtype BuiltinList a = BuiltinList [a]
    deriving stock Typeable (BuiltinList a)
DataType
Constr
Typeable (BuiltinList a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (BuiltinList a))
-> (BuiltinList a -> Constr)
-> (BuiltinList a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (BuiltinList a)))
-> ((forall b. Data b => b -> b) -> BuiltinList a -> BuiltinList a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r)
-> (forall u. (forall d. Data d => d -> u) -> BuiltinList a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinList a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BuiltinList a -> m (BuiltinList a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinList a -> m (BuiltinList a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BuiltinList a -> m (BuiltinList a))
-> Data (BuiltinList a)
BuiltinList a -> DataType
BuiltinList a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a))
(forall b. Data b => b -> b) -> BuiltinList a -> BuiltinList a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinList a)
forall a. Data a => Typeable (BuiltinList a)
forall a. Data a => BuiltinList a -> DataType
forall a. Data a => BuiltinList a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> BuiltinList a -> BuiltinList a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> BuiltinList a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> BuiltinList a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinList a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinList a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BuiltinList a -> u
forall u. (forall d. Data d => d -> u) -> BuiltinList a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinList a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinList a))
$cBuiltinList :: Constr
$tBuiltinList :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
gmapMp :: (forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
gmapM :: (forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> BuiltinList a -> m (BuiltinList a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinList a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> BuiltinList a -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinList a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> BuiltinList a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinList a -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinList a -> BuiltinList a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> BuiltinList a -> BuiltinList a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinList a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (BuiltinList a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (BuiltinList a))
dataTypeOf :: BuiltinList a -> DataType
$cdataTypeOf :: forall a. Data a => BuiltinList a -> DataType
toConstr :: BuiltinList a -> Constr
$ctoConstr :: forall a. Data a => BuiltinList a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinList a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (BuiltinList a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinList a -> c (BuiltinList a)
$cp1Data :: forall a. Data a => Typeable (BuiltinList a)
Data
    deriving newtype (Int -> BuiltinList a -> ShowS
[BuiltinList a] -> ShowS
BuiltinList a -> String
(Int -> BuiltinList a -> ShowS)
-> (BuiltinList a -> String)
-> ([BuiltinList a] -> ShowS)
-> Show (BuiltinList a)
forall a. Show a => Int -> BuiltinList a -> ShowS
forall a. Show a => [BuiltinList a] -> ShowS
forall a. Show a => BuiltinList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuiltinList a] -> ShowS
$cshowList :: forall a. Show a => [BuiltinList a] -> ShowS
show :: BuiltinList a -> String
$cshow :: forall a. Show a => BuiltinList a -> String
showsPrec :: Int -> BuiltinList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> BuiltinList a -> ShowS
Haskell.Show, BuiltinList a -> BuiltinList a -> Bool
(BuiltinList a -> BuiltinList a -> Bool)
-> (BuiltinList a -> BuiltinList a -> Bool) -> Eq (BuiltinList a)
forall a. Eq a => BuiltinList a -> BuiltinList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuiltinList a -> BuiltinList a -> Bool
$c/= :: forall a. Eq a => BuiltinList a -> BuiltinList a -> Bool
== :: BuiltinList a -> BuiltinList a -> Bool
$c== :: forall a. Eq a => BuiltinList a -> BuiltinList a -> Bool
Haskell.Eq, Eq (BuiltinList a)
Eq (BuiltinList a)
-> (BuiltinList a -> BuiltinList a -> Ordering)
-> (BuiltinList a -> BuiltinList a -> Bool)
-> (BuiltinList a -> BuiltinList a -> Bool)
-> (BuiltinList a -> BuiltinList a -> Bool)
-> (BuiltinList a -> BuiltinList a -> Bool)
-> (BuiltinList a -> BuiltinList a -> BuiltinList a)
-> (BuiltinList a -> BuiltinList a -> BuiltinList a)
-> Ord (BuiltinList a)
BuiltinList a -> BuiltinList a -> Bool
BuiltinList a -> BuiltinList a -> Ordering
BuiltinList a -> BuiltinList a -> BuiltinList a
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
forall a. Ord a => Eq (BuiltinList a)
forall a. Ord a => BuiltinList a -> BuiltinList a -> Bool
forall a. Ord a => BuiltinList a -> BuiltinList a -> Ordering
forall a. Ord a => BuiltinList a -> BuiltinList a -> BuiltinList a
min :: BuiltinList a -> BuiltinList a -> BuiltinList a
$cmin :: forall a. Ord a => BuiltinList a -> BuiltinList a -> BuiltinList a
max :: BuiltinList a -> BuiltinList a -> BuiltinList a
$cmax :: forall a. Ord a => BuiltinList a -> BuiltinList a -> BuiltinList a
>= :: BuiltinList a -> BuiltinList a -> Bool
$c>= :: forall a. Ord a => BuiltinList a -> BuiltinList a -> Bool
> :: BuiltinList a -> BuiltinList a -> Bool
$c> :: forall a. Ord a => BuiltinList a -> BuiltinList a -> Bool
<= :: BuiltinList a -> BuiltinList a -> Bool
$c<= :: forall a. Ord a => BuiltinList a -> BuiltinList a -> Bool
< :: BuiltinList a -> BuiltinList a -> Bool
$c< :: forall a. Ord a => BuiltinList a -> BuiltinList a -> Bool
compare :: BuiltinList a -> BuiltinList a -> Ordering
$ccompare :: forall a. Ord a => BuiltinList a -> BuiltinList a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (BuiltinList a)
Haskell.Ord)

{-# NOINLINE null #-}
null :: BuiltinList a -> BuiltinBool
null :: BuiltinList a -> BuiltinBool
null (BuiltinList (a
_:[a]
_)) = Bool -> BuiltinBool
coerce Bool
False
null (BuiltinList [])    = Bool -> BuiltinBool
coerce Bool
True

{-# NOINLINE head #-}
head :: BuiltinList a -> a
head :: BuiltinList a -> a
head (BuiltinList (a
x:[a]
_)) = a
x
head (BuiltinList [])    = String -> a
forall a. HasCallStack => String -> a
Haskell.error String
"empty list"

{-# NOINLINE tail #-}
tail :: BuiltinList a -> BuiltinList a
tail :: BuiltinList a -> BuiltinList a
tail (BuiltinList (a
_:[a]
xs)) = [a] -> BuiltinList a
coerce [a]
xs
tail (BuiltinList [])     = String -> BuiltinList a
forall a. HasCallStack => String -> a
Haskell.error String
"empty list"

{-# NOINLINE chooseList #-}
chooseList :: BuiltinList a -> b -> b-> b
chooseList :: BuiltinList a -> b -> b -> b
chooseList (BuiltinList [])    b
b1 b
_ = b
b1
chooseList (BuiltinList (a
_:[a]
_)) b
_ b
b2 = b
b2

{-# NOINLINE mkNilData #-}
mkNilData :: BuiltinUnit -> BuiltinList BuiltinData
mkNilData :: BuiltinUnit -> BuiltinList BuiltinData
mkNilData BuiltinUnit
_ = [BuiltinData] -> BuiltinList BuiltinData
forall a. [a] -> BuiltinList a
BuiltinList []

{-# NOINLINE mkNilPairData #-}
mkNilPairData :: BuiltinUnit -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
mkNilPairData :: BuiltinUnit -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
mkNilPairData BuiltinUnit
_ = [BuiltinPair BuiltinData BuiltinData]
-> BuiltinList (BuiltinPair BuiltinData BuiltinData)
forall a. [a] -> BuiltinList a
BuiltinList []

{-# NOINLINE mkCons #-}
mkCons :: a -> BuiltinList a -> BuiltinList a
mkCons :: a -> BuiltinList a -> BuiltinList a
mkCons a
a (BuiltinList [a]
as) = [a] -> BuiltinList a
forall a. [a] -> BuiltinList a
BuiltinList (a
aa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
as)

{-
DATA
-}

{-|
A type corresponding to the Plutus Core builtin equivalent of 'PLC.Data'.

The point of this type is to be an opaque equivalent of 'PLC.Data', so as to
ensure that it is only used in ways that the compiler can handle.

As such, you should use this type in your on-chain code, and in any data structures
that you want to be representable on-chain.

For off-chain usage, there are conversion functions 'builtinDataToData' and
'dataToBuiltinData', but note that these will not work on-chain.
-}
newtype BuiltinData = BuiltinData PLC.Data
    deriving stock Typeable BuiltinData
DataType
Constr
Typeable BuiltinData
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BuiltinData -> c BuiltinData)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BuiltinData)
-> (BuiltinData -> Constr)
-> (BuiltinData -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BuiltinData))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BuiltinData))
-> ((forall b. Data b => b -> b) -> BuiltinData -> BuiltinData)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinData -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BuiltinData -> r)
-> (forall u. (forall d. Data d => d -> u) -> BuiltinData -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BuiltinData -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData)
-> Data BuiltinData
BuiltinData -> DataType
BuiltinData -> Constr
(forall b. Data b => b -> b) -> BuiltinData -> BuiltinData
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinData -> c BuiltinData
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinData
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BuiltinData -> u
forall u. (forall d. Data d => d -> u) -> BuiltinData -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinData
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinData -> c BuiltinData
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinData)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinData)
$cBuiltinData :: Constr
$tBuiltinData :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
gmapMp :: (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
gmapM :: (forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData
gmapQi :: Int -> (forall d. Data d => d -> u) -> BuiltinData -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BuiltinData -> u
gmapQ :: (forall d. Data d => d -> u) -> BuiltinData -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BuiltinData -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BuiltinData -> r
gmapT :: (forall b. Data b => b -> b) -> BuiltinData -> BuiltinData
$cgmapT :: (forall b. Data b => b -> b) -> BuiltinData -> BuiltinData
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinData)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c BuiltinData)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c BuiltinData)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BuiltinData)
dataTypeOf :: BuiltinData -> DataType
$cdataTypeOf :: BuiltinData -> DataType
toConstr :: BuiltinData -> Constr
$ctoConstr :: BuiltinData -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinData
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BuiltinData
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinData -> c BuiltinData
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BuiltinData -> c BuiltinData
$cp1Data :: Typeable BuiltinData
Data
    deriving newtype (Int -> BuiltinData -> ShowS
[BuiltinData] -> ShowS
BuiltinData -> String
(Int -> BuiltinData -> ShowS)
-> (BuiltinData -> String)
-> ([BuiltinData] -> ShowS)
-> Show BuiltinData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuiltinData] -> ShowS
$cshowList :: [BuiltinData] -> ShowS
show :: BuiltinData -> String
$cshow :: BuiltinData -> String
showsPrec :: Int -> BuiltinData -> ShowS
$cshowsPrec :: Int -> BuiltinData -> ShowS
Haskell.Show, BuiltinData -> BuiltinData -> Bool
(BuiltinData -> BuiltinData -> Bool)
-> (BuiltinData -> BuiltinData -> Bool) -> Eq BuiltinData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuiltinData -> BuiltinData -> Bool
$c/= :: BuiltinData -> BuiltinData -> Bool
== :: BuiltinData -> BuiltinData -> Bool
$c== :: BuiltinData -> BuiltinData -> Bool
Haskell.Eq, Eq BuiltinData
Eq BuiltinData
-> (BuiltinData -> BuiltinData -> Ordering)
-> (BuiltinData -> BuiltinData -> Bool)
-> (BuiltinData -> BuiltinData -> Bool)
-> (BuiltinData -> BuiltinData -> Bool)
-> (BuiltinData -> BuiltinData -> Bool)
-> (BuiltinData -> BuiltinData -> BuiltinData)
-> (BuiltinData -> BuiltinData -> BuiltinData)
-> Ord BuiltinData
BuiltinData -> BuiltinData -> Bool
BuiltinData -> BuiltinData -> Ordering
BuiltinData -> BuiltinData -> BuiltinData
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
min :: BuiltinData -> BuiltinData -> BuiltinData
$cmin :: BuiltinData -> BuiltinData -> BuiltinData
max :: BuiltinData -> BuiltinData -> BuiltinData
$cmax :: BuiltinData -> BuiltinData -> BuiltinData
>= :: BuiltinData -> BuiltinData -> Bool
$c>= :: BuiltinData -> BuiltinData -> Bool
> :: BuiltinData -> BuiltinData -> Bool
$c> :: BuiltinData -> BuiltinData -> Bool
<= :: BuiltinData -> BuiltinData -> Bool
$c<= :: BuiltinData -> BuiltinData -> Bool
< :: BuiltinData -> BuiltinData -> Bool
$c< :: BuiltinData -> BuiltinData -> Bool
compare :: BuiltinData -> BuiltinData -> Ordering
$ccompare :: BuiltinData -> BuiltinData -> Ordering
$cp1Ord :: Eq BuiltinData
Haskell.Ord)

-- NOT a builtin, only safe off-chain, hence the NOINLINE
{-# NOINLINE builtinDataToData #-}
-- | Convert a 'BuiltinData' into a 'PLC.Data'. Only works off-chain.
builtinDataToData :: BuiltinData -> PLC.Data
builtinDataToData :: BuiltinData -> Data
builtinDataToData (BuiltinData Data
d) = Data
d

-- NOT a builtin, only safe off-chain, hence the NOINLINE
{-# NOINLINE dataToBuiltinData #-}
-- | Convert a 'PLC.Data' into a 'BuiltinData'. Only works off-chain.
dataToBuiltinData :: PLC.Data -> BuiltinData
dataToBuiltinData :: Data -> BuiltinData
dataToBuiltinData = Data -> BuiltinData
BuiltinData

{-# NOINLINE chooseData #-}
chooseData :: forall a . BuiltinData -> a -> a -> a -> a -> a -> a
chooseData :: BuiltinData -> a -> a -> a -> a -> a -> a
chooseData (BuiltinData Data
d) a
constrCase a
mapCase a
listCase a
iCase a
bCase = case Data
d of
    PLC.Constr{} -> a
constrCase
    PLC.Map{}    -> a
mapCase
    PLC.List{}   -> a
listCase
    PLC.I{}      -> a
iCase
    PLC.B{}      -> a
bCase

{-# NOINLINE mkConstr #-}
mkConstr :: BuiltinInteger -> BuiltinList BuiltinData -> BuiltinData
mkConstr :: BuiltinInteger -> BuiltinList BuiltinData -> BuiltinData
mkConstr BuiltinInteger
i BuiltinList BuiltinData
args = Data -> BuiltinData
BuiltinData (BuiltinInteger -> [Data] -> Data
PLC.Constr BuiltinInteger
i (BuiltinList BuiltinData -> [Data]
coerce BuiltinList BuiltinData
args))

{-# NOINLINE mkMap #-}
mkMap :: BuiltinList (BuiltinPair BuiltinData BuiltinData) -> BuiltinData
mkMap :: BuiltinList (BuiltinPair BuiltinData BuiltinData) -> BuiltinData
mkMap BuiltinList (BuiltinPair BuiltinData BuiltinData)
es = Data -> BuiltinData
BuiltinData ([(Data, Data)] -> Data
PLC.Map (BuiltinList (BuiltinPair BuiltinData BuiltinData) -> [(Data, Data)]
coerce BuiltinList (BuiltinPair BuiltinData BuiltinData)
es))

{-# NOINLINE mkList #-}
mkList :: BuiltinList BuiltinData -> BuiltinData
mkList :: BuiltinList BuiltinData -> BuiltinData
mkList BuiltinList BuiltinData
l = Data -> BuiltinData
BuiltinData ([Data] -> Data
PLC.List (BuiltinList BuiltinData -> [Data]
coerce BuiltinList BuiltinData
l))

{-# NOINLINE mkI #-}
mkI :: BuiltinInteger -> BuiltinData
mkI :: BuiltinInteger -> BuiltinData
mkI BuiltinInteger
i = Data -> BuiltinData
BuiltinData (BuiltinInteger -> Data
PLC.I BuiltinInteger
i)

{-# NOINLINE mkB #-}
mkB :: BuiltinByteString -> BuiltinData
mkB :: BuiltinByteString -> BuiltinData
mkB (BuiltinByteString ByteString
b) = Data -> BuiltinData
BuiltinData (ByteString -> Data
PLC.B ByteString
b)

{-# NOINLINE unsafeDataAsConstr #-}
unsafeDataAsConstr :: BuiltinData -> BuiltinPair BuiltinInteger (BuiltinList BuiltinData)
unsafeDataAsConstr :: BuiltinData -> BuiltinPair BuiltinInteger (BuiltinList BuiltinData)
unsafeDataAsConstr (BuiltinData (PLC.Constr BuiltinInteger
i [Data]
args)) = (BuiltinInteger, BuiltinList BuiltinData)
-> BuiltinPair BuiltinInteger (BuiltinList BuiltinData)
forall a b. (a, b) -> BuiltinPair a b
BuiltinPair (BuiltinInteger
i, [Data] -> BuiltinList BuiltinData
coerce [Data]
args)
unsafeDataAsConstr BuiltinData
_                                 = String -> BuiltinPair BuiltinInteger (BuiltinList BuiltinData)
forall a. HasCallStack => String -> a
Haskell.error String
"not a Constr"

{-# NOINLINE unsafeDataAsMap #-}
unsafeDataAsMap :: BuiltinData -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
unsafeDataAsMap :: BuiltinData -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
unsafeDataAsMap (BuiltinData (PLC.Map [(Data, Data)]
m)) = [(Data, Data)] -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
coerce [(Data, Data)]
m
unsafeDataAsMap BuiltinData
_                         = String -> BuiltinList (BuiltinPair BuiltinData BuiltinData)
forall a. HasCallStack => String -> a
Haskell.error String
"not a Map"

{-# NOINLINE unsafeDataAsList #-}
unsafeDataAsList :: BuiltinData -> BuiltinList BuiltinData
unsafeDataAsList :: BuiltinData -> BuiltinList BuiltinData
unsafeDataAsList (BuiltinData (PLC.List [Data]
l)) = [Data] -> BuiltinList BuiltinData
coerce [Data]
l
unsafeDataAsList BuiltinData
_                          = String -> BuiltinList BuiltinData
forall a. HasCallStack => String -> a
Haskell.error String
"not a List"

{-# NOINLINE unsafeDataAsI #-}
unsafeDataAsI :: BuiltinData -> BuiltinInteger
unsafeDataAsI :: BuiltinData -> BuiltinInteger
unsafeDataAsI (BuiltinData (PLC.I BuiltinInteger
i)) = BuiltinInteger
i
unsafeDataAsI BuiltinData
_                       = String -> BuiltinInteger
forall a. HasCallStack => String -> a
Haskell.error String
"not an I"

{-# NOINLINE unsafeDataAsB #-}
unsafeDataAsB :: BuiltinData -> BuiltinByteString
unsafeDataAsB :: BuiltinData -> BuiltinByteString
unsafeDataAsB (BuiltinData (PLC.B ByteString
b)) = ByteString -> BuiltinByteString
BuiltinByteString ByteString
b
unsafeDataAsB BuiltinData
_                       = String -> BuiltinByteString
forall a. HasCallStack => String -> a
Haskell.error String
"not a B"

{-# NOINLINE equalsData #-}
equalsData :: BuiltinData -> BuiltinData -> BuiltinBool
equalsData :: BuiltinData -> BuiltinData -> BuiltinBool
equalsData (BuiltinData Data
b1) (BuiltinData Data
b2) = Bool -> BuiltinBool
coerce (Bool -> BuiltinBool) -> Bool -> BuiltinBool
forall a b. (a -> b) -> a -> b
$ Data
b1 Data -> Data -> Bool
forall a. Eq a => a -> a -> Bool
Haskell.== Data
b2