Safe Haskell | None |
---|---|
Language | Haskell2010 |
Common Michelson macros defined using Lorentz syntax.
Synopsis
- type IfCmpXConstraints a b op = (Typeable a, Typeable b, ArithOpHs Compare a b, UnaryArithOpHs op (ArithResHs Compare a b), UnaryArithResHs op (ArithResHs Compare a b) ~ Bool)
- eq :: (ArithOpHs Compare n m, UnaryArithOpHs Eq' (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Eq' (ArithResHs Compare n m) & s)
- neq :: (ArithOpHs Compare n m, UnaryArithOpHs Neq (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Neq (ArithResHs Compare n m) & s)
- lt :: (ArithOpHs Compare n m, UnaryArithOpHs Lt (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Lt (ArithResHs Compare n m) & s)
- gt :: (ArithOpHs Compare n m, UnaryArithOpHs Gt (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Gt (ArithResHs Compare n m) & s)
- le :: (ArithOpHs Compare n m, UnaryArithOpHs Le (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Le (ArithResHs Compare n m) & s)
- ge :: (ArithOpHs Compare n m, UnaryArithOpHs Ge (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Ge (ArithResHs Compare n m) & s)
- ifEq0 :: IfCmp0Constraints a Eq' => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifGe0 :: IfCmp0Constraints a Ge => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifGt0 :: IfCmp0Constraints a Gt => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifLe0 :: IfCmp0Constraints a Le => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifLt0 :: IfCmp0Constraints a Lt => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifNeq0 :: IfCmp0Constraints a Neq => (s :-> s') -> (s :-> s') -> (a & s) :-> s'
- ifEq :: IfCmpXConstraints a b Eq' => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- ifGe :: IfCmpXConstraints a b Ge => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- ifGt :: IfCmpXConstraints a b Gt => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- ifLe :: IfCmpXConstraints a b Le => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- ifLt :: IfCmpXConstraints a b Lt => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- ifNeq :: IfCmpXConstraints a b Neq => (s :-> s') -> (s :-> s') -> (a & (b & s)) :-> s'
- fail_ :: a :-> c
- assert :: MText -> (Bool & s) :-> s
- assertEq0 :: IfCmp0Constraints a Eq' => MText -> (a & s) :-> s
- assertNeq0 :: IfCmp0Constraints a Neq => MText -> (a & s) :-> s
- assertLt0 :: IfCmp0Constraints a Lt => MText -> (a & s) :-> s
- assertGt0 :: IfCmp0Constraints a Gt => MText -> (a & s) :-> s
- assertLe0 :: IfCmp0Constraints a Le => MText -> (a & s) :-> s
- assertGe0 :: IfCmp0Constraints a Ge => MText -> (a & s) :-> s
- assertEq :: IfCmpXConstraints a b Eq' => MText -> (a & (b & s)) :-> s
- assertNeq :: IfCmpXConstraints a b Neq => MText -> (a & (b & s)) :-> s
- assertLt :: IfCmpXConstraints a b Lt => MText -> (a & (b & s)) :-> s
- assertGt :: IfCmpXConstraints a b Gt => MText -> (a & (b & s)) :-> s
- assertLe :: IfCmpXConstraints a b Le => MText -> (a & (b & s)) :-> s
- assertGe :: IfCmpXConstraints a b Ge => MText -> (a & (b & s)) :-> s
- assertNone :: MText -> (Maybe a & s) :-> s
- assertSome :: MText -> (Maybe a & s) :-> (a & s)
- assertLeft :: MText -> (Either a b & s) :-> (a & s)
- assertRight :: MText -> (Either a b & s) :-> (b & s)
- assertUsing :: (IsoValue a, KnownValue a, NoOperation a, NoBigMap a) => a -> (Bool & s) :-> s
- dipX :: forall (n :: Nat) inp out s s'. (DipX (ToPeano n) (Above (ToPeano n) inp) s s', (Above (ToPeano n) inp ++ s) ~ inp, (Above (ToPeano n) inp ++ s') ~ out) => (s :-> s') -> inp :-> out
- dropX :: forall (n :: Nat) a inp out s s'. (DipX (ToPeano n) (Above (ToPeano n) inp) s s', (Above (ToPeano n) inp ++ s) ~ inp, (Above (ToPeano n) inp ++ s') ~ out, s ~ (a ': s')) => inp :-> out
- cloneX :: forall (n :: Nat) a s. CloneX (ToPeano n) a s => (a & s) :-> CloneXT (ToPeano n) a s
- duupX :: forall (n :: Nat) inp. DuupX (ToPeano n) inp (At (ToPeano (n - 1)) inp) => inp :-> (At (ToPeano (n - 1)) inp & inp)
- elevateX :: forall (n :: Nat) inp out s a. (DuupX (ToPeano (1 + n)) inp a, DipX (ToPeano (n + 1)) (Above (ToPeano (n + 1)) (a ': inp)) (a ': s) s, (a ': (Above (ToPeano n) inp ++ s)) ~ out, a ~ At (ToPeano n) inp, (Above (ToPeano (n + 1)) (a ': inp) ++ (a ': s)) ~ (a ': inp), (Above (ToPeano (n + 1)) (a ': inp) ++ s) ~ (a ': (Above (ToPeano n) inp ++ s)), ((1 + n) - 1) ~ n) => inp :-> out
- caar :: (((a, b1), b2) & s) :-> (a & s)
- cadr :: (((a, b1), b2) & s) :-> (b1 & s)
- cdar :: ((a1, (a2, b)) & s) :-> (a2 & s)
- cddr :: ((a1, (a2, b)) & s) :-> (b & s)
- ifRight :: ((b & s) :-> s') -> ((a & s) :-> s') -> (Either a b & s) :-> s'
- ifSome :: ((a & s) :-> s') -> (s :-> s') -> (Maybe a & s) :-> s'
- mapCar :: ((a & s) :-> (a1 & s)) -> ((a, b) & s) :-> ((a1, b) & s)
- mapCdr :: ((b & ((a, b) & s)) :-> (b1 & ((a, b) & s))) -> ((a, b) & s) :-> ((a, b1) & s)
- papair :: (a & (b & (c & s))) :-> (((a, b), c) & s)
- ppaiir :: (a & (b & (c & s))) :-> ((a, (b, c)) & s)
- unpair :: ((a, b) & s) :-> (a & (b & s))
- setCar :: ((a, b1) & (b2 & s)) :-> ((b2, b1) & s)
- setCdr :: ((a, b1) & (b2 & s)) :-> ((a, b2) & s)
- setInsert :: IsComparable e => (e & (Set e & s)) :-> (Set e & s)
- mapInsert :: (MapInstrs map, IsComparable k) => (k ': (v ': (map k v ': s))) :-> (map k v ': s)
- setInsertNew :: (IsComparable e, KnownValue err) => (forall s0. (e ': s0) :-> (err ': s0)) -> (e & (Set e & s)) :-> (Set e & s)
- mapInsertNew :: (MapInstrs map, IsComparable k, KnownValue e) => (forall s0. (k ': s0) :-> (e ': s0)) -> (k ': (v ': (map k v ': s))) :-> (map k v ': s)
- deleteMap :: forall k v s. (MapInstrs map, IsComparable k, KnownValue k, KnownValue v) => (k ': (map k v ': s)) :-> (map k v ': s)
- setDelete :: IsComparable e => (e & (Set e & s)) :-> (Set e & s)
- data View (a :: Type) (r :: Type) = View {
- viewParam :: a
- viewCallbackTo :: ContractAddr (a, Maybe r)
- data Void_ (a :: Type) (b :: Type) = Void_ {
- voidParam :: a
- voidResProxy :: Lambda b b
- newtype VoidResult r = VoidResult {
- unVoidResult :: r
- view_ :: (KnownValue a, KnownValue r, NoOperation (a, r), NoBigMap (a, r)) => (forall s0. ((a, storage) & s0) :-> (r ': s0)) -> (View a r & (storage & s)) :-> ((List Operation, storage) & s)
- void_ :: forall a b s s' anything. KnownValue b => ((a & s) :-> (b & s')) -> (Void_ a b & s) :-> anything
- mkVoid :: forall b a. a -> Void_ a b
Compare
type IfCmpXConstraints a b op = (Typeable a, Typeable b, ArithOpHs Compare a b, UnaryArithOpHs op (ArithResHs Compare a b), UnaryArithResHs op (ArithResHs Compare a b) ~ Bool) Source #
eq :: (ArithOpHs Compare n m, UnaryArithOpHs Eq' (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Eq' (ArithResHs Compare n m) & s) Source #
neq :: (ArithOpHs Compare n m, UnaryArithOpHs Neq (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Neq (ArithResHs Compare n m) & s) Source #
lt :: (ArithOpHs Compare n m, UnaryArithOpHs Lt (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Lt (ArithResHs Compare n m) & s) Source #
gt :: (ArithOpHs Compare n m, UnaryArithOpHs Gt (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Gt (ArithResHs Compare n m) & s) Source #
le :: (ArithOpHs Compare n m, UnaryArithOpHs Le (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Le (ArithResHs Compare n m) & s) Source #
ge :: (ArithOpHs Compare n m, UnaryArithOpHs Ge (ArithResHs Compare n m)) => (n & (m & s)) :-> (UnaryArithResHs Ge (ArithResHs Compare n m) & s) Source #
Fail
Warning: fail_
remains in code
Analog of the FAIL macro in Michelson. Its usage is discouraged because it doesn't carry any information about failure.
Assertion macros
They differ from the same macros in Michelson, because those macros use FAIL macro which is not informative (fails with unit). If you really want Michelson versions (maybe to produce exact copy of an existing contract), you can pass empty string, then FAILWITH will be called with unit, not empty string.
assertUsing :: (IsoValue a, KnownValue a, NoOperation a, NoBigMap a) => a -> (Bool & s) :-> s Source #
Syntactic Conveniences
dipX :: forall (n :: Nat) inp out s s'. (DipX (ToPeano n) (Above (ToPeano n) inp) s s', (Above (ToPeano n) inp ++ s) ~ inp, (Above (ToPeano n) inp ++ s') ~ out) => (s :-> s') -> inp :-> out Source #
DII+P
macro. For example, `dipX @3` is DIIIP
.
dropX :: forall (n :: Nat) a inp out s s'. (DipX (ToPeano n) (Above (ToPeano n) inp) s s', (Above (ToPeano n) inp ++ s) ~ inp, (Above (ToPeano n) inp ++ s') ~ out, s ~ (a ': s')) => inp :-> out Source #
Custom Lorentz macro that drops element with given index (starting from 0) from the stack.
cloneX :: forall (n :: Nat) a s. CloneX (ToPeano n) a s => (a & s) :-> CloneXT (ToPeano n) a s Source #
Duplicate the top of the stack n
times.
For example, `cloneX @3` has type `a & s :-> a & a & a & a & s`.
duupX :: forall (n :: Nat) inp. DuupX (ToPeano n) inp (At (ToPeano (n - 1)) inp) => inp :-> (At (ToPeano (n - 1)) inp & inp) Source #
DUU+P
macro. For example, `duupX @3` is DUUUP
, it puts
the 3-rd (starting from 1) element to the top of the stack.
elevateX :: forall (n :: Nat) inp out s a. (DuupX (ToPeano (1 + n)) inp a, DipX (ToPeano (n + 1)) (Above (ToPeano (n + 1)) (a ': inp)) (a ': s) s, (a ': (Above (ToPeano n) inp ++ s)) ~ out, a ~ At (ToPeano n) inp, (Above (ToPeano (n + 1)) (a ': inp) ++ (a ': s)) ~ (a ': inp), (Above (ToPeano (n + 1)) (a ': inp) ++ s) ~ (a ': (Above (ToPeano n) inp ++ s)), ((1 + n) - 1) ~ n) => inp :-> out Source #
Move item with given index (starting from 0) to the top of the stack.
TODO: probably it can be implemented more efficiently, so if we ever want to optimize gas consumption we can rewrite it. It only makes sense if it's applied to a relatively large index.
setInsert :: IsComparable e => (e & (Set e & s)) :-> (Set e & s) Source #
Insert given element into set.
This is a separate function from updateMap
because stacks they operate with
differ in length.
mapInsert :: (MapInstrs map, IsComparable k) => (k ': (v ': (map k v ': s))) :-> (map k v ': s) Source #
Insert given element into map.
setInsertNew :: (IsComparable e, KnownValue err) => (forall s0. (e ': s0) :-> (err ': s0)) -> (e & (Set e & s)) :-> (Set e & s) Source #
Insert given element into set, ensuring that it does not overwrite any existing entry.
As first argument accepts container name.
mapInsertNew :: (MapInstrs map, IsComparable k, KnownValue e) => (forall s0. (k ': s0) :-> (e ': s0)) -> (k ': (v ': (map k v ': s))) :-> (map k v ': s) Source #
Insert given element into map, ensuring that it does not overwrite any existing entry.
As first argument accepts container name (for error message).
deleteMap :: forall k v s. (MapInstrs map, IsComparable k, KnownValue k, KnownValue v) => (k ': (map k v ': s)) :-> (map k v ': s) Source #
Delete element from the map.
setDelete :: IsComparable e => (e & (Set e & s)) :-> (Set e & s) Source #
Delete given element from the set.
Additional Morley macros
data View (a :: Type) (r :: Type) Source #
view
type synonym as described in A1.
View | |
|
Instances
Generic (View a r) Source # | |
IsoValue a => IsoValue (View a r) Source # | |
type Rep (View a r) Source # | |
Defined in Lorentz.Macro type Rep (View a r) = D1 (MetaData "View" "Lorentz.Macro" "morley-0.3.0.1-Avb9bjjqJWNEobyGi9OGAh" False) (C1 (MetaCons "View" PrefixI True) (S1 (MetaSel (Just "viewParam") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Just "viewCallbackTo") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ContractAddr (a, Maybe r))))) | |
type ToT (View a r) Source # | |
Defined in Lorentz.Macro |
data Void_ (a :: Type) (b :: Type) Source #
void
type synonym as described in A1.
Void_ | |
|
Instances
Generic (Void_ a b) Source # | |
IsoValue a => IsoValue (Void_ a b) Source # | |
type Rep (Void_ a b) Source # | |
Defined in Lorentz.Macro type Rep (Void_ a b) = D1 (MetaData "Void_" "Lorentz.Macro" "morley-0.3.0.1-Avb9bjjqJWNEobyGi9OGAh" False) (C1 (MetaCons "Void_" PrefixI True) (S1 (MetaSel (Just "voidParam") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Just "voidResProxy") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Lambda b b)))) | |
type ToT (Void_ a b) Source # | |
Defined in Lorentz.Macro |
newtype VoidResult r Source #
Newtype over void result type used in tests to distinguish successful void result from other errors.
Usage example: lExpectFailWith (== VoidResult roleMaster)`
VoidResult | |
|
Instances
Eq r => Eq (VoidResult r) Source # | |
Defined in Lorentz.Macro (==) :: VoidResult r -> VoidResult r -> Bool # (/=) :: VoidResult r -> VoidResult r -> Bool # | |
IsoValue r => IsoValue (VoidResult r) Source # | |
Defined in Lorentz.Macro type ToT (VoidResult r) :: T Source # toVal :: VoidResult r -> Value (ToT (VoidResult r)) Source # fromVal :: Value (ToT (VoidResult r)) -> VoidResult r Source # | |
type ToT (VoidResult r) Source # | |
Defined in Lorentz.Macro |
view_ :: (KnownValue a, KnownValue r, NoOperation (a, r), NoBigMap (a, r)) => (forall s0. ((a, storage) & s0) :-> (r ': s0)) -> (View a r & (storage & s)) :-> ((List Operation, storage) & s) Source #