| License | Apache-2.0 |
|---|---|
| Stability | provisional |
| Safe Haskell | None |
| Language | Haskell2010 |
HaskLedger.Combinators
Description
Combinators and operators for accessing ledger data and expressing conditions within a HaskLedger contract.
All combinators take monadic Contract Expr arguments so let-bindings
work naturally in do blocks.
Synopsis
- theRedeemer :: Contract Expr
- theTxInfo :: Contract Expr
- txValidRange :: Contract Expr
- (.==) :: Contract Expr -> Contract Expr -> Contract Condition
- (./=) :: Contract Expr -> Contract Expr -> Contract Condition
- (.<) :: Contract Expr -> Contract Expr -> Contract Condition
- (.<=) :: Contract Expr -> Contract Expr -> Contract Condition
- (.>) :: Contract Expr -> Contract Expr -> Contract Condition
- (.>=) :: Contract Expr -> Contract Expr -> Contract Condition
- (.&&) :: Contract Condition -> Contract Condition -> Contract Condition
- (.||) :: Contract Condition -> Contract Condition -> Contract Condition
- scriptContext :: Contract Expr
- txInfo :: Contract Expr -> Contract Expr
- redeemer :: Contract Expr -> Contract Expr
- validRange :: Contract Expr -> Contract Expr
- asInt :: Contract Expr -> Contract Expr
- mkInt :: Integer -> Contract Expr
- equalsInt :: Contract Expr -> Contract Expr -> Contract Condition
- lessThanInt :: Contract Expr -> Contract Expr -> Contract Condition
- lessThanEqInt :: Contract Expr -> Contract Expr -> Contract Condition
- after :: Contract Expr -> Contract Expr -> Contract Condition
- andBool :: Contract Condition -> Contract Condition -> Contract Condition
- orBool :: Contract Condition -> Contract Condition -> Contract Condition
- notBool :: Contract Condition -> Contract Condition
Convenience combinators
theRedeemer :: Contract Expr #
The redeemer from the script context, as raw Data.
txValidRange :: Contract Expr #
The transaction validity range (Interval POSIXTime), as raw Data.
Operators
(.==) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer equality (EqualsInteger).
(./=) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer inequality. notBool (a .== b).
(.<) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer strict less-than (LessThanInteger).
(.<=) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer less-than-or-equal (LessThanEqualsInteger).
(.>) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer strict greater-than. flip (.<).
(.>=) :: Contract Expr -> Contract Expr -> Contract Condition infix 4 #
Integer greater-than-or-equal. flip (.<=).
(.&&) :: Contract Condition -> Contract Condition -> Contract Condition infixr 3 #
Logical AND. Compiles to IfThenElse a b False. Both operands evaluated eagerly.
(.||) :: Contract Condition -> Contract Condition -> Contract Condition infixr 2 #
Logical OR. Compiles to IfThenElse a True b. Both operands evaluated eagerly.
Script context access
scriptContext :: Contract Expr #
The raw script context Data - the single argument to every PlutusV3 validator.
TxInfo field access
Data conversion
mkInt :: Integer -> Contract Expr #
Construct an on-chain integer literal. Usually unnecessary - the
Num instance lets you write 42 directly.
Integer comparisons
lessThanEqInt :: Contract Expr -> Contract Expr -> Contract Condition #
LessThanEqualsInteger. Prefer .<=.
Time range operations
after :: Contract Expr -> Contract Expr -> Contract Condition #
Check that a validity range starts at or after a deadline.
The deadline is a POSIX timestamp in milliseconds (Cardano's on-chain unit).
Walks the Interval POSIXTime encoding to extract the lower bound,
reads the closure flag, and compares against the deadline. Closed (inclusive)
bounds check deadline <= time; open (exclusive) bounds check
deadline <= time + 1. Non-finite bounds (NegInf, PosInf) crash
at runtime, which is the correct rejection for a deadline validator.
Boolean combinators
andBool :: Contract Condition -> Contract Condition -> Contract Condition #
Logical AND. IfThenElse a b False. Both operands evaluated eagerly.
For short-circuit semantics, use requireAll instead.