plutus-tx-0.1.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellNone
LanguageHaskell2010

PlutusTx.Prelude

Synopsis

Documentation

The PlutusTx Prelude is a replacement for the Haskell Prelude that works better with Plutus Tx. You should use it if you're writing code that will be compiled with the Plutus Tx compiler. {--} import PlutusTx.Prelude

Monad

(>>=) :: Monad m => m a -> (a -> m b) -> m b #

(=<<) :: Monad m => (a -> m b) -> m a -> m b #

(>>) :: Monad m => m a -> m b -> m b #

return :: Monad m => a -> m a #

Standard functions, Tuples

Tracing functions

String

data BuiltinString Source #

Instances

Instances details
Eq BuiltinString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Ord BuiltinString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

IsString BuiltinString Source # 
Instance details

Defined in PlutusTx.Builtins.Class

Eq BuiltinString Source # 
Instance details

Defined in PlutusTx.Eq

Semigroup BuiltinString Source # 
Instance details

Defined in PlutusTx.Semigroup

Monoid BuiltinString Source # 
Instance details

Defined in PlutusTx.Monoid

Includes uni Text => Lift uni BuiltinString Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

lift :: BuiltinString -> RTCompile uni fun (Term TyName Name uni fun ()) Source #

ToBuiltin Text BuiltinString Source # 
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinString Text Source # 
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni Text => Typeable uni BuiltinString Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

typeRep :: Proxy BuiltinString -> RTCompile uni fun (Type TyName uni ()) Source #

emptyString :: BuiltinString Source #

An empty String.

equalsString :: BuiltinString -> BuiltinString -> Bool Source #

Check if two strings are equal

encodeUtf8 :: BuiltinString -> BuiltinByteString Source #

Convert a String into a ByteString.

Error

error :: () -> a Source #

Aborts evaluation with an error.

check :: Bool -> () Source #

Checks a Bool and aborts if it is false.

Booleans

Integer numbers

data Integer #

Instances

Instances details
Enum Integer 
Instance details

Defined in GHC.Enum

Eq Integer 
Instance details

Defined in GHC.Integer.Type

Methods

(==) :: Integer -> Integer -> Bool #

(/=) :: Integer -> Integer -> Bool #

Integral Integer 
Instance details

Defined in GHC.Real

Num Integer 
Instance details

Defined in GHC.Num

Ord Integer 
Instance details

Defined in GHC.Integer.Type

Read Integer 
Instance details

Defined in GHC.Read

Methods

readsPrec :: Int -> ReadS Integer #

readList :: ReadS [Integer] #

readPrec :: ReadPrec Integer #

readListPrec :: ReadPrec [Integer] #

Real Integer 
Instance details

Defined in GHC.Real

Show Integer 
Instance details

Defined in GHC.Show

Ix Integer 
Instance details

Defined in GHC.Ix

Hashable Integer 
Instance details

Defined in Data.Hashable.Class

ToJSON Integer 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Integer 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON Integer

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Integer 
Instance details

Defined in Data.Aeson.Types.FromJSON

Subtractive Integer 
Instance details

Defined in Basement.Numerical.Subtractive

Associated Types

type Difference Integer Source #

NFData Integer 
Instance details

Defined in Control.DeepSeq

Methods

rnf :: Integer -> () #

ExMemoryUsage Integer 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Pretty Integer
>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in Prettyprinter.Internal

Methods

pretty :: Integer -> Doc ann Source #

prettyList :: [Integer] -> Doc ann Source #

UniformRange Integer 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Integer, Integer) -> g -> m Integer Source #

Serialise Integer

Since: serialise-0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Pretty Integer 
Instance details

Defined in Text.PrettyPrint.Annotated.WL

Pretty Rational 
Instance details

Defined in Text.PrettyPrint.Annotated.WL

Eq Integer Source # 
Instance details

Defined in PlutusTx.Eq

Methods

(==) :: Integer -> Integer -> Bool Source #

Ord Integer Source # 
Instance details

Defined in PlutusTx.Ord

MultiplicativeMonoid Integer Source # 
Instance details

Defined in PlutusTx.Numeric

Methods

one :: Integer Source #

MultiplicativeSemigroup Integer Source # 
Instance details

Defined in PlutusTx.Numeric

Methods

(*) :: Integer -> Integer -> Integer Source #

AdditiveGroup Integer Source # 
Instance details

Defined in PlutusTx.Numeric

Methods

(-) :: Integer -> Integer -> Integer Source #

AdditiveMonoid Integer Source # 
Instance details

Defined in PlutusTx.Numeric

Methods

zero :: Integer Source #

AdditiveSemigroup Integer Source # 
Instance details

Defined in PlutusTx.Numeric

Methods

(+) :: Integer -> Integer -> Integer Source #

UnsafeFromData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData Integer Source # 
Instance details

Defined in PlutusTx.IsData.Class

Enum Integer Source # 
Instance details

Defined in PlutusTx.Enum

Lift Integer 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Integer -> Q Exp #

liftTyped :: Integer -> Q (TExp Integer) #

PrettyDefaultBy config Integer => PrettyBy config Integer
>>> prettyBy () (2^(123 :: Int) :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in Text.PrettyBy.Internal

Methods

prettyBy :: config -> Integer -> Doc ann Source #

prettyListBy :: config -> [Integer] -> Doc ann Source #

DefaultPrettyBy config Integer 
Instance details

Defined in Text.PrettyBy.Internal

Methods

defaultPrettyBy :: config -> Integer -> Doc ann Source #

defaultPrettyListBy :: config -> [Integer] -> Doc ann Source #

NonDefaultPrettyBy ConstConfig Integer 
Instance details

Defined in PlutusCore.Pretty.PrettyConst

Includes uni Integer => Lift uni Integer Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

lift :: Integer -> RTCompile uni fun (Term TyName Name uni fun ()) Source #

ToBuiltin Integer BuiltinInteger Source # 
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinInteger Integer Source # 
Instance details

Defined in PlutusTx.Builtins.Class

KnownNat n => Reifies (n :: Nat) Integer 
Instance details

Defined in Data.Reflection

Methods

reflect :: proxy n -> Integer Source #

Ord (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

MultiplicativeMonoid (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

MultiplicativeSemigroup (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

AdditiveGroup (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

AdditiveMonoid (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

AdditiveSemigroup (Ratio Integer) Source # 
Instance details

Defined in PlutusTx.Ratio

Contains DefaultUni Integer 
Instance details

Defined in PlutusCore.Default.Universe

Includes uni Integer => Typeable uni Integer Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

typeRep :: Proxy Integer -> RTCompile uni fun (Type TyName uni ()) Source #

type Difference Integer 
Instance details

Defined in Basement.Numerical.Subtractive

type ToBinds Integer 
Instance details

Defined in PlutusCore.Constant.Meaning

type ToBinds Integer = '[] :: [Some TyNameRep]

divide :: Integer -> Integer -> Integer Source #

Integer division, rounding downwards

>>> divide (-41) 5
-9

modulo :: Integer -> Integer -> Integer Source #

Integer remainder, always positive for a positive divisor

>>> modulo (-41) 5
4

quotient :: Integer -> Integer -> Integer Source #

Integer division, rouding towards zero

>>> quotient (-41) 5
-8

remainder :: Integer -> Integer -> Integer Source #

Integer remainder, same sign as dividend

>>> remainder (-41) 5
-1

Maybe

Either

Lists

map :: (a -> b) -> [a] -> [b] Source #

Plutus Tx version of map.

>>> map (\i -> i + 1) [1, 2, 3]
[2,3,4]

(++) :: [a] -> [a] -> [a] infixr 5 Source #

Plutus Tx version of (++).

>>> [0, 1, 2] ++ [1, 2, 3, 4]
[0,1,2,1,2,3,4]

filter :: (a -> Bool) -> [a] -> [a] Source #

Plutus Tx version of filter.

>>> filter (> 1) [1, 2, 3, 4]
[2,3,4]

listToMaybe :: [a] -> Maybe a Source #

Plutus Tx version of listToMaybe.

uniqueElement :: [a] -> Maybe a Source #

Return the element in the list, if there is precisely one.

findIndices :: (a -> Bool) -> [a] -> [Integer] Source #

Plutus Tx version of findIndices.

findIndex :: (a -> Bool) -> [a] -> Maybe Integer Source #

Plutus Tx version of findIndex.

(!!) :: [a] -> Integer -> a infixl 9 Source #

Plutus Tx version of (!!).

>>> [10, 11, 12] !! 2
12

reverse :: [a] -> [a] Source #

Plutus Tx version of reverse.

zip :: [a] -> [b] -> [(a, b)] Source #

Plutus Tx version of zip.

head :: [a] -> a Source #

Plutus Tx version of head.

tail :: [a] -> [a] Source #

Plutus Tx version of tail.

take :: Integer -> [a] -> [a] Source #

Plutus Tx version of take.

nub :: Eq a => [a] -> [a] Source #

Plutus Tx version of nub.

nubBy :: (a -> a -> Bool) -> [a] -> [a] Source #

Plutus Tx version of nubBy.

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source #

Plutus Tx version of zipWith.

dropWhile :: (a -> Bool) -> [a] -> [a] Source #

Plutus Tx version of dropWhile.

ByteStrings

data BuiltinByteString Source #

An opaque type representing Plutus Core ByteStrings.

Instances

Instances details
Eq BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Ord BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

IsString BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Class

Generic BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Associated Types

type Rep BuiltinByteString :: Type -> Type #

Semigroup BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Monoid BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Hashable BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

NFData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Methods

rnf :: BuiltinByteString -> () #

ByteArray BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Methods

allocRet :: Int -> (Ptr p -> IO a) -> IO (a, BuiltinByteString) Source #

ByteArrayAccess BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Pretty BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Serialise BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Eq

Ord BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Ord

Semigroup BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Semigroup

Monoid BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Monoid

UnsafeFromData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinByteString Source # 
Instance details

Defined in PlutusTx.IsData.Class

Includes uni ByteString => Lift uni BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

lift :: BuiltinByteString -> RTCompile uni fun (Term TyName Name uni fun ()) Source #

ToBuiltin ByteString BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinByteString ByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni ByteString => Typeable uni BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

typeRep :: Proxy BuiltinByteString -> RTCompile uni fun (Type TyName uni ()) Source #

type Rep BuiltinByteString Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

type Rep BuiltinByteString = D1 ('MetaData "BuiltinByteString" "PlutusTx.Builtins.Internal" "plutus-tx-0.1.0.0-JhxM3mRtqYc7GjOPzmjCNb" 'True) (C1 ('MetaCons "BuiltinByteString" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

consByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #

Adds a byte to the front of a ByteString.

takeByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #

Returns the n length prefix of a ByteString.

dropByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #

Returns the suffix of a ByteString after n elements.

sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString Source #

Returns the substring of a ByteString from index start of length n.

lengthOfByteString :: BuiltinByteString -> Integer Source #

Returns the length of a ByteString.

indexByteString :: BuiltinByteString -> Integer -> Integer Source #

Returns the byte of a ByteString at index.

emptyByteString :: BuiltinByteString Source #

An empty ByteString.

decodeUtf8 :: BuiltinByteString -> BuiltinString Source #

Converts a ByteString to a String.

Hashes and Signatures

sha2_256 :: BuiltinByteString -> BuiltinByteString Source #

The SHA2-256 hash of a ByteString

sha3_256 :: BuiltinByteString -> BuiltinByteString Source #

The SHA3-256 hash of a ByteString

verifySignature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool Source #

Verify that the signature is a signature of the message by the public key.

Rational numbers

(%) :: Integer -> Integer -> Ratio Integer infixl 7 Source #

Forms the ratio of two integral numbers.

fromInteger :: Integer -> Ratio Integer Source #

Convert an Interger to a Rational

round :: Ratio Integer -> Integer Source #

From GHC.Real | round x returns the nearest integer to x; the even integer if x is equidistant between two integers

divMod :: Integer -> Integer -> (Integer, Integer) Source #

Simultaneous div and mod.

quotRem :: Integer -> Integer -> (Integer, Integer) Source #

Simultaneous quot and rem.

Data

data BuiltinData Source #

A type corresponding to the Plutus Core builtin equivalent of Data.

The point of this type is to be an opaque equivalent of 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.

Instances

Instances details
Eq BuiltinData Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Ord BuiltinData Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinData Source # 
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinData Source # 
Instance details

Defined in PlutusTx.Eq

UnsafeFromData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinData Source # 
Instance details

Defined in PlutusTx.IsData.Class

Includes uni Data => Lift uni BuiltinData Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

lift :: BuiltinData -> RTCompile uni fun (Term TyName Name uni fun ()) Source #

ToBuiltin BuiltinData BuiltinData Source # 
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinData BuiltinData Source # 
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni Data => Typeable uni BuiltinData Source # 
Instance details

Defined in PlutusTx.Lift.Instances

Methods

typeRep :: Proxy BuiltinData -> RTCompile uni fun (Type TyName uni ()) Source #

ToBuiltin [(BuiltinData, BuiltinData)] (BuiltinList (BuiltinPair BuiltinData BuiltinData)) Source # 
Instance details

Defined in PlutusTx.Builtins.Class

ToBuiltin [BuiltinData] (BuiltinList BuiltinData) Source # 
Instance details

Defined in PlutusTx.Builtins.Class

ToBuiltin (BuiltinData, BuiltinData) (BuiltinPair BuiltinData BuiltinData) Source # 
Instance details

Defined in PlutusTx.Builtins.Class

fromBuiltin :: FromBuiltin arep a => arep -> a Source #

toBuiltin :: ToBuiltin a arep => a -> arep Source #