| License | Apache-2.0 |
|---|---|
| Stability | provisional |
| Safe Haskell | None |
| Language | Haskell2010 |
HaskLedger.Contract
Description
Core types and control flow for defining Cardano validators.
Types
A named validator carrying the Covenant ASG builder for its on-chain code.
Constructors
| Validator | |
Fields | |
type Contract a = ASGBuilder a #
Monadic computation type for building contracts. Alias for Covenant's ASGBuilder.
Validator construction
validator :: String -> Contract Expr -> Validator #
Construct a Validator from a name and a contract body.
Control flow
require :: String -> Contract Condition -> Contract Expr #
Require a condition to be true; crash via division-by-zero if false.
Compiles to (\_ -> ()) (DivideInteger 1 (IfThenElse cond 1 0)).
Both IfThenElse branches are safe integer literals. The result becomes
the denominator - 1 when true (harmless), 0 when false (crash).
The wrapper discards the integer and returns Unit.
requireAll :: [(String, Contract Condition)] -> Contract Expr #
Require all conditions to be true, checked left to right.
First failure aborts. Conditions are sequenced with ChooseUnit
for left-to-right short-circuit evaluation.
Orphan instances
| Num (Contract Expr) # | Integer literals and arithmetic in contract expressions.
|
Methods (+) :: Contract Expr -> Contract Expr -> Contract Expr # (-) :: Contract Expr -> Contract Expr -> Contract Expr # (*) :: Contract Expr -> Contract Expr -> Contract Expr # negate :: Contract Expr -> Contract Expr # abs :: Contract Expr -> Contract Expr # signum :: Contract Expr -> Contract Expr # fromInteger :: Integer -> Contract Expr # | |