lorentz-0.15.1: EDSL for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lorentz.Macro

Description

Common Michelson macros defined using Lorentz syntax.

Synopsis

Compare

type NiceComparable n = (ProperNonComparableValBetterErrors (ToT n), KnownValue n, Comparable (ToT n)) Source #

Constraint applied to any type, to check if Michelson representation (if exists) of this type is Comparable. In case it is not prints human-readable error message

eq :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

neq :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

lt :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

gt :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

le :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

ge :: NiceComparable n => (n ': (n ': s)) :-> (Bool ': s) Source #

ifEq0 :: IfCmp0Constraints a Eq' => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifGe0 :: IfCmp0Constraints a Ge => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifGt0 :: IfCmp0Constraints a Gt => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifLe0 :: IfCmp0Constraints a Le => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifLt0 :: IfCmp0Constraints a Lt => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifNeq0 :: IfCmp0Constraints a Neq => (s :-> s') -> (s :-> s') -> (a ': s) :-> s' Source #

ifEq :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

ifGe :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

ifGt :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

ifLe :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

ifLt :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

ifNeq :: NiceComparable a => (s :-> s') -> (s :-> s') -> (a ': (a ': s)) :-> s' Source #

Fail

fail_ :: a :-> c Source #

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 UnspecifiedError, then FAILWITH will be called with unit.

assert :: IsError err => err -> (Bool ': s) :-> s Source #

assertEq0 :: (IfCmp0Constraints a Eq', IsError err) => err -> (a ': s) :-> s Source #

assertNeq0 :: (IfCmp0Constraints a Neq, IsError err) => err -> (a ': s) :-> s Source #

assertLt0 :: (IfCmp0Constraints a Lt, IsError err) => err -> (a ': s) :-> s Source #

assertGt0 :: (IfCmp0Constraints a Gt, IsError err) => err -> (a ': s) :-> s Source #

assertLe0 :: (IfCmp0Constraints a Le, IsError err) => err -> (a ': s) :-> s Source #

assertGe0 :: (IfCmp0Constraints a Ge, IsError err) => err -> (a ': s) :-> s Source #

assertEq :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertNeq :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertLt :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertGt :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertLe :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertGe :: (NiceComparable a, IsError err) => err -> (a ': (a ': s)) :-> s Source #

assertNone :: IsError err => err -> (Maybe a ': s) :-> s Source #

assertSome :: IsError err => err -> (Maybe a ': s) :-> (a ': s) Source #

assertLeft :: IsError err => err -> (Either a b ': s) :-> (a ': s) Source #

assertRight :: IsError err => err -> (Either a b ': s) :-> (b ': s) Source #

assertUsing :: IsError a => a -> (Bool ': s) :-> s Source #

Syntactic Conveniences

type ErrInstr s = forall serr. s :-> serr Source #

An instruction that always fails.

type ConstraintReplaceNLorentz (n :: Peano) (s :: [Type]) (a :: Type) (mid :: [Type]) (tail :: [Type]) = (ReplaceNConstraint' T n (ToTs s) (ToT a) (ToTs mid) (ToTs tail), ReplaceNConstraint' Type n s a mid tail) Source #

Constraint for replaceN that combines kind-agnostic constraint for Lorentz (Haskell) types and for our typed Michelson.

type ConstraintUpdateNLorentz (n :: Peano) (s :: [Type]) (a :: Type) (b :: Type) (mid :: [Type]) (tail :: [Type]) = (UpdateNConstraint' T n (ToTs s) (ToT a) (ToT b) (ToTs mid) (ToTs tail), UpdateNConstraint' Type n s a b mid tail) Source #

Constraint for updateN that combines kind-agnostic constraint for Lorentz (Haskell) types and for our typed Michelson.

class ReplaceN (n :: Peano) (s :: [Type]) (a :: Type) mid tail where Source #

Methods

replaceNImpl :: (a ': s) :-> s Source #

Instances

Instances details
s ~ (a ': xs) => ReplaceN ('S 'Z) s a (mid :: k1) (tail :: k2) Source # 
Instance details

Defined in Lorentz.Macro

Methods

replaceNImpl :: (a ': s) :-> s Source #

(ConstraintReplaceNLorentz ('S n) s a mid tail, SingI n) => ReplaceN ('S ('S n)) s a (mid :: [Type]) (tail :: [Type]) Source # 
Instance details

Defined in Lorentz.Macro

Methods

replaceNImpl :: (a ': s) :-> s Source #

class UpdateN (n :: Peano) (s :: [Type]) (a :: Type) (b :: Type) mid tail where Source #

Methods

updateNImpl :: ('[a, b] :-> '[b]) -> (a ': s) :-> s Source #

Instances

Instances details
s ~ (x ': (b ': tail)) => UpdateN ('S ('S 'Z)) s a b (mid :: k) (tail :: [Type]) Source # 
Instance details

Defined in Lorentz.Macro

Methods

updateNImpl :: ('[a, b] :-> '[b]) -> (a ': s) :-> s Source #

s ~ (b ': tail) => UpdateN ('S 'Z) s a b (mid :: k) (tail :: [Type]) Source # 
Instance details

Defined in Lorentz.Macro

Methods

updateNImpl :: ('[a, b] :-> '[b]) -> (a ': s) :-> s Source #

(ConstraintUpdateNLorentz ('S ('S n)) s a b mid tail, SingI n) => UpdateN ('S ('S ('S n))) s a b (mid :: [Type]) (tail :: [Type]) Source # 
Instance details

Defined in Lorentz.Macro

Methods

updateNImpl :: ('[a, b] :-> '[b]) -> (a ': s) :-> s Source #

dropX :: forall (n :: Nat) a inp out s s'. (ConstraintDIPNLorentz (ToPeano n) inp out s s', s ~ (a ': s'), SingIPeano n) => 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) :-> (a ': 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) a s s'. (ConstraintDUPNLorentz (ToPeano n) s s' a, Dupable a) => s :-> (a ': s) 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.

Note that DUU+P has since been added as the DUP n instruction and so this macro is defined simply as follows:

duupX = dupN @n

framedN :: forall n nNat s i i' o o'. (nNat ~ ToPeano n, i' ~ Take nNat i, s ~ Drop nNat i, i ~ (i' ++ s), o ~ (o' ++ s), KnownList i', KnownList o') => (i' :-> o') -> i :-> o Source #

Version of framed which accepts number of elements on input stack which should be preserved.

You can treat this macro as calling a Michelson function with given number of arguments.

Given a stack of 3 elements, >>> arg = (1 :: Integer) ::: (2 :: Integer) ::: (3 :: Integer)

framedN will have access to exactly the number of elements specified, >>> framedN 1 drop -$ arg 2 ::: 3 >>> framedN 1 (drop # drop) -$ arg ... ... error: ... Couldn't match type: '[] ... with: a0 : o'0 ...

When the number of elements is larger than the size of the stack, framedN will have access to all of them: >>> framedN @5 (drop # drop) -$ arg 3

But not more than there are on stack: >>> framedN @5 (drop # drop # drop # drop) -$ arg ... ... error: ... Couldn't match type ‘ZippedStackRepr a1 (ZippedStackRepr a0 out)’ ... with ‘Integer’ ...

carN :: forall (n :: Nat) (pair :: Type) (s :: [Type]). ConstraintPairGetLorentz ((2 * n) + 1) pair => (pair ': s) :-> (PairGetHs (ToPeano ((2 * n) + 1)) pair ': s) Source #

cdrN :: forall (n :: Nat) (pair :: Type) (s :: [Type]). ConstraintPairGetLorentz (2 * n) pair => (pair ': s) :-> (PairGetHs (ToPeano (2 * n)) pair ': s) Source #

caar :: (((a, b1), b2) ': s) :-> (a ': s) Source #

>>> caar == car # car
True
>>> caar -$ ((True, 1), ())
True

cadr :: (((a, b1), b2) ': s) :-> (b1 ': s) Source #

>>> cadr == car # cdr
True
>>> cadr -$ ((True, 1), ())
1

cdar :: ((a1, (a2, b)) ': s) :-> (a2 ': s) Source #

>>> cdar == cdr # car
True
>>> cdar -$ (True, (1, ()))
1

cddr :: ((a1, (a2, b)) ': s) :-> (b ': s) Source #

>>> cddr == cdr # cdr
True
>>> cddr -$ (True, (1, ()))
()

ifRight :: ((b ': s) :-> s') -> ((a ': s) :-> s') -> (Either a b ': s) :-> s' Source #

>>> ifRight (not @Bool) (dup @Integer # compare # eq0) == ifLeft (dup @Integer # compare # eq0) (not @Bool)
True
>>> ifRight not (dup # compare # eq0) -$ (Right True :: Either Integer Bool)
False
>>> ifRight not (dup # compare # eq0) -$ (Left 1 :: Either Integer Bool)
True

ifSome :: ((a ': s) :-> s') -> (s :-> s') -> (Maybe a ': s) :-> s' Source #

>>> ifSome (dup @Integer # compare # eq0) (push False) == ifNone (push False) (dup @Integer # compare # eq0)
True
>>> ifSome (dup # compare # eq0) (push False) -$ (Just 1 :: Maybe Integer)
True
>>> ifSome (dup # compare # eq0) (push False) -$ (Nothing :: Maybe Integer)
False

when_ :: (s :-> s) -> (Bool ': s) :-> s Source #

>>> when_ (push 5 # add @Integer @Integer) == if_ (push 5 # add @Integer @Integer) nop
True
>>> when_ (push 5 # add @Integer) -$ True ::: 3
8
>>> when_ (push 5 # add @Integer) -$ False ::: 3
3

unless_ :: (s :-> s) -> (Bool ': s) :-> s Source #

>>> unless_ (push 5 # add @Integer @Integer) == if_ nop (push 5 # add @Integer @Integer)
True
>>> unless_ (push 5 # add @Integer) -$ True ::: 3
3
>>> unless_ (push 5 # add @Integer) -$ False ::: 3
8

whenSome :: ((a ': s) :-> s) -> (Maybe a ': s) :-> s Source #

>>> whenSome drop == ifSome drop nop
True
>>> whenSome drop -$ Just 1 ::: ()
()

whenNone :: (s :-> (a ': s)) -> (Maybe a ': s) :-> (a ': s) Source #

>>> whenNone (push True) == ifNone (push True) nop
True
>>> whenNone (push 1) -$ (Nothing :: Maybe Integer)
1

mapCar :: (forall s0. (a ': s0) :-> (a1 ': s0)) -> ((a, b) ': s) :-> ((a1, b) ': s) Source #

>>> mapCar (not @Bool) == unpair # (not @Bool) # pair
True
>>> mapCar not -$ (True, 1)
(False,1)

mapCdr :: (forall s0. (b ': s0) :-> (b1 ': s0)) -> ((a, b) ': s) :-> ((a, b1) ': s) Source #

>>> mapCdr (not @Bool) == unpair # dip (not @Bool) # pair
True
>>> mapCdr not -$ (1, True)
(1,False)

papair :: (a ': (b ': (c ': s))) :-> (((a, b), c) ': s) Source #

>>> papair == pair # pair
True
>>> papair -$ True ::: 1 ::: ()
((True,1),())

ppaiir :: (a ': (b ': (c ': s))) :-> ((a, (b, c)) ': s) Source #

>>> ppaiir == dip pair # pair
True
>>> ppaiir -$ True ::: 1 ::: ()
(True,(1,()))

unpair :: ((a, b) ': s) :-> (a ': (b ': s)) Source #

setCar :: ((a, b1) ': (b2 ': s)) :-> ((b2, b1) ': s) Source #

>>> setCar == cdr # swap # pair
True
>>> setCar -$ (True, 1) ::: ()
((),1)

setCdr :: ((a, b1) ': (b2 ': s)) :-> ((a, b2) ': s) Source #

>>> setCdr == car # pair
True
>>> setCdr -$ (True, 1) ::: ()
(True,())

setInsert :: NiceComparable e => (e ': (Set e ': s)) :-> (Set e ': s) Source #

Insert given element into set.

This is a separate function from mapUpdate because stacks they operate with differ in length.

mapInsert :: (MapInstrs map, NiceComparable k) => (k ': (v ': (map k v ': s))) :-> (map k v ': s) Source #

Insert given element into map.

setInsertNew :: (NiceConstant err, NiceComparable e, Dupable e, Dupable (Set e)) => (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, IsoValue (map k v), NiceComparable k, NiceConstant e, Dupable k, KnownValue v) => (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, NiceComparable k, KnownValue v) => (k ': (map k v ': s)) :-> (map k v ': s) Source #

Delete element from the map.

setDelete :: NiceComparable e => (e ': (Set e ': s)) :-> (Set e ': s) Source #

Delete given element from the set.

replaceN :: forall (n :: Nat) a (s :: [Type]) (s1 :: [Type]) (tail :: [Type]). (ConstraintReplaceNLorentz (ToPeano (n - 1)) s a s1 tail, ReplaceN (ToPeano n) s a s1 tail) => (a ': s) :-> s Source #

Replace nth element (0-indexed) with the one on the top of the stack. For example, `replaceN 3` replaces the 3rd element with the 0th one. `replaceN 0` is not a valid operation (and it is not implemented). `replaceN 1` is equivalent to `swap # drop` (and is the only one implemented like this). In all other cases `replaceN n` will drop the nth element (`dipN n drop`) and then put the 0th one in its place (`dug (n-1)`).

updateN :: forall (n :: Nat) a b (s :: [Type]) (mid :: [Type]) (tail :: [Type]). (ConstraintUpdateNLorentz (ToPeano (n - 1)) s a b mid tail, UpdateN (ToPeano n) s a b mid tail) => ('[a, b] :-> '[b]) -> (a ': s) :-> s Source #

Replaces the nth element (0-indexed) with the result of the given "updating" instruction (binary with the return type equal to the second argument) applied to the 0th element and the nth element itself. For example, updateN @3 cons replaces the 3rd element with the result of cons applied to the topmost element and the 3rd one. updateN @0 instr is not a valid operation (and it is not implemented). updateN @1 instr is equivalent to instr (and so is implemented). updateN @2 instr is equivalent to swap # dip instr (and so is implemented). In all other cases updateN @n instr will put the topmost element right above the nth one (dug @(n-1)) and then apply the function to them in place (dipN @(n-1) instr).

Additional Morley macros

data View_ (a :: Type) (r :: Type) Source #

view type synonym as described in A1.

Constructors

View_ 

Instances

Instances details
(CanCastTo a1 a2, CanCastTo r1 r2) => CanCastTo (View_ a1 r1 :: Type) (View_ a2 r2 :: Type) Source # 
Instance details

Defined in Lorentz.Macro

Methods

castDummy :: Proxy (View_ a1 r1) -> Proxy (View_ a2 r2) -> () Source #

Generic (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type Rep (View_ a r) :: Type -> Type #

Methods

from :: View_ a r -> Rep (View_ a r) x #

to :: Rep (View_ a r) x -> View_ a r #

Show a => Show (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

showsPrec :: Int -> View_ a r -> ShowS #

show :: View_ a r -> String #

showList :: [View_ a r] -> ShowS #

(HasNoOpToT r, HasNoNestedBigMaps (ToT r)) => Buildable (View_ () r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

build :: View_ () r -> Builder #

(Buildable a, HasNoOpToT r, HasNoNestedBigMaps (ToT r)) => Buildable (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

build :: View_ a r -> Builder #

Eq a => Eq (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

(==) :: View_ a r -> View_ a r -> Bool #

(/=) :: View_ a r -> View_ a r -> Bool #

(HasAnnotation a, HasAnnotation r) => HasAnnotation (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

HasRPCRepr a => HasRPCRepr (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type AsRPC (View_ a r)

Each '[Typeable :: Type -> Constraint, TypeHasDoc] '[a, r] => TypeHasDoc (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type TypeDocFieldDescriptions (View_ a r) :: FieldDescriptions #

Methods

typeDocName :: Proxy (View_ a r) -> Text #

typeDocMdDescription :: Markdown #

typeDocMdReference :: Proxy (View_ a r) -> WithinParens -> Markdown #

typeDocDependencies :: Proxy (View_ a r) -> [SomeDocDefinitionItem] #

typeDocHaskellRep :: TypeDocHaskellRep (View_ a r) #

typeDocMichelsonRep :: TypeDocMichelsonRep (View_ a r) #

(HasNoOpToT r, HasNoNestedBigMaps (ToT r), WellTypedToT a) => IsoValue (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ToT (View_ a r) :: T #

Methods

toVal :: View_ a r -> Value (ToT (View_ a r)) #

fromVal :: Value (ToT (View_ a r)) -> View_ a r #

type Rep (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type Rep (View_ a r) = D1 ('MetaData "View_" "Lorentz.Macro" "lorentz-0.15.1-inplace" 'False) (C1 ('MetaCons "View_" 'PrefixI 'True) (S1 ('MetaSel ('Just "viewParam") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "viewCallbackTo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ContractRef r))))
type AsRPC (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type AsRPC (View_ a r) = View_ (AsRPC a) r
type TypeDocFieldDescriptions (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type TypeDocFieldDescriptions (View_ a r) = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT (View_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type ToT (View_ a r) = GValueType (Rep (View_ a r))

data Void_ (a :: Type) (b :: Type) Source #

void type synonym as described in A1.

Constructors

Void_ 

Fields

Instances

Instances details
(CanCastTo a1 a2, CanCastTo r1 r2) => CanCastTo (Void_ a1 r1 :: Type) (Void_ a2 r2 :: Type) Source # 
Instance details

Defined in Lorentz.Macro

Methods

castDummy :: Proxy (Void_ a1 r1) -> Proxy (Void_ a2 r2) -> () Source #

Generic (Void_ a b) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type Rep (Void_ a b) :: Type -> Type #

Methods

from :: Void_ a b -> Rep (Void_ a b) x #

to :: Rep (Void_ a b) x -> Void_ a b #

Show a => Show (Void_ a b) Source # 
Instance details

Defined in Lorentz.Macro

Methods

showsPrec :: Int -> Void_ a b -> ShowS #

show :: Void_ a b -> String #

showList :: [Void_ a b] -> ShowS #

Buildable a => Buildable (Void_ a b) Source # 
Instance details

Defined in Lorentz.Macro

Methods

build :: Void_ a b -> Builder #

(HasAnnotation a, HasAnnotation b) => HasAnnotation (Void_ a b) Source # 
Instance details

Defined in Lorentz.Macro

HasRPCRepr a => HasRPCRepr (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type AsRPC (Void_ a r)

Each '[Typeable :: Type -> Constraint, TypeHasDoc] '[a, r] => TypeHasDoc (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type TypeDocFieldDescriptions (Void_ a r) :: FieldDescriptions #

Methods

typeDocName :: Proxy (Void_ a r) -> Text #

typeDocMdDescription :: Markdown #

typeDocMdReference :: Proxy (Void_ a r) -> WithinParens -> Markdown #

typeDocDependencies :: Proxy (Void_ a r) -> [SomeDocDefinitionItem] #

typeDocHaskellRep :: TypeDocHaskellRep (Void_ a r) #

typeDocMichelsonRep :: TypeDocMichelsonRep (Void_ a r) #

(WellTypedToT r, WellTypedToT a) => IsoValue (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ToT (Void_ a r) :: T #

Methods

toVal :: Void_ a r -> Value (ToT (Void_ a r)) #

fromVal :: Value (ToT (Void_ a r)) -> Void_ a r #

type Rep (Void_ a b) Source # 
Instance details

Defined in Lorentz.Macro

type Rep (Void_ a b) = D1 ('MetaData "Void_" "Lorentz.Macro" "lorentz-0.15.1-inplace" 'False) (C1 ('MetaCons "Void_" 'PrefixI 'True) (S1 ('MetaSel ('Just "voidParam") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "voidResProxy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Lambda b b))))
type AsRPC (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type AsRPC (Void_ a r) = Void_ (AsRPC a) r
type TypeDocFieldDescriptions (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type TypeDocFieldDescriptions (Void_ a r) = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT (Void_ a r) Source # 
Instance details

Defined in Lorentz.Macro

type ToT (Void_ a r) = GValueType (Rep (Void_ a r))

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)`

This error is special - it can contain arguments of different types depending on entrypoint which raises it.

Constructors

VoidResult 

Fields

Instances

Instances details
Generic (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type Rep (VoidResult r) :: Type -> Type #

Methods

from :: VoidResult r -> Rep (VoidResult r) x #

to :: Rep (VoidResult r) x -> VoidResult r #

Eq r => Eq (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

(==) :: VoidResult r -> VoidResult r -> Bool #

(/=) :: VoidResult r -> VoidResult r -> Bool #

TypeHasDoc r => ErrorHasDoc (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ErrorRequirements (VoidResult r) Source #

(NiceConstant r, ErrorHasDoc (VoidResult r)) => IsError (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Methods

errorToVal :: VoidResult r -> (forall (t :: T). ErrorScope t => Value t -> r0) -> r0 Source #

errorFromVal :: forall (t :: T). SingI t => Value t -> Either Text (VoidResult r) Source #

failUsing :: forall (s :: [Type]) (t :: [Type]). IsError (VoidResult r) => VoidResult r -> s :-> t Source #

(TypeHasDoc r, IsError (VoidResult r)) => TypeHasDoc (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type TypeDocFieldDescriptions (VoidResult r) :: FieldDescriptions #

(Bottom, WellTypedToT (VoidResult r), TypeError ('Text "No IsoValue instance for VoidResult " :<>: 'ShowType r) :: Constraint) => IsoValue (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ToT (VoidResult r) :: T #

type Rep (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

type Rep (VoidResult r) = D1 ('MetaData "VoidResult" "Lorentz.Macro" "lorentz-0.15.1-inplace" 'True) (C1 ('MetaCons "VoidResult" 'PrefixI 'True) (S1 ('MetaSel ('Just "unVoidResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 r)))
type ErrorRequirements (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

type TypeDocFieldDescriptions (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

type ToT (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

type ToT (VoidResult r) = TypeError ('Text "No IsoValue instance for VoidResult " :<>: 'ShowType r) :: T

view_ :: (NiceParameter r, Dupable storage, IsNotInView) => (forall s0. (a ': (storage ': s0)) :-> (r ': s0)) -> (View_ a r ': (storage ': s)) :-> ((List Operation, storage) ': s) Source #

mkView_ :: ToContractRef r contract => a -> contract -> View_ a r Source #

Polymorphic version of View_ constructor.

wrapView_ :: ((a, ContractRef r) ': s) :-> (View_ a r ': s) Source #

Wrap internal representation of view into View_ itself.

View_ is part of public standard and should not change often.

unwrapView_ :: (View_ a r ': s) :-> ((a, ContractRef r) ': s) Source #

Unwrap View_ into its internal representation.

View_ is part of public standard and should not change often.

void_ :: forall a b s s' anything. (IsError (VoidResult b), NiceConstant b) => ((a ': s) :-> (b ': s')) -> (Void_ a b ': s) :-> anything Source #

mkVoid :: forall b a. a -> Void_ a b Source #

wrapVoid :: ((a, Lambda b b) ': s) :-> (Void_ a b ': s) Source #

Wrap internal representation of void into Void_ itself.

Void_ is part of public standard and should not change often.

unwrapVoid :: (Void_ a b ': s) :-> ((a, Lambda b b) ': s) Source #

Unwrap Void_ into its internal representation.

Void_ is part of public standard and should not change often.

dupTop2 :: forall (a :: Type) (b :: Type) (s :: [Type]). (Dupable a, Dupable b) => (a ': (b ': s)) :-> (a ': (b ': (a ': (b ': s)))) Source #

Duplicate two topmost items on top of the stack.

fromOption :: NiceConstant a => a -> (Maybe a ': s) :-> (a ': s) Source #

isSome :: (Maybe a ': s) :-> (Bool ': s) Source #

non :: (NiceConstant a, NiceComparable a) => a -> (a ': s) :-> (Maybe a ': s) Source #

Retain the value if it is not equal to the given one.

>>> non 0 -$ 5
Just 5
>>> non 0 -$ 0
Nothing

non' :: NiceConstant a => ('[a] :-> '[Bool]) -> (a ': s) :-> (Maybe a ': s) Source #

Version of non with a custom predicate.

>>> non' eq0 -$ 5
Just 5
>>> non' eq0 -$ 0
Nothing

isEmpty :: SizeOpHs c => (c ': s) :-> (Bool ': s) Source #

Check whether container is empty.

class NonZero t where Source #

Methods

nonZero :: (t ': s) :-> (Maybe t ': s) Source #

Retain the value only if it is not zero.

Instances

Instances details
NonZero Integer Source # 
Instance details

Defined in Lorentz.Macro

Methods

nonZero :: forall (s :: [Type]). (Integer ': s) :-> (Maybe Integer ': s) Source #

NonZero Natural Source # 
Instance details

Defined in Lorentz.Macro

Methods

nonZero :: forall (s :: [Type]). (Natural ': s) :-> (Maybe Natural ': s) Source #

NiceComparable d => NonZero (Ticket d) Source # 
Instance details

Defined in Lorentz.Macro

Methods

nonZero :: forall (s :: [Type]). (Ticket d ': s) :-> (Maybe (Ticket d) ': s) Source #

(NiceComparable d, Typeable k, Typeable action) => NonZero (STicket action d) Source # 
Instance details

Defined in Lorentz.Tickets

Methods

nonZero :: forall (s :: [Type]). (STicket action d ': s) :-> (Maybe (STicket action d) ': s) Source #

Buildable utils for additional Morley macros

buildView_ :: (HasNoOpToT r, HasNoNestedBigMaps (ToT r)) => (a -> Builder) -> View_ a r -> Builder Source #

buildViewTuple_ :: (HasNoOpToT r, HasNoNestedBigMaps (ToT r), TupleF a) => View_ a r -> Builder Source #

Macros for working with address and contract-like types

pushContractRef :: NiceParameter arg => (forall s0. (FutureContract arg ': s) :-> s0) -> ContractRef arg -> s :-> (ContractRef arg ': s) Source #

Push a value of contract type.

Doing this via push instruction is not possible, so we need to perform extra actions here.

Aside from contract value itself you will need to specify which error to throw in case this value is not valid.

view :: forall name arg ret p vd s. (HasCallStack, KnownSymbol name, KnownValue arg, NiceViewable ret, HasView vd name arg ret) => (arg ': (TAddress p vd ': s)) :-> (ret ': s) Source #

Call a view.

Accepts the view name via a type annotation. This internally asserts the view to be present, as if the supplied TAddress argument is valid, the view is guaranteed to be called successfully.

Integer division

data IDiv Source #

Michelson supports only EDiv, which gives both the quotient and the remainder for integers. For convenience, we also offer IDiv, which gives just the quotient.

Instances

Instances details
(ArithOpHs EDiv n d (Maybe (q, r)), mq ~ Maybe q, KnownValue q) => ArithOpHs IDiv n d mq Source # 
Instance details

Defined in Lorentz.Macro

Methods

evalArithOpHs :: forall (s :: [Type]). (n ': (d ': s)) :-> (mq ': s) Source #

data IMod Source #

Michelson supports only EDiv, which gives both the quotient and the remainder for integers. For convenience, we also offer IMod, which gives just the remainder.

Instances

Instances details
(ArithOpHs EDiv n d (Maybe (q, r)), mr ~ Maybe r, KnownValue r) => ArithOpHs IMod n d mr Source # 
Instance details

Defined in Lorentz.Macro

Methods

evalArithOpHs :: forall (s :: [Type]). (n ': (d ': s)) :-> (mr ': s) Source #

idiv :: ArithOpHs IDiv n d q => (n ': (d ': s)) :-> (q ': s) Source #

Integer division.

>>> idiv -$ (5 :: Integer) ::: (2 :: Integer)
Just 2
>>> idiv -$ (5 :: Integer) ::: (0 :: Integer)
Nothing

imod :: ArithOpHs IMod n d r => (n ': (d ': s)) :-> (r ': s) Source #

Integer modulus.

>>> imod -$ (5 :: Integer) ::: (2 :: Integer)
Just 1
>>> imod -$ (5 :: Integer) ::: (0 :: Integer)
Nothing

Orphan instances