Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module PlutusTx.Eq
- module PlutusTx.Enum
- module PlutusTx.Ord
- module PlutusTx.Semigroup
- module PlutusTx.Monoid
- module PlutusTx.Numeric
- module PlutusTx.Functor
- module PlutusTx.Applicative
- module PlutusTx.Lattice
- module PlutusTx.Foldable
- module PlutusTx.Traversable
- (>>=) :: 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
- module PlutusTx.Base
- module PlutusTx.Trace
- data BuiltinString
- appendString :: BuiltinString -> BuiltinString -> BuiltinString
- emptyString :: BuiltinString
- equalsString :: BuiltinString -> BuiltinString -> Bool
- encodeUtf8 :: BuiltinString -> BuiltinByteString
- error :: () -> a
- check :: Bool -> ()
- module PlutusTx.Bool
- data Integer
- divide :: Integer -> Integer -> Integer
- modulo :: Integer -> Integer -> Integer
- quotient :: Integer -> Integer -> Integer
- remainder :: Integer -> Integer -> Integer
- even :: Integer -> Bool
- module PlutusTx.Maybe
- module PlutusTx.Either
- map :: (a -> b) -> [a] -> [b]
- (++) :: [a] -> [a] -> [a]
- filter :: (a -> Bool) -> [a] -> [a]
- listToMaybe :: [a] -> Maybe a
- uniqueElement :: [a] -> Maybe a
- findIndices :: (a -> Bool) -> [a] -> [Integer]
- findIndex :: (a -> Bool) -> [a] -> Maybe Integer
- (!!) :: [a] -> Integer -> a
- reverse :: [a] -> [a]
- zip :: [a] -> [b] -> [(a, b)]
- head :: [a] -> a
- tail :: [a] -> [a]
- take :: Integer -> [a] -> [a]
- nub :: Eq a => [a] -> [a]
- nubBy :: (a -> a -> Bool) -> [a] -> [a]
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- dropWhile :: (a -> Bool) -> [a] -> [a]
- partition :: (a -> Bool) -> [a] -> ([a], [a])
- sort :: Ord a => [a] -> [a]
- sortBy :: (a -> a -> Ordering) -> [a] -> [a]
- data BuiltinByteString
- appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- consByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- takeByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- dropByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString
- lengthOfByteString :: BuiltinByteString -> Integer
- indexByteString :: BuiltinByteString -> Integer -> Integer
- emptyByteString :: BuiltinByteString
- decodeUtf8 :: BuiltinByteString -> BuiltinString
- sha2_256 :: BuiltinByteString -> BuiltinByteString
- sha3_256 :: BuiltinByteString -> BuiltinByteString
- verifyEd25519Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifyEcdsaSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifySchnorrSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- data Rational
- unsafeRatio :: Integer -> Integer -> Rational
- ratio :: Integer -> Integer -> Maybe Rational
- fromInteger :: Integer -> Rational
- round :: Rational -> Integer
- data BuiltinData
- fromBuiltin :: FromBuiltin arep a => arep -> a
- toBuiltin :: ToBuiltin a arep => a -> arep
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.
{-# LANGUAGE NoImplicitPrelude #-}
import PlutusTx.Prelude
module PlutusTx.Eq
module PlutusTx.Enum
module PlutusTx.Ord
module PlutusTx.Semigroup
module PlutusTx.Monoid
module PlutusTx.Numeric
module PlutusTx.Functor
module PlutusTx.Applicative
module PlutusTx.Lattice
module PlutusTx.Foldable
module PlutusTx.Traversable
Monad
(>>=) :: Monad m => m a -> (a -> m b) -> m b infixl 1 Source #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source #
Same as >>=
, but with the arguments interchanged.
(>>) :: Monad m => m a -> m b -> m b infixl 1 Source #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
Standard functions, Tuples
module PlutusTx.Base
Tracing functions
module PlutusTx.Trace
String
data BuiltinString Source #
Instances
appendString :: BuiltinString -> BuiltinString -> BuiltinString Source #
Append two String
s.
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
Booleans
module PlutusTx.Bool
Integer numbers
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int
, the Integer
type represents the entire infinite range of
integers.
For more information about this type's representation, see the comments in its implementation.
Instances
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
module PlutusTx.Maybe
Either
module PlutusTx.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
.
ByteStrings
data BuiltinByteString Source #
An opaque type representing Plutus Core ByteStrings.
Instances
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString Source #
Concatenates two ByteString
s.
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
verifyEd25519Signature Source #
:: BuiltinByteString | Public Key (32 bytes) |
-> BuiltinByteString | Message (arbirtary length) |
-> BuiltinByteString | Signature (64 bytes) |
-> Bool |
Ed25519 signature verification. Verify that the signature is a signature of the message by the public key. This will fail if key or the signature are not of the expected length.
verifyEcdsaSecp256k1Signature Source #
:: BuiltinByteString | Verification key (64 bytes) |
-> BuiltinByteString | Message hash (32 bytes) |
-> BuiltinByteString | Signature (64 bytes) |
-> Bool |
Given an ECDSA SECP256k1 verification key, an ECDSA SECP256k1 signature,
and an ECDSA SECP256k1 message hash (all as BuiltinByteString
s), verify the
hash with that key and signature.
Important note
The verification key, the signature, and the message hash must all be of appropriate form and length. This function will error if any of these are not the case.
verifySchnorrSecp256k1Signature Source #
:: BuiltinByteString | Verification key (64 bytes) |
-> BuiltinByteString | Message |
-> BuiltinByteString | Signature (64 bytes) |
-> Bool |
Given a Schnorr SECP256k1 verification key, a Schnorr SECP256k1 signature,
and a message (all as BuiltinByteString
s), verify the message with that key
and signature.
Important note
The verification key and signature must all be of appropriate form and length. This function will error if this is not the case.
Rational numbers
Represents an arbitrary-precision ratio.
Instances
ratio :: Integer -> Integer -> Maybe Rational Source #
Safely constructs a Rational
from a numerator and a denominator. Returns
Nothing
if given a zero denominator.
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
fromBuiltin :: FromBuiltin arep a => arep -> a Source #