Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module, containing some boilerplate for support of arithmetic operations in Michelson language.
Synopsis
- class ArithOp aop (n :: T) (m :: T) where
- type ArithRes aop n m :: T
- convergeArith :: proxy aop -> Notes n -> Notes m -> Either AnnConvergeError (Notes (ArithRes aop n m))
- evalOp :: proxy aop -> Value' instr n -> Value' instr m -> Either (ArithError (Value' instr n) (Value' instr m)) (Value' instr (ArithRes aop n m))
- commutativityProof :: Maybe $ Dict (ArithRes aop n m ~ ArithRes aop m n, ArithOp aop m n)
- class UnaryArithOp aop (n :: T) where
- type UnaryArithRes aop n :: T
- evalUnaryArithOp :: proxy aop -> Value' instr n -> Value' instr (UnaryArithRes aop n)
- data ArithError n m
- data ShiftArithErrorType
- data MutezArithErrorType
- data Add
- data Sub
- data Mul
- data Abs
- data Neg
- data Or
- data And
- data Xor
- data Not
- data Lsl
- data Lsr
- data Compare
- data Eq'
- data Neq
- data Lt
- data Gt
- data Le
- data Ge
- compareOp :: forall t i. (Comparable t, SingI t) => Value' i t -> Value' i t -> Integer
Documentation
class ArithOp aop (n :: T) (m :: T) where Source #
Class for binary arithmetic operation.
Takes binary operation marker as op
parameter,
types of left operand n
and right operand m
.
type ArithRes aop n m :: T Source #
Type family ArithRes
denotes the type resulting from
computing operation op
from operands of types n
and m
.
For instance, adding integer to natural produces integer,
which is reflected in following instance of type family:
ArithRes Add CNat CInt = CInt
.
convergeArith :: proxy aop -> Notes n -> Notes m -> Either AnnConvergeError (Notes (ArithRes aop n m)) Source #
Converge the notes of given operands.
evalOp :: proxy aop -> Value' instr n -> Value' instr m -> Either (ArithError (Value' instr n) (Value' instr m)) (Value' instr (ArithRes aop n m)) Source #
Evaluate arithmetic operation on given operands.
commutativityProof :: Maybe $ Dict (ArithRes aop n m ~ ArithRes aop m n, ArithOp aop m n) Source #
An operation can marked as commutative, it does not affect its runtime behavior, but enables certain optimization in the optimizer. We conservatively consider operations non-commutative by default.
Note that there is one unusual case: AND
works with int : nat
but not with nat : int
. That's how it's specified in Michelson.
Instances
class UnaryArithOp aop (n :: T) where Source #
Marker data type for add operation.
type UnaryArithRes aop n :: T Source #
evalUnaryArithOp :: proxy aop -> Value' instr n -> Value' instr (UnaryArithRes aop n) Source #
Instances
UnaryArithOp Ge 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Le 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Gt 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Lt 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Neq 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Eq' 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Not 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Not 'TNat Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Not 'TBool Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Neg 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Neg 'TNat Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Abs 'TInt Source # | |
Defined in Michelson.Typed.Arith |
data ArithError n m Source #
Represents an arithmetic error of the operation.
Instances
data ShiftArithErrorType Source #
Denotes the error type occurred in the arithmetic shift operation.
Instances
data MutezArithErrorType Source #
Denotes the error type occurred in the arithmetic operation involving mutez.
Instances
Instances
Instances
Instances
Instances
UnaryArithOp Abs 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Abs 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Neg 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Neg 'TNat Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Neg 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Neg 'TNat Source # | |
Defined in Michelson.Typed.Arith |
Instances
Instances
Instances
Instances
UnaryArithOp Not 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Not 'TNat Source # | |
Defined in Michelson.Typed.Arith | |
UnaryArithOp Not 'TBool Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Not 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Not 'TNat Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Not 'TBool Source # | |
Defined in Michelson.Typed.Arith |
Instances
ArithOp Lsl 'TNat 'TNat Source # | |
Defined in Michelson.Typed.Arith convergeArith :: proxy Lsl -> Notes 'TNat -> Notes 'TNat -> Either AnnConvergeError (Notes (ArithRes Lsl 'TNat 'TNat)) Source # evalOp :: forall proxy (instr :: [T] -> [T] -> Type). proxy Lsl -> Value' instr 'TNat -> Value' instr 'TNat -> Either (ArithError (Value' instr 'TNat) (Value' instr 'TNat)) (Value' instr (ArithRes Lsl 'TNat 'TNat)) Source # commutativityProof :: Maybe $ Dict (ArithRes Lsl 'TNat 'TNat ~ ArithRes Lsl 'TNat 'TNat, ArithOp Lsl 'TNat 'TNat) Source # | |
type ArithRes Lsl 'TNat 'TNat Source # | |
Instances
ArithOp Lsr 'TNat 'TNat Source # | |
Defined in Michelson.Typed.Arith convergeArith :: proxy Lsr -> Notes 'TNat -> Notes 'TNat -> Either AnnConvergeError (Notes (ArithRes Lsr 'TNat 'TNat)) Source # evalOp :: forall proxy (instr :: [T] -> [T] -> Type). proxy Lsr -> Value' instr 'TNat -> Value' instr 'TNat -> Either (ArithError (Value' instr 'TNat) (Value' instr 'TNat)) (Value' instr (ArithRes Lsr 'TNat 'TNat)) Source # commutativityProof :: Maybe $ Dict (ArithRes Lsr 'TNat 'TNat ~ ArithRes Lsr 'TNat 'TNat, ArithOp Lsr 'TNat 'TNat) Source # | |
type ArithRes Lsr 'TNat 'TNat Source # | |
Instances
UnaryArithOp Eq' 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Eq' 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Neq 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Neq 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Lt 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Lt 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Gt 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Gt 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Le 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Le 'TInt Source # | |
Defined in Michelson.Typed.Arith |
Instances
UnaryArithOp Ge 'TInt Source # | |
Defined in Michelson.Typed.Arith | |
type UnaryArithRes Ge 'TInt Source # | |
Defined in Michelson.Typed.Arith |