Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype PDataNewtype (a :: S -> Type) (s :: S) = PDataNewtype (Term s (PAsData a))
- data PBool (s :: S)
- pand' :: forall (s :: S). Term s (PBool :--> (PBool :--> PBool))
- pcond :: forall (a :: S -> Type) (s :: S). [(Term s PBool, Term s a)] -> Term s a -> Term s a
- pif :: forall (a :: S -> Type) (s :: S). Term s PBool -> Term s a -> Term s a -> Term s a
- pif' :: forall (a :: S -> Type) (s :: S). Term s (PBool :--> (a :--> (a :--> a)))
- pnot :: forall (s :: S). Term s (PBool :--> PBool)
- por' :: Term s (PBool :--> (PBool :--> PBool))
- (#&&) :: forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
- (#||) :: forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
- data PByte (s :: S)
- data PByteString s
- data PLogicOpSemantics (s :: S)
- pandBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString)))
- pbyteToInteger :: Term s (PByte :--> PInteger)
- pcomplementBS :: forall (s :: S). Term s (PByteString :--> PByteString)
- pconsBS :: Term s (PByte :--> (PByteString :--> PByteString))
- phexByteStr :: HasCallStack => String -> Term s PByteString
- pindexBS :: Term s (PByteString :--> (PInteger :--> PByte))
- pintegerToByte :: Term s (PInteger :--> PByte)
- plengthBS :: Term s (PByteString :--> PInteger)
- porBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString)))
- ppadding :: forall (s :: S). Term s PLogicOpSemantics
- preplicateBS :: forall (s :: S). Term s (PInteger :--> (PByte :--> PByteString))
- psliceBS :: Term s (PInteger :--> (PInteger :--> (PByteString :--> PByteString)))
- ptruncation :: forall (s :: S). Term s PLogicOpSemantics
- pxorBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString)))
- psha2_256 :: Term s (PByteString :--> PByteString)
- psha3_256 :: Term s (PByteString :--> PByteString)
- pverifySignature :: Term s (PByteString :--> (PByteString :--> (PByteString :--> PBool)))
- newtype PAsData (a :: S -> Type) (s :: S) = PAsData (Term s a)
- data PBuiltinList (a :: S -> Type) (s :: S)
- = PCons (Term s a) (Term s (PBuiltinList a))
- | PNil
- newtype PBuiltinPair (a :: S -> Type) (b :: S -> Type) (s :: S) = PBuiltinPair (Term s (PBuiltinPair a b))
- newtype PData (s :: S) = PData (Term s PData)
- pasByteStr :: Term s (PData :--> PByteString)
- pasConstr :: Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
- pasInt :: Term s (PData :--> PInteger)
- pasList :: Term s (PData :--> PBuiltinList PData)
- pasMap :: Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
- pchooseData :: Term s (PData :--> (a :--> (a :--> (a :--> (a :--> (a :--> a))))))
- pchooseListBuiltin :: Term s (PBuiltinList a :--> (b :--> (b :--> b)))
- pconsBuiltin :: Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
- pconstrBuiltin :: Term s (PInteger :--> (PBuiltinList PData :--> PAsData (PBuiltinPair PInteger (PBuiltinList PData))))
- pfstBuiltin :: Term s (PBuiltinPair a b :--> a)
- pheadBuiltin :: Term s (PBuiltinList a :--> a)
- plistData :: Term s (PBuiltinList PData :--> PData)
- pnullBuiltin :: Term s (PBuiltinList a :--> PBool)
- ppairDataBuiltin :: Term s (PAsData a :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
- pserialiseData :: Term s (PData :--> PByteString)
- psndBuiltin :: Term s (PBuiltinPair a b :--> b)
- ptailBuiltin :: Term s (PBuiltinList a :--> PBuiltinList a)
- data PInteger s
- newtype POpaque s = POpaque (Term s POpaque)
- popaque :: Term s a -> Term s POpaque
- data PString s
- pdecodeUtf8 :: Term s (PByteString :--> PString)
- pencodeUtf8 :: Term s (PString :--> PByteString)
- data PUnit (s :: S) = PUnit
- class PDataFields (a :: S -> Type)
- data PDataRecord (as :: [PLabeledType]) (s :: S)
- data PDataSum defs s
- data PLabeledType = Symbol := (S -> Type)
- data PlutusTypeData
- pdcons :: forall label a l s. Term s (PAsData a :--> (PDataRecord l :--> PDataRecord ((label ':= a) ': l)))
- pdnil :: Term s (PDataRecord '[])
- pfield :: forall name b p s a as n. (PDataFields p, as ~ PFields p, n ~ PLabelIndex name as, KnownNat n, a ~ PUnLabel (IndexList n as), PFromDataable a b) => Term s (p :--> b)
- pletFields :: forall fs a s b ps bs. (PDataFields a, ps ~ PFields a, bs ~ Bindings ps fs, BindFields ps bs) => Term s a -> (HRecOf a fs s -> Term s b) -> Term s b
- data PEither (a :: S -> Type) (b :: S -> Type) (s :: S)
- class POrd a => PCountable (a :: S -> Type) where
- psuccessor :: forall (s :: S). Term s (a :--> a)
- psuccessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a))
- class PCountable a => PEnumerable (a :: S -> Type) where
- ppredecessor :: forall (s :: S). Term s (a :--> a)
- ppredecessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a))
- class PEq t where
- class PEq t => POrd t where
- (#>) :: forall (a :: S -> Type) (s :: S). POrd a => Term s a -> Term s a -> Term s PBool
- (#>=) :: forall (a :: S -> Type) (s :: S). POrd a => Term s a -> Term s a -> Term s PBool
- pfix :: Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
- class PIsData a where
- pdata :: PIsData a => Term s a -> Term s (PAsData a)
- pforgetData :: forall s a. Term s (PAsData a) -> Term s PData
- pfromData :: PIsData a => Term s (PAsData a) -> Term s a
- class PlutusType a => PLiftable (a :: S -> Type) where
- type AsHaskell a :: Type
- type PlutusRepr a :: Type
- toPlutarchRepr :: AsHaskell a -> PlutusRepr a
- toPlutarch :: AsHaskell a -> PLifted s a
- fromPlutarchRepr :: PlutusRepr a -> Maybe (AsHaskell a)
- fromPlutarch :: (forall s. PLifted s a) -> Either LiftError (AsHaskell a)
- data DeriveDataPLiftable (a :: S -> Type) (h :: Type) (s :: S)
- data DeriveNewtypePLiftable (wrapper :: S -> Type) (inner :: S -> Type) (h :: Type) (s :: S)
- newtype PLifted (s :: S) (a :: S -> Type) = PLifted (Term s POpaque)
- fromPlutarchUni :: forall (a :: S -> Type). (PLiftable a, DefaultUni `Includes` PlutusRepr a) => (forall s. PLifted s a) -> Either LiftError (AsHaskell a)
- toPlutarchUni :: forall (a :: S -> Type) (s :: S). (PLiftable a, DefaultUni `Includes` PlutusRepr a) => AsHaskell a -> PLifted s a
- pconstant :: forall (a :: S -> Type) (s :: S). PLiftable a => AsHaskell a -> Term s a
- plift :: forall (a :: S -> Type). PLiftable a => (forall (s :: S). Term s a) -> AsHaskell a
- type family PElemConstraint list (a :: S -> Type) :: Constraint
- type PIsListLike list a = (PListLike list, PElemConstraint list a)
- class PListLike (list :: (S -> Type) -> S -> Type)
- data PList (a :: S -> Type) (s :: S)
- pelem :: (PIsListLike list a, PEq a) => Term s (a :--> (list a :--> PBool))
- pelemAt :: PIsListLike l a => Term s (PInteger :--> (l a :--> a))
- pfind :: PIsListLike l a => Term s ((a :--> PBool) :--> (l a :--> PMaybe a))
- plistEquals :: (PIsListLike list a, PEq a) => Term s (list a :--> (list a :--> PBool))
- puncons :: PIsListLike list a => Term s (list a :--> PMaybe (PPair a (list a)))
- pzip :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list (PPair a b)) => Term s (list a :--> (list b :--> list (PPair a b)))
- (#!!) :: PIsListLike l a => Term s (l a) -> Term s PInteger -> Term s a
- pall :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool))
- pany :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool))
- pconcat :: PIsListLike list a => Term s (list a :--> (list a :--> list a))
- pcons :: (PListLike list, PElemConstraint list a) => Term s (a :--> (list a :--> list a))
- pdrop :: PIsListLike list a => Natural -> Term s (list a) -> Term s (list a)
- pelimList :: (PListLike list, PElemConstraint list a) => (Term s a -> Term s (list a) -> Term s r) -> Term s r -> Term s (list a) -> Term s r
- pfilter :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> list a))
- pfoldl :: PIsListLike list a => Term s ((b :--> (a :--> b)) :--> (b :--> (list a :--> b)))
- pfoldr :: PIsListLike list a => Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b)))
- pfoldrLazy :: PIsListLike list a => Term s ((a :--> (PDelayed b :--> b)) :--> (b :--> (list a :--> b)))
- phead :: (PListLike list, PElemConstraint list a) => Term s (list a :--> a)
- plength :: PIsListLike list a => Term s (list a :--> PInteger)
- pmap :: (PListLike list, PElemConstraint list a, PElemConstraint list b) => Term s ((a :--> b) :--> (list a :--> list b))
- pnil :: (PListLike list, PElemConstraint list a) => Term s (list a)
- pnull :: (PListLike list, PElemConstraint list a) => Term s (list a :--> PBool)
- precList :: PIsListLike list a => (Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r) -> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
- psingleton :: PIsListLike list a => Term s (a :--> list a)
- ptail :: (PListLike list, PElemConstraint list a) => Term s (list a :--> list a)
- ptryIndex :: PIsListLike list a => Natural -> Term s (list a) -> Term s a
- pzipWith :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => Term s ((a :--> (b :--> c)) :--> (list a :--> (list b :--> list c)))
- pzipWith' :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => (Term s a -> Term s b -> Term s c) -> Term s (list a :--> (list b :--> list c))
- class (PInner a ~ DerivedPInner (DPTStrat a) a, PlutusTypeStrat (DPTStrat a), PlutusTypeStratConstraint (DPTStrat a) a, PlutusType a) => DerivePlutusType (a :: PType) where
- type PCon = PlutusType
- type PMatch = PlutusType
- class PlutusType (a :: PType) where
- pcon :: PlutusType a => a s -> Term s a
- pmatch :: PlutusType a => Term s a -> (a s -> Term s b) -> Term s b
- data PlutusTypeNewtype
- data PlutusTypeScott
- data Positive
- data PPositive (s :: S)
- class PAdditiveSemigroup (a :: S -> Type) where
- class PAdditiveSemigroup a => PAdditiveMonoid (a :: S -> Type) where
- class PAdditiveMonoid a => PAdditiveGroup (a :: S -> Type) where
- class PMultiplicativeSemigroup (a :: S -> Type) where
- class PMultiplicativeSemigroup a => PMultiplicativeMonoid (a :: S -> Type) where
- class (PAdditiveGroup a, PMultiplicativeMonoid a) => PRing (a :: S -> Type) where
- pfromInteger :: forall (s :: S). Integer -> Term s a
- class (PRing a, POrd a) => PIntegralDomain (a :: S -> Type) where
- pquot :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
- prem :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
- pdiv :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
- pmod :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
- ppositive :: Term s (PInteger :--> PMaybe PPositive)
- ptryPositive :: forall (s :: S). Term s (PInteger :--> PPositive)
- pto :: Term s a -> Term s (PInner a)
- pinl :: Term s a -> (Term s a -> Term s b) -> Term s b
- plam :: forall c. (PLamN a b s, HasCallStack) => (Term s c -> a) -> Term s (c :--> b)
- newtype PForall (b :: a -> PType) s = PForall (forall (x :: a). Term s (b x))
- class PShow t
- pshow :: PShow a => Term s a -> Term s PString
- data Term (s :: S) (a :: PType)
- data S
- type ClosedTerm (a :: PType) = forall (s :: S). Term s a
- data PDelayed (a :: PType) (s :: S)
- papp :: Term s (a :--> b) -> Term s a -> Term s b
- pdelay :: Term s a -> Term s (PDelayed a)
- pforce :: Term s (PDelayed a) -> Term s a
- perror :: Term s a
- phoistAcyclic :: HasCallStack => ClosedTerm a -> Term s a
- plet :: Term s a -> (Term s a -> Term s b) -> Term s b
- pthrow :: HasCallStack => Text -> Term s a
- (#) :: Term s (a :--> b) -> Term s a -> Term s b
- (#$) :: Term s (a :--> b) -> Term s a -> Term s b
- data ((a :: PType) :--> (b :: PType)) (s :: S)
- type family PSubtype (a :: PType) (b :: PType) :: Constraint where ...
- class PSubtype a b => PTryFrom (a :: PType) (b :: PType) where
- type PTryFromExcess a b :: PType
- ptryFrom' :: forall s r. Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r
- ptryFrom :: forall b a s r. PTryFrom a b => Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r
- pupcast :: forall a b s. PSubtype a b => Term s b -> Term s a
- data PMaybe (a :: S -> Type) (s :: S)
- data PPair (a :: PType) (b :: PType) (s :: S) = PPair (Term s a) (Term s b)
- data PRational s = PRational (Term s PInteger) (Term s PPositive)
- pdenominator :: Term s (PRational :--> PPositive)
- pnumerator :: Term s (PRational :--> PInteger)
- pround :: Term s (PRational :--> PInteger)
- newtype TermCont :: forall (r :: PType). S -> Type -> Type where
- pguardC :: Term s PString -> Term s PBool -> TermCont s ()
- pguardC' :: Term s a -> Term s PBool -> TermCont @a s ()
- pletC :: Term s a -> TermCont s (Term s a)
- pletFieldsC :: forall fs a s b ps bs. (PDataFields a, ps ~ PFields a, bs ~ Bindings ps fs, BindFields ps bs) => Term s a -> TermCont @b s (HRec (BoundTerms ps bs s))
- pmatchC :: PlutusType a => Term s a -> TermCont s (a s)
- ptraceC :: Term s PString -> TermCont s ()
- ptryFromC :: forall b r a s. PTryFrom a b => Term s a -> TermCont @r s (Term s b, Reduce (PTryFromExcess a b s))
- unTermCont :: TermCont @a s (Term s a) -> Term s a
- tcont :: ((a -> Term s r) -> Term s r) -> TermCont @r s a
- ptrace :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a -> Term s a
- ptraceDebug :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a -> Term s a
- ptraceDebugError :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a
- ptraceDebugIfFalse :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool
- ptraceDebugIfTrue :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool
- ptraceDebugShowId :: forall (a :: S -> Type) (s :: S). PShow a => Term s a -> Term s a
- ptraceError :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a
- ptraceIfFalse :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool
- ptraceInfo :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a -> Term s a
- ptraceInfoError :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a
- ptraceInfoIfFalse :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool
- ptraceInfoIfTrue :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool
- ptraceInfoShowId :: forall (a :: S -> Type) (s :: S). PShow a => Term s a -> Term s a
- ptraceShowId :: forall (a :: S -> Type) (s :: S). PShow a => Term s a -> Term s a
Documentation
newtype PDataNewtype (a :: S -> Type) (s :: S) Source #
Since: 1.7.0
PDataNewtype (Term s (PAsData a)) |
Instances
Boolean
Builtin Plutus boolean.
@since WIP
Instances
pand' :: forall (s :: S). Term s (PBool :--> (PBool :--> PBool)) Source #
As pand
, but strict.
@since WIP
pcond :: forall (a :: S -> Type) (s :: S). [(Term s PBool, Term s a)] -> Term s a -> Term s a Source #
Essentially multi-way pif
. More precisely, given a list of
condition-action pairs, and an 'action of last resort', construct a
left-to-right 'chain' of pif
s, using the conditions to determine which
action gets taken. The 'action of last resort' finishes the 'chain'. For
example:
pcond [(cond1, act1), (cond2, act2)] act3
does the same thing as
pif cond1 act1 (pif cond2 act2 act3)
@since WIP
pif :: forall (a :: S -> Type) (s :: S). Term s PBool -> Term s a -> Term s a -> Term s a Source #
Lazy if-then-else.
@since WIP
pif' :: forall (a :: S -> Type) (s :: S). Term s (PBool :--> (a :--> (a :--> a))) Source #
Strict if-then-else. Emits slightly less code than the lazy version.
@since WIP
(#&&) :: forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool infixr 3 Source #
Lazy AND for terms.
@since WIP
(#||) :: forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool infixr 2 Source #
Lazy OR for terms.
@since WIP
Bytestring
A Plutarch-level representation of bytes.
Note =
This type is intentionally quite restrictive, as it's not really meant to be
computed with. Instead, it ensures certain operations' type safety while also
allowing more sensible signatures. If you want to do anything with PByte
s,
we recommend converting them to PInteger
s first.
@since WIP
Instances
data PByteString s Source #
Plutus BuiltinByteString
Instances
data PLogicOpSemantics (s :: S) Source #
Type designating whether logical operations should use padding or truncation semantics. See CIP-122 for more details on this.
@since WIP
Instances
pandBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString))) Source #
Perform the logical AND of two PByteString
s, as per
CIP-122.
The PLogicOpSemantics
argument specifies what should be done if the lengths
of the two PByteString
arguments do not match.
@since WIP
pcomplementBS :: forall (s :: S). Term s (PByteString :--> PByteString) Source #
Perform the logical complement of a PByteString
, as per
CIP-122.
@since WIP
pconsBS :: Term s (PByte :--> (PByteString :--> PByteString)) Source #
Prepend a PByte
to a 'PByteString.
@since WIP
phexByteStr :: HasCallStack => String -> Term s PByteString Source #
Interpret a hex string as a PByteString.
pindexBS :: Term s (PByteString :--> (PInteger :--> PByte)) Source #
Given a valid index into a PByteString
, returns the PByte
at that
index. Will crash if given an out-of-bounds index.
@since WIP
plengthBS :: Term s (PByteString :--> PInteger) Source #
Find the length of a PByteString
.
porBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString))) Source #
Perform the logical OR of two PByteString
s, as per
CIP-122.
The PLogicOpSemantics
argument specifies what should be done if the lengths
of the two PByteString
arguments do not match.
@since WIP
ppadding :: forall (s :: S). Term s PLogicOpSemantics Source #
Indicates that padding semantics should be used.
@since WIP
preplicateBS :: forall (s :: S). Term s (PInteger :--> (PByte :--> PByteString)) Source #
Given a desired length and a PByte
, construct a PByteString
of the
specified length (0 if negative) consisting entirely of that PByte
.
@since WIP
psliceBS :: Term s (PInteger :--> (PInteger :--> (PByteString :--> PByteString))) Source #
Slice a PByteString
with given start index and slice length.
>>>
(pslice # 2 # 3 phexByteStr "4102afde5b2a") #== phexByteStr "afde5b"
ptruncation :: forall (s :: S). Term s PLogicOpSemantics Source #
Indicates that truncation semantics should be used.
@since WIP
pxorBS :: forall (s :: S). Term s (PLogicOpSemantics :--> (PByteString :--> (PByteString :--> PByteString))) Source #
Perform the logical XOR of two PByteString
s, as per
CIP-122.
The PLogicOpSemantics
argument specifies what should be done if the lengths
of the two PByteString
arguments do not match.
@since WIP
Cryptographic primitives
psha2_256 :: Term s (PByteString :--> PByteString) Source #
Hash a PByteString
using SHA-256.
psha3_256 :: Term s (PByteString :--> PByteString) Source #
Hash a PByteString
using SHA3-256.
pverifySignature :: Term s (PByteString :--> (PByteString :--> (PByteString :--> PBool))) Source #
Deprecated: use one of the Ed25519, Schnorr- or ECDSA Secp256k1 signature verification functions
Verify the signature against the public key and message.
Data encoding
newtype PAsData (a :: S -> Type) (s :: S) Source #
Instances
data PBuiltinList (a :: S -> Type) (s :: S) Source #
Plutus BuiltinList
PCons (Term s a) (Term s (PBuiltinList a)) | |
PNil |
Instances
newtype PBuiltinPair (a :: S -> Type) (b :: S -> Type) (s :: S) Source #
PBuiltinPair (Term s (PBuiltinPair a b)) |
Instances
newtype PData (s :: S) Source #
Instances
pasByteStr :: Term s (PData :--> PByteString) Source #
pasConstr :: Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData)) Source #
pasMap :: Term s (PData :--> PBuiltinList (PBuiltinPair PData PData)) Source #
pchooseListBuiltin :: Term s (PBuiltinList a :--> (b :--> (b :--> b))) Source #
pconsBuiltin :: Term s (a :--> (PBuiltinList a :--> PBuiltinList a)) Source #
pconstrBuiltin :: Term s (PInteger :--> (PBuiltinList PData :--> PAsData (PBuiltinPair PInteger (PBuiltinList PData)))) Source #
pfstBuiltin :: Term s (PBuiltinPair a b :--> a) Source #
pheadBuiltin :: Term s (PBuiltinList a :--> a) Source #
pnullBuiltin :: Term s (PBuiltinList a :--> PBool) Source #
ppairDataBuiltin :: Term s (PAsData a :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b))) Source #
pserialiseData :: Term s (PData :--> PByteString) Source #
Serialise any builtin data to its cbor represented by a builtin bytestring
psndBuiltin :: Term s (PBuiltinPair a b :--> b) Source #
ptailBuiltin :: Term s (PBuiltinList a :--> PBuiltinList a) Source #
Integer
A builtin Plutus integer.
@since WIP
Instances
Opaque
An Arbitrary Term with an unknown type
Instances
PlutusType POpaque Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PContravariant' POpaque Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PCovariant' POpaque Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PInner POpaque Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PVariant' POpaque Source # | |
Defined in Plutarch.Internal.PlutusType |
String
Plutus BuiltinString
values
Instances
pdecodeUtf8 :: Term s (PByteString :--> PString) Source #
Decode a PByteString
using UTF-8.
pencodeUtf8 :: Term s (PString :--> PByteString) Source #
Encode a PString
using UTF-8.
Unit
Instances
DataRepr
class PDataFields (a :: S -> Type) Source #
Class allowing letFields
to work for a PType, usually via
PIsDataRepr
, but is derived for some other types for convenience.
Instances
(PIsData a, PDataFields a) => PDataFields (PAsData a) Source # | |
PDataFields (PDataRecord as) Source # | |
Defined in Plutarch.DataRepr.Internal.Field type PFields (PDataRecord as) :: [PLabeledType] Source # ptoFields :: forall (s :: S). Term s (PDataRecord as) -> Term s (PDataRecord (PFields (PDataRecord as))) Source # | |
PDataFields (PDataSum '[as]) Source # | |
data PDataRecord (as :: [PLabeledType]) (s :: S) Source #
A "record" of `exists a. PAsData a`. The underlying representation is `PBuiltinList PData`.
Instances
A sum of PDataRecord
s. The underlying representation is the Constr
constructor,
where the integer is the index of the variant and the list is the record.
Instances
data PLabeledType Source #
Instances
data PlutusTypeData Source #
Instances
PlutusTypeStrat PlutusTypeData Source # | |
Defined in Plutarch.DataRepr.Internal type PlutusTypeStratConstraint PlutusTypeData :: PType -> Constraint Source # type DerivedPInner PlutusTypeData a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeData) => a s -> Term s (DerivedPInner PlutusTypeData a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeData) => Term s (DerivedPInner PlutusTypeData a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeData Source # | |
Defined in Plutarch.DataRepr.Internal | |
type DerivedPInner PlutusTypeData a Source # | |
Defined in Plutarch.DataRepr.Internal |
pdcons :: forall label a l s. Term s (PAsData a :--> (PDataRecord l :--> PDataRecord ((label ':= a) ': l))) Source #
Cons a field to a data record.
You can specify the label to associate with the field using type applications-
foo :: Term s (PDataRecord '[ "fooField" ':= PByteString ]) foo = pdcons @"fooField" # pdata (phexByteStr "ab") # pdnil
pdnil :: Term s (PDataRecord '[]) Source #
An empty PDataRecord
.
pfield :: forall name b p s a as n. (PDataFields p, as ~ PFields p, n ~ PLabelIndex name as, KnownNat n, a ~ PUnLabel (IndexList n as), PFromDataable a b) => Term s (p :--> b) Source #
Get a single field from a Term.
- NB*: If you access more than one field from
the same value you should use
pletFields
instead, which will generate the bindings more efficiently.
pletFields :: forall fs a s b ps bs. (PDataFields a, ps ~ PFields a, bs ~ Bindings ps fs, BindFields ps bs) => Term s a -> (HRecOf a fs s -> Term s b) -> Term s b Source #
Bind a HRec of named fields containing all the specified fields.
Either
data PEither (a :: S -> Type) (b :: S -> Type) (s :: S) Source #
Scott-encoded Either
.
Instances
Enumerable and Countable
class POrd a => PCountable (a :: S -> Type) where Source #
A notion of 'next' value. More formally, instances of this type class are discrete linear orders with no maximal element.
Laws
x /= psuccessor x
y < x
=
psuccessor y <= x
x < psuccessor y
=
x <= y
If you define psuccessorN
, you must also ensure the following hold; the
default implementation ensures this.
psuccessorN 1
=
psuccessor
psuccessorN n . psuccessorN m
=
psuccessorN (n + m)
Law 1 ensures no value is its own successor. Laws 2 and 3 ensure that there
are no 'gaps': every value is 'reachable' from any lower value by a
finite number of applications of successor
.
@since WIP
psuccessor :: forall (s :: S). Term s (a :--> a) Source #
@since WIP
psuccessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a)) Source #
The default implementation of this function is inefficient: if at all possible, give instances an optimized version that doesn't require recursion.
@since WIP
Instances
PCountable PInteger Source # | @since WIP |
PCountable PPositive Source # | @since WIP |
class PCountable a => PEnumerable (a :: S -> Type) where Source #
Similar to PCountable
, but has the ability to get a 'previous' value as
well. More formally, instances of this type class are discrete linear orders
with no maximal or minimal element.
Laws
ppredecessor . psuccessor
=
psuccessor . ppredecessor
=
id
If you define ppredecessorN
, you must also ensure the following hold; the
default implementation ensures this.
ppredecessorN 1
=
ppredecessor
ppredecessorN n . ppredecessorN m
=
ppredecessorN (n + m)
From Law 1, we obtain the following theorem:
x /= predecessor x
@since WIP
ppredecessor :: forall (s :: S). Term s (a :--> a) Source #
@since WIP
ppredecessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a)) Source #
The default implementation of this function is inefficient: if at all possible, give instances an optimized version that doesn't require recursion.
@since WIP
Eq and Ord
Nothing
Instances
class PEq t => POrd t where Source #
Total ordering relation.
Laws
#<=
must form a total order. More precisely:
x #<= x
=
pcon PTrue
(reflexivity)(y #< x) #|| (z #< y) #|| (x #<= z)
=
pcon PTrue
(transitivity)(x #<= y) #|| (y #<= x)
=
pcon PTrue
(totality)
Furthermore, #<
must be an equivalent strict total order to #<=
:
x #< x
=
pcon PFalse
(irreflexivity)(y #<= x) #|| (z #<= y) #|| (x #< z)
=
pcon PTrue
(transitivity)(x #< y) #|| (y #< x) #|| (x #== z)
=
pcon PTrue
(trichotomy)x #<= y
=
(x #< y) #|| (x #== y)
(strict equivalence)
If you define pmax
or pmin
, ensure the following also hold:
pmax # x # y
=
pmax # y # x
(commutativity, also for @pmin)pmax # x #$ pmax y z
=
pmax # (pmax # x # y) # z
(associativity, also for @pmin)pmax # x #$ pmin # y # z
=
pmin # (pmax # x # y) # (pmax # x # z)
(pmax
distributes overpmin
, also equivalent forpmin
)pmin x y
=
pif' (x #<= y) x y
pmax x y
=
pif' (x #<= y) y x
Laws 8-12 hold if you use the defaults provided by this type class.
@since WIP
Nothing
(#<=) :: Term s t -> Term s t -> Term s PBool infix 4 Source #
@since WIP
(#<) :: Term s t -> Term s t -> Term s PBool infix 4 Source #
@since WIP
pmax :: forall (s :: S). Term s t -> Term s t -> Term s t Source #
@since WIP
pmin :: forall (s :: S). Term s t -> Term s t -> Term s t Source #
@since WIP
Instances
(#>) :: forall (a :: S -> Type) (s :: S). POrd a => Term s a -> Term s a -> Term s PBool infix 4 Source #
@since WIP
(#>=) :: forall (a :: S -> Type) (s :: S). POrd a => Term s a -> Term s a -> Term s PBool infix 4 Source #
@since WIP
Fixed point
pfix :: Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b)) Source #
Fixpoint recursion. Used to encode recursive functions.
Example:
iterateN' :: Term s (PInteger :--> (a :--> a) :--> a :--> a) -> Term s PInteger -> Term s (a :--> a) -> Term s a iterateN' self n f x = pif (n #== 0) x (self # n - 1 #$ f x) iterateN :: Term s (PInteger :--> (a :--> a) :--> a :--> a) iterateN = pfix #$ plam iterateN'
Further examples can be found in examples/Recursion.hs
IsData
class PIsData a where Source #
Laws:
- If PSubtype PData a
, then pdataImpl a
must be pupcast
.
- pdataImpl . pupcast . pfromDataImpl ≡ id
- pfromDataImpl . punsafeDowncast . pdataImpl ≡ id
Nothing
Instances
Lifting and lowering
class PlutusType a => PLiftable (a :: S -> Type) where Source #
Indicates that the given Plutarch type has an equivalent in Haskell (and Plutus by extension), and we have the ability to move between them.
Important note
Calling methods of PLiftable
directly should rarely, if ever, be a
thing you do, unless defining your own instances without via
-deriving
helpers (below). Prefer using pconstant
and plift
, as these handle
some of the oddities required without you having to think about them.
You should rarely, if ever, need to define PLiftable
instances by hand.
Whenever possible, prefer using DeriveBuiltinPLiftable
,
DeriveDataPLiftable
, and DeriveNewtypePLiftable
as they have fewer
complexities and caveats. See their documentation for when to use them.
If you do want to define the methods yourself, there's a few key factors to keep in mind:
- You still shouldn't write every method by hand, there are helpers
fromPlutarch*
andtoPlutarch*
to cover common cases like types in Plutus universe or Scott encoding - If defining
toPlutarchRepr
andfromPlutarchRepr
you will need to define an associatedPlutusRepr
type, this is a Hasekll level type that is included in the Plutus default universe. - If defining
toPlutarch
andfromPlutarch
for Scott encoded type you need to setPlutusRepr
PMyType =PLiftedClosed
PMyType - When choosing a type for
AsHaskell
, any value of that type must be representable in Plutarch. If you have internal invariants to maintain on the Haskell side, make sure you do so with great care.
Laws
fromPlutarchRepr
.
toPlutarchRepr
=
Just
fmap
toPlutarchRepr
.
fromPlutarchRepr
=
Just
fromPlutarch
.
toPlutarch
=
Right
fmap
toPlutarch
.
fromPlutarch
=
Right
Any derivations via DeriveBuiltinPLiftable
, DeriveDataPLiftable
, and
DeriveNewtypePLiftable
automatically follow these laws.
@since WIP
toPlutarchRepr :: AsHaskell a -> PlutusRepr a Source #
toPlutarch :: AsHaskell a -> PLifted s a Source #
fromPlutarchRepr :: PlutusRepr a -> Maybe (AsHaskell a) Source #
fromPlutarch :: (forall s. PLifted s a) -> Either LiftError (AsHaskell a) Source #
Instances
data DeriveDataPLiftable (a :: S -> Type) (h :: Type) (s :: S) Source #
via
-deriving helper, indicating that a
has a Haskell-level equivalent
h
by way of its Data
encoding, rather than by h
being directly part of
the Plutus default universe.
@since WIP
Instances
data DeriveNewtypePLiftable (wrapper :: S -> Type) (inner :: S -> Type) (h :: Type) (s :: S) Source #
via
-deriving helper, indicating that wrapper
has a Haskell-level equivalent
h
by way of encoding of inner
. It requires that AsHaskell inner
has the same
Haskell representation as h
@since WIP
Instances
newtype PLifted (s :: S) (a :: S -> Type) Source #
Similar to Identity
, but at the level of Plutarch. Only needed when
writing manual instances of PLiftable
, or if you want to use toPlutarch
and fromPlutarch
directly.
This is used for coercing Plutarch terms in Haskell level with
`coerce :: PLifted s a -> PLifted s b` for via
-deriving helpers
@since WIP
fromPlutarchUni :: forall (a :: S -> Type). (PLiftable a, DefaultUni `Includes` PlutusRepr a) => (forall s. PLifted s a) -> Either LiftError (AsHaskell a) Source #
Valid definition for fromPlutarch
if PlutusRepr
is in Plutus universe
@since WIP
toPlutarchUni :: forall (a :: S -> Type) (s :: S). (PLiftable a, DefaultUni `Includes` PlutusRepr a) => AsHaskell a -> PLifted s a Source #
Valid definition for toPlutarch
if PlutusRepr
is in Plutus universe
@since WIP
pconstant :: forall (a :: S -> Type) (s :: S). PLiftable a => AsHaskell a -> Term s a Source #
Given a Haskell-level representation of a Plutarch term, transform it into its equivalent term.
@since WIP
plift :: forall (a :: S -> Type). PLiftable a => (forall (s :: S). Term s a) -> AsHaskell a Source #
Given a closed Plutarch term, compile and evaluate it, then produce the
corresponding Haskell value. If compilation or evaluation fails somehow, this
will call error
: if you need to 'trap' these outcomes and handle them
differently somehow, use fromPlutarch
.
@since WIP
Lists
type family PElemConstraint list (a :: S -> Type) :: Constraint Source #
Instances
type PElemConstraint PBuiltinList a Source # | |
Defined in Plutarch.Internal.ListLike | |
type PElemConstraint PList _1 Source # | |
Defined in Plutarch.List |
type PIsListLike list a = (PListLike list, PElemConstraint list a) Source #
'PIsListLike list a' constraints list
be a PListLike
with valid element type, a
.
class PListLike (list :: (S -> Type) -> S -> Type) Source #
Plutarch types that behave like lists.
Instances
data PList (a :: S -> Type) (s :: S) Source #
Instances
pelem :: (PIsListLike list a, PEq a) => Term s (a :--> (list a :--> PBool)) Source #
O(n) . Check if element is in the list
pelemAt :: PIsListLike l a => Term s (PInteger :--> (l a :--> a)) Source #
O(n) . Like Haskell level (!!)
but on the Plutarch level, not infix and
with arguments reversed, errors if the specified index is greater than or equal
to the lists length
pfind :: PIsListLike l a => Term s ((a :--> PBool) :--> (l a :--> PMaybe a)) Source #
O(n) . like haskell level find
but on plutarch level
plistEquals :: (PIsListLike list a, PEq a) => Term s (list a :--> (list a :--> PBool)) Source #
O(min(n, m)) . Check if two lists are equal.
puncons :: PIsListLike list a => Term s (list a :--> PMaybe (PPair a (list a))) Source #
Extract head and tail of the list, if list is not empty.
pzip :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list (PPair a b)) => Term s (list a :--> (list b :--> list (PPair a b))) Source #
O(min(n, m)) . Zip two lists together, creating pairs of the elements.
If the lists are of differing lengths, cut to the shortest.
(#!!) :: PIsListLike l a => Term s (l a) -> Term s PInteger -> Term s a Source #
O(n) . Like Haskell level (!!)
but on the plutarch level
pall :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool)) Source #
O(n) . Check that predicate holds for all elements in a list.
pany :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool)) Source #
O(n) . Check that predicate holds for any element in a list.
pconcat :: PIsListLike list a => Term s (list a :--> (list a :--> list a)) Source #
O(n) . Concatenate two lists
Example: > pconcat # psingleton x # psingleton y == plistLiteral [x, y]
pconcat exhibits identities with empty lists such that > forall x. pconcat # pnil # x == x > forall x. pconcat # x # pnil == x
pcons :: (PListLike list, PElemConstraint list a) => Term s (a :--> (list a :--> list a)) Source #
Cons an element onto an existing list.
pdrop :: PIsListLike list a => Natural -> Term s (list a) -> Term s (list a) Source #
Drop the first n fields of a List.
The term will be statically generated as
repeated applications of ptail
, which will be more
efficient in many circumstances.
pelimList :: (PListLike list, PElemConstraint list a) => (Term s a -> Term s (list a) -> Term s r) -> Term s r -> Term s (list a) -> Term s r Source #
Canonical eliminator for list-likes.
pfilter :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> list a)) Source #
O(n) . Filter elements from a list that don't match the predicate.
pfoldl :: PIsListLike list a => Term s ((b :--> (a :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list left-associatively.
pfoldr :: PIsListLike list a => Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list right-associatively.
pfoldrLazy :: PIsListLike list a => Term s ((a :--> (PDelayed b :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list right-associatively, with opportunity for short circuting.
May short circuit when given reducer function is lazy in its second argument.
phead :: (PListLike list, PElemConstraint list a) => Term s (list a :--> a) Source #
Return the first element of a list. Partial, throws an error upon encountering an empty list.
plength :: PIsListLike list a => Term s (list a :--> PInteger) Source #
O(n) . Count the number of elements in the list
pmap :: (PListLike list, PElemConstraint list a, PElemConstraint list b) => Term s ((a :--> b) :--> (list a :--> list b)) Source #
O(n) . Map a function over a list of elements
pnull :: (PListLike list, PElemConstraint list a) => Term s (list a :--> PBool) Source #
O(1) . Check if a list is empty
precList :: PIsListLike list a => (Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r) -> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r) Source #
Like pelimList
, but with a fixpoint recursion hatch.
psingleton :: PIsListLike list a => Term s (a :--> list a) Source #
O(1) . Create a singleton list from an element
ptail :: (PListLike list, PElemConstraint list a) => Term s (list a :--> list a) Source #
Take the tail of a list, meaning drop its head. Partial, throws an error upon encountering an empty list.
ptryIndex :: PIsListLike list a => Natural -> Term s (list a) -> Term s a Source #
Index a BuiltinList, throwing an error if the index is out of bounds.
pzipWith :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => Term s ((a :--> (b :--> c)) :--> (list a :--> (list b :--> list c))) Source #
O(min(n, m)) . Zip two lists together with a passed function.
If the lists are of differing lengths, cut to the shortest.
pzipWith' :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => (Term s a -> Term s b -> Term s c) -> Term s (list a :--> (list b :--> list c)) Source #
Like pzipWith
but with Haskell-level merge function.
PlutusType
class (PInner a ~ DerivedPInner (DPTStrat a) a, PlutusTypeStrat (DPTStrat a), PlutusTypeStratConstraint (DPTStrat a) a, PlutusType a) => DerivePlutusType (a :: PType) Source #
Instances
type PCon = PlutusType Source #
Deprecated: Use PlutusType
type PMatch = PlutusType Source #
Deprecated: Use PlutusType
class PlutusType (a :: PType) Source #
Instances
pcon :: PlutusType a => a s -> Term s a Source #
Construct a Plutarch Term via a Haskell datatype
pmatch :: PlutusType a => Term s a -> (a s -> Term s b) -> Term s b Source #
Pattern match over Plutarch Terms via a Haskell datatype
data PlutusTypeNewtype Source #
Instances
PlutusTypeStrat PlutusTypeNewtype Source # | |
Defined in Plutarch.Internal.Newtype type PlutusTypeStratConstraint PlutusTypeNewtype :: PType -> Constraint Source # type DerivedPInner PlutusTypeNewtype a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeNewtype) => a s -> Term s (DerivedPInner PlutusTypeNewtype a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeNewtype) => Term s (DerivedPInner PlutusTypeNewtype a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeNewtype Source # | |
Defined in Plutarch.Internal.Newtype | |
type DerivedPInner PlutusTypeNewtype a Source # | |
Defined in Plutarch.Internal.Newtype |
data PlutusTypeScott Source #
Instances
PlutusTypeStrat PlutusTypeScott Source # | |
Defined in Plutarch.Internal.ScottEncoding type PlutusTypeStratConstraint PlutusTypeScott :: PType -> Constraint Source # type DerivedPInner PlutusTypeScott a :: PType Source # derivedPCon :: forall a (s :: S). (DerivePlutusType a, DPTStrat a ~ PlutusTypeScott) => a s -> Term s (DerivedPInner PlutusTypeScott a) Source # derivedPMatch :: forall a (s :: S) (b :: PType). (DerivePlutusType a, DPTStrat a ~ PlutusTypeScott) => Term s (DerivedPInner PlutusTypeScott a) -> (a s -> Term s b) -> Term s b Source # | |
type PlutusTypeStratConstraint PlutusTypeScott Source # | |
Defined in Plutarch.Internal.ScottEncoding | |
type DerivedPInner PlutusTypeScott a Source # | |
Defined in Plutarch.Internal.ScottEncoding |
Numeric
@since WIP
Instances
Arbitrary Positive Source # | @since WIP |
CoArbitrary Positive Source # | @since WIP |
Defined in Plutarch.Internal.Numeric coarbitrary :: Positive -> Gen b -> Gen b | |
Function Positive Source # | @since WIP |
Defined in Plutarch.Internal.Numeric | |
Show Positive Source # | @since WIP |
Eq Positive Source # | @since WIP |
Ord Positive Source # | @since WIP |
Defined in Plutarch.Internal.Numeric | |
Pretty Positive Source # | @since WIP |
Defined in Plutarch.Internal.Numeric prettyList :: [Positive] -> Doc ann |
data PPositive (s :: S) Source #
@since WIP
Instances
class PAdditiveSemigroup (a :: S -> Type) where Source #
The addition operation.
Laws
x #+ y
=
y #+ x
(commutativity of#+
)x #+ (y #+ z)
=
(x #+ y) #+ z
(associativity of#+
)
If you define a custom pscalePositive
, ensure the following also hold:
pscalePositive # x # pone
=
x
(pscalePositive # x # n) #+ (pscalePositive # x # m)
=
pscalePositive # x # (n #+ m)
pscalePositive # (pscalePositive # x # n) # m
=
pscalePositive # x # (n #* m)
The default implementation ensures these laws are satisfied.
@since WIP
Nothing
(#+) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #
default (#+) :: forall (s :: S). PAdditiveSemigroup (PInner a) => Term s a -> Term s a -> Term s a Source #
pscalePositive :: forall (s :: S). Term s (a :--> (PPositive :--> a)) Source #
This defaults to exponentiation-by-squaring, which in general is the best we can do.
Instances
PAdditiveSemigroup PBuiltinBLS12_381_G1_Element Source # | @since WIP |
Defined in Plutarch.Internal.Numeric (#+) :: forall (s :: S). Term s PBuiltinBLS12_381_G1_Element -> Term s PBuiltinBLS12_381_G1_Element -> Term s PBuiltinBLS12_381_G1_Element Source # pscalePositive :: forall (s :: S). Term s (PBuiltinBLS12_381_G1_Element :--> (PPositive :--> PBuiltinBLS12_381_G1_Element)) Source # | |
PAdditiveSemigroup PBuiltinBLS12_381_G2_Element Source # | @since WIP |
Defined in Plutarch.Internal.Numeric (#+) :: forall (s :: S). Term s PBuiltinBLS12_381_G2_Element -> Term s PBuiltinBLS12_381_G2_Element -> Term s PBuiltinBLS12_381_G2_Element Source # pscalePositive :: forall (s :: S). Term s (PBuiltinBLS12_381_G2_Element :--> (PPositive :--> PBuiltinBLS12_381_G2_Element)) Source # | |
PAdditiveSemigroup PInteger Source # | @since WIP |
PAdditiveSemigroup PPositive Source # | @since WIP @since WIP |
PAdditiveSemigroup PRational Source # | @since WIP |
class PAdditiveSemigroup a => PAdditiveMonoid (a :: S -> Type) where Source #
The notion of zero, as well as a (kind of) reversal of pscalePositive
,
similar to floor division by positive integers.
Laws
pzero #+ x
=
x
(pzero
is the identity of#+
)pscalePositive # pzero # n
=
pzero
(pzero
does not scale up)
@since WIP
Instances
PAdditiveMonoid PBuiltinBLS12_381_G1_Element Source # | @since WIP |
Defined in Plutarch.Internal.Numeric | |
PAdditiveMonoid PBuiltinBLS12_381_G2_Element Source # | @since WIP |
Defined in Plutarch.Internal.Numeric | |
PAdditiveMonoid PInteger Source # | @since WIP |
PAdditiveMonoid PRational Source # | @since WIP |
class PAdditiveMonoid a => PAdditiveGroup (a :: S -> Type) where Source #
The notion of additive inverses, and the subtraction operation.
Laws
If you define pnegate
, the following laws must hold:
(pnegate # x) #+ x
=
pzero
(pnegate
is an additive inverse)pnegate #$ pnegate # x
=
x
(pnegate
is self-inverting)
If you define #-
, the following law must hold:
x #- x
=
pzero
Additionally, the following 'consistency laws' must hold. Default
implementations of both pnegate
and #-
uphold these.
pnegate # x
=
pzero #- x
x #- y
=
x #+ (pnegate # y)
Lastly, if you define a custom pscaleInteger
, the following laws
must hold:
pscaleInteger # x # pzero
=
pzero
pscaleInteger # x #$ pnegate y
=
pnegate #$ pscaleInteger # x # y
@since WIP
pnegate :: forall (s :: S). Term s (a :--> a) Source #
(#-) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #
pscaleInteger :: forall (s :: S). Term s (a :--> (PInteger :--> a)) Source #
Instances
class PMultiplicativeSemigroup (a :: S -> Type) where Source #
The multiplication operation.
Laws
x #* (y #* z)
=
(x #* y) #* z
(associativity of#*
)
If you define a custom ppowPositive
, ensure the following also hold:
ppowPositive # x # pone
=
x
(ppowPositive # x # n) #* (ppowPositive # x # m)
=
pscalePositive # x # (n #+ m)
ppowPositive # (ppowPositive # x # n) # m
=
pscalePositive # x # (n #* m)
The default implementation ensures these laws are satisfied.
Note
Unlike PAdditiveSemigroup
, the multiplication operation doesn't need to be
commutative. Currently, all Plutarch-provided instances are, but this need
not be true for other instances.
@since WIP
Nothing
(#*) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #
default (#*) :: forall (s :: S). PMultiplicativeSemigroup (PInner a) => Term s a -> Term s a -> Term s a Source #
ppowPositive :: forall (s :: S). Term s (a :--> (PPositive :--> a)) Source #
Instances
PMultiplicativeSemigroup PInteger Source # | @since WIP |
PMultiplicativeSemigroup PPositive Source # | @since WIP @since WIP |
PMultiplicativeSemigroup PRational Source # | @since WIP |
class PMultiplicativeSemigroup a => PMultiplicativeMonoid (a :: S -> Type) where Source #
The notion of one (multiplicative identity).
Laws
pone #* x
=
x
(pone
is the left identity of#*
)x #* pone
=
x
(pone
is the right identity of#*
)
@since WIP
Instances
PMultiplicativeMonoid PInteger Source # | @since WIP |
PMultiplicativeMonoid PPositive Source # | @since WIP |
PMultiplicativeMonoid PRational Source # | @since WIP |
class (PAdditiveGroup a, PMultiplicativeMonoid a) => PRing (a :: S -> Type) where Source #
Laws
pfromInteger 0
=
pzero
pfromInteger 1
=
pone
pfromInteger (x + y)
=
pfromInteger x #+ pfromInteger y
pfromInteger (x * y)
=
pfromInteger x #* pfromInteger y
Additionally, the following 'interaction laws' must hold between the
instances of PAdditiveGroup
and PMultiplicativeMonoid
for a
:
x #* (y #+ z)
=
(x #* y) #+ (x #* z)
(#*
left-distributes over#+
)(y #+ z) #* x
=
(y #* x) #+ (z #* x)
(#*
right-distributes over#+
)
@since WIP
Nothing
class (PRing a, POrd a) => PIntegralDomain (a :: S -> Type) where Source #
Laws
Pedantry note
Technically, the requirements here are too strong: we demand an ordered ring, which integral domains don't necessarily have to be. However, in our case, our hand is forced by expected semantics: in abstract algebra, both the absolute value and the signum are real numbers (which are always totally ordered) but in our case, both must be elements of the integral domain itself. Thus, in order for the laws to make any sense, we have to ensure a total order on the integral domain. Since all of our integral domains are 'at least as big' as the integers, this doesn't pose a huge problem.
@since WIP
Nothing
Instances
PIntegralDomain PInteger Source # | @since WIP |
PIntegralDomain PRational Source # | @since WIP |
ptryPositive :: forall (s :: S). Term s (PInteger :--> PPositive) Source #
Partial version of PPositive
. Errors if argument is zero.
@since WIP
Other
pto :: Term s a -> Term s (PInner a) Source #
Safely coerce from a Term to it's PInner
representation.
newtype PForall (b :: a -> PType) s Source #
Instances
PlutusType (PForall f) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PContravariant' (PForall f) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PCovariant' (PForall f) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PInner (PForall f) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PVariant' (PForall f) Source # | |
Defined in Plutarch.Internal.PlutusType |
Show
Instances
pshow :: PShow a => Term s a -> Term s PString Source #
Return the string representation of a Plutarch value
Term and related functionality
data Term (s :: S) (a :: PType) Source #
Instances
type ClosedTerm (a :: PType) = forall (s :: S). Term s a Source #
- Closed* terms with no free variables.
pforce :: Term s (PDelayed a) -> Term s a Source #
Plutus 'force',
used to force evaluation of PDelayed
terms.
Plutus 'error'.
When using this explicitly, it should be ensured that the containing term is delayed, avoiding premature evaluation.
phoistAcyclic :: HasCallStack => ClosedTerm a -> Term s a Source #
plet :: Term s a -> (Term s a -> Term s b) -> Term s b Source #
Let bindings.
This is approximately a shorthand for a lambda and application:
plet v f
== papp (plam f) v
But sufficiently small terms in WHNF may be inlined for efficiency.
(#) :: Term s (a :--> b) -> Term s a -> Term s b infixl 8 Source #
High precedence infixl synonym of papp
, to be used like
function juxtaposition. e.g.:
>>>
f # x # y
f x y
data ((a :: PType) :--> (b :: PType)) (s :: S) infixr 0 Source #
Instances
PlutusType (a :--> b) Source # | |
Defined in Plutarch.Internal.PlutusType | |
(a' ~ Term s a, PLamN b' b s) => PLamN (a' -> b') (a :--> b) s Source # | |
Defined in Plutarch.Internal.PLam | |
type PContravariant' (a :--> b) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PCovariant' (a :--> b) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PInner (a :--> b) Source # | |
Defined in Plutarch.Internal.PlutusType | |
type PVariant' (a :--> b) Source # | |
Defined in Plutarch.Internal.PlutusType |
Conversion
type family PSubtype (a :: PType) (b :: PType) :: Constraint where ... Source #
PSubtype a b = (PSubtype' a b ~ 'PSubtypeRelation, PSubtypeHelper a b (PSubtype' a b)) |
class PSubtype a b => PTryFrom (a :: PType) (b :: PType) where Source #
PTryFrom a b
represents a subtyping relationship between a
and b
,
and a way to go from a
to b
.
Laws:
- (punsafeCoerce . fst) $ tcont (ptryFrom x) ≡ pure x
Nothing
type PTryFromExcess a b :: PType Source #
type PTryFromExcess a b = PTryFromExcess a (PInner b)
ptryFrom' :: forall s r. Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r Source #
default ptryFrom' :: forall s r. (PTryFrom a (PInner b), PTryFromExcess a b ~ PTryFromExcess a (PInner b)) => Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r Source #
Instances
ptryFrom :: forall b a s r. PTryFrom a b => Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r Source #
Maybe
data PMaybe (a :: S -> Type) (s :: S) Source #
Plutus Maybe type, with Scott-encoded repr
Instances
Pair
data PPair (a :: PType) (b :: PType) (s :: S) Source #
Plutus encoding of Pairs.
Note: This is represented differently than BuiltinPair
. It is scott-encoded.
Instances
(PEq a, PEq b) => PEq (PPair a b) Source # | |
DerivePlutusType (PPair a b) Source # | |
Defined in Plutarch.Pair | |
PlutusType (PPair a b) Source # | |
Defined in Plutarch.Pair | |
(PShow a, PShow b) => PShow (PPair a b) Source # | |
Generic (PPair a b s) Source # | |
type DPTStrat (PPair a b) Source # | |
Defined in Plutarch.Pair | |
type PContravariant' (PPair a b) Source # | |
Defined in Plutarch.Pair | |
type PCovariant' (PPair a b) Source # | |
Defined in Plutarch.Pair | |
type PInner (PPair a b) Source # | |
Defined in Plutarch.Pair | |
type PVariant' (PPair a b) Source # | |
Defined in Plutarch.Pair | |
type Rep (PPair a b s) Source # | |
Defined in Plutarch.Pair type Rep (PPair a b s) = D1 ('MetaData "PPair" "Plutarch.Pair" "plutarch-1.9.0-FtN0mhIoM9oEvz7Q98pjWP" 'False) (C1 ('MetaCons "PPair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s b)))) |
Rational
A Scott-encoded rational number, with a guaranteed positive denominator (and thus, a canonical form).
Note
This is not the Plutarch equivalent of a Plutus Rational
; for this, you
want PRationalData
from plutarch-ledger-api
. PRational
is designed to
optimize for computation: if you want to do any serious work with rational
numbers that isn't just passing them around, you want to use (or convert to)
PRational
.
Instances
TermCont
newtype TermCont :: forall (r :: PType). S -> Type -> Type where Source #
TermCont | |
|
Instances
MonadFail (TermCont s) Source # | |
Applicative (TermCont s) Source # | |
Defined in Plutarch.Internal.TermCont pure :: a -> TermCont s a Source # (<*>) :: TermCont s (a -> b) -> TermCont s a -> TermCont s b Source # liftA2 :: (a -> b -> c) -> TermCont s a -> TermCont s b -> TermCont s c Source # (*>) :: TermCont s a -> TermCont s b -> TermCont s b Source # (<*) :: TermCont s a -> TermCont s b -> TermCont s a Source # | |
Functor (TermCont s) Source # | |
Monad (TermCont s) Source # | |
pguardC :: Term s PString -> Term s PBool -> TermCont s () Source #
Trace a message and raise error if cond
is false. Otherwise, continue.
Example ===
onlyAllow42 :: Term s (PInteger :--> PUnit) onlyAllow42 = plam $ i -> unTermCont $ do pguardC "expected 42" $ i #== 42 pure $ pconstant ()
pguardC' :: Term s a -> Term s PBool -> TermCont @a s () Source #
Stop computation and return given term if cond
is false. Otherwise, continue.
Example ===
is42 :: Term s (PInteger :--> PBool) is42 = plam $ i -> unTermCont $ do pguardC' (pconstant False) $ i #== 42 pure $ pconstant True
pletFieldsC :: forall fs a s b ps bs. (PDataFields a, ps ~ PFields a, bs ~ Bindings ps fs, BindFields ps bs) => Term s a -> TermCont @b s (HRec (BoundTerms ps bs s)) Source #
Like pletFields
but works in a TermCont
monad.
ptraceC :: Term s PString -> TermCont s () Source #
Like ptrace
but works in a TermCont
monad.
Example ===
foo :: Term s PUnit foo = unTermCont $ do ptraceC "returning unit!" pure $ pconstant ()
ptryFromC :: forall b r a s. PTryFrom a b => Term s a -> TermCont @r s (Term s b, Reduce (PTryFromExcess a b s)) Source #
Tracing
ptraceDebug :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a -> Term s a Source #
Trace the given message at the debug level before evaluating the given argument.
Since: 1.6.0
ptraceDebugError :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a Source #
Trace the given message at the debug level, then terminate with perror
.
Since: 1.6.0
ptraceDebugIfFalse :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool Source #
Trace the given message at the debug level if the argument is false.
Since: 1.6.0
ptraceDebugIfTrue :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool Source #
Trace the given message at the debug level if the argument is true.
Since: 1.6.0
ptraceDebugShowId :: forall (a :: S -> Type) (s :: S). PShow a => Term s a -> Term s a Source #
Like Haskell's traceShowId
but for Plutarch, at the debug level.
Since: 1.6.0
ptraceInfo :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a -> Term s a Source #
Trace the given message at the info level before evaluating the given argument.
Since: 1.6.0
ptraceInfoError :: forall (a :: S -> Type) (s :: S). Term s PString -> Term s a Source #
Trace the given message at the info level, then terminate with perror
.
Since: 1.6.0
ptraceInfoIfFalse :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool Source #
Trace the given message at the info level if the argument is false.
Since: 1.6.0
ptraceInfoIfTrue :: forall (s :: S). Term s PString -> Term s PBool -> Term s PBool Source #
Trace the given message at the info level if the argument is true.
Since: 1.6.0
ptraceInfoShowId :: forall (a :: S -> Type) (s :: S). PShow a => Term s a -> Term s a Source #
Like Haskell's traceShowId
but for Plutarch, at the info level.
Since: 1.6.0