-- SPDX-FileCopyrightText: 2020 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

-- | All the basic 'Expr'essions used in Indigo code.
--
-- Note: infix operators acting on structure follow a naming convention:
--
-- 1. the last character identifies the structure type:
--
--      - @:@ for containers ('Map', 'BigMap', 'Set', 'List')
--      - @\@@ for 'UStore'
--      - @!@ for 'HasField'
--      - @~@ fot 'Util.Named'
--
-- 2. the preceding characters identify the action:
--
--      - @#@ for get, lookup or from
--      - @!@ for set, update or to
--      - @+@ for insert
--      - @++@ for insertNew
--      - @-@ for remove
--      - @?@ for mem or elem
--
-- The only exception to this convention is '(.:)' (for 'cons')

module Indigo.Internal.Expr.Symbolic
  ( -- * Basic
    constExpr, varExpr, cast

  -- * Math
  , add, sub, mul, div, mod, neg, abs
  , (+), (-), (*), (/), (%)

  -- * Comparison
  , eq, neq, lt, gt, le, ge
  , (==), (/=), (<), (>), (<=), (>=)

  -- * Conversion
  , isNat, toInt, nonZero, coerce, forcedCoerce

  -- * Bits and boolean
  , lsl, lsr, and, or, xor, not
  , (<<<), (>>>), (&&), (||), (^)

  -- * Serialization
  , pack, unpack

  -- * Pairs
  , pair, car, cdr, fst, snd

  -- * Maybe
  , some, none

  -- * Either
  , right, left

  -- * Bytes and string
  , slice, concat, (<>)

  -- * List
  , concatAll, nil, cons, (.:)

  -- * Containers
  , get, update, insert, remove, mem, size
  , (#:), (!:), (+:), (-:), (?:)
  , empty, emptyBigMap, emptyMap, emptySet

  -- * UStore
  , uGet, uUpdate, uInsert, uInsertNew, uDelete, uMem
  , (#@), (!@), (+@), (++@), (-@), (?@)

  -- * Sum types
  , wrap, unwrap

  -- * HasField
  , (!!), (#!)

  -- * Record and Named
  , name, unName, (!~), (#~)
  , construct, constructRec

  -- * Contract
  , contract
  , self
  , contractAddress
  , contractCallingUnsafe
  , contractCallingString
  , runFutureContract
  , implicitAccount
  , convertEpAddressToContract
  , makeView
  , makeVoid

  -- * Auxiliary
  , now
  , amount
  , sender
  , blake2b
  , sha256
  , sha512
  , hashKey
  , chainId
  , balance
  , checkSignature
  ) where

import Data.Vinyl.Core (RMap(..))

import Indigo.Internal.Expr.Types
import Indigo.Internal.Field
import Indigo.Internal.Object (Var)
import Indigo.Lorentz hiding (forcedCoerce)
import Indigo.Prelude
import qualified Michelson.Typed.Arith as M
import Util.TypeTuple
import Michelson.Text (unMText)
import Michelson.Typed.Haskell.Instr.Sum (CtorOnlyField, InstrUnwrapC, InstrWrapOneC)
import Michelson.Untyped.Entrypoints (unsafeBuildEpName)

----------------------------------------------------------------------------
-- Basic
----------------------------------------------------------------------------

constExpr :: NiceConstant a => a -> Expr a
constExpr :: a -> Expr a
constExpr = a -> Expr a
forall a. NiceConstant a => a -> Expr a
C

-- | Create an expression holding a variable.
varExpr :: KnownValue a => Var a -> Expr a
varExpr :: Var a -> Expr a
varExpr = Var a -> Expr a
forall a. KnownValue a => Var a -> Expr a
V

cast :: (ex :~> a) => ex -> Expr a
cast :: ex -> Expr a
cast = Expr a -> Expr a
forall a. KnownValue a => Expr a -> Expr a
Cast (Expr a -> Expr a) -> (ex -> Expr a) -> ex -> Expr a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr a
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Math
----------------------------------------------------------------------------

infixl 6 +
add, (+)
  :: IsArithExpr exN exM M.Add n m
  => exN -> exM
  -> Expr (ArithResHs M.Add n m)
add :: exN -> exM -> Expr (ArithResHs Add n m)
add n :: exN
n m :: exM
m = Expr n -> Expr m -> Expr (ArithResHs Add n m)
forall n n.
(ArithOpHs Add n n, KnownValue (ArithResHs Add n n)) =>
Expr n -> Expr n -> Expr (ArithResHs Add n n)
Add (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
m)
+ :: exN -> exM -> Expr (ArithResHs Add n m)
(+) = exN -> exM -> Expr (ArithResHs Add n m)
forall exN exM n m.
IsArithExpr exN exM Add n m =>
exN -> exM -> Expr (ArithResHs Add n m)
add

infixl 6 -
sub, (-)
  :: IsArithExpr exN exM M.Sub n m
  => exN -> exM
  -> Expr (ArithResHs M.Sub n m)
sub :: exN -> exM -> Expr (ArithResHs Sub n m)
sub n :: exN
n m :: exM
m = Expr n -> Expr m -> Expr (ArithResHs Sub n m)
forall n n.
(ArithOpHs Sub n n, KnownValue (ArithResHs Sub n n)) =>
Expr n -> Expr n -> Expr (ArithResHs Sub n n)
Sub (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
m)
(-) = exN -> exM -> Expr (ArithResHs Sub n m)
forall exN exM n m.
IsArithExpr exN exM Sub n m =>
exN -> exM -> Expr (ArithResHs Sub n m)
sub

infixl 7 *
mul, (*)
  :: IsArithExpr exN exM M.Mul n m
  => exN -> exM
  -> Expr (ArithResHs M.Mul n m)
mul :: exN -> exM -> Expr (ArithResHs Mul n m)
mul n :: exN
n m :: exM
m = Expr n -> Expr m -> Expr (ArithResHs Mul n m)
forall n n.
(ArithOpHs Mul n n, KnownValue (ArithResHs Mul n n)) =>
Expr n -> Expr n -> Expr (ArithResHs Mul n n)
Mul (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
m)
* :: exN -> exM -> Expr (ArithResHs Mul n m)
(*) = exN -> exM -> Expr (ArithResHs Mul n m)
forall exN exM n m.
IsArithExpr exN exM Mul n m =>
exN -> exM -> Expr (ArithResHs Mul n m)
mul

infixl 7 /
div, (/)
  :: IsDivExpr exN exM n m
  => exN -> exM
  -> Expr (EDivOpResHs n m)
div :: exN -> exM -> Expr (EDivOpResHs n m)
div n :: exN
n m :: exM
m = Expr n -> Expr m -> Expr (EDivOpResHs n m)
forall n n.
(EDivOpHs n n, KnownValue (EDivOpResHs n n)) =>
Expr n -> Expr n -> Expr (EDivOpResHs n n)
Div (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
m)
/ :: exN -> exM -> Expr (EDivOpResHs n m)
(/) = exN -> exM -> Expr (EDivOpResHs n m)
forall exN exM n m.
IsDivExpr exN exM n m =>
exN -> exM -> Expr (EDivOpResHs n m)
div

infixl 7 %
mod, (%)
  :: IsModExpr exN exM n m
  => exN -> exM
  -> Expr (EModOpResHs n m)
mod :: exN -> exM -> Expr (EModOpResHs n m)
mod n :: exN
n m :: exM
m = Expr n -> Expr m -> Expr (EModOpResHs n m)
forall n n.
(EDivOpHs n n, KnownValue (EModOpResHs n n)) =>
Expr n -> Expr n -> Expr (EModOpResHs n n)
Mod (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
m)
% :: exN -> exM -> Expr (EModOpResHs n m)
(%) = exN -> exM -> Expr (EModOpResHs n m)
forall exN exM n m.
IsModExpr exN exM n m =>
exN -> exM -> Expr (EModOpResHs n m)
mod

abs
  :: IsUnaryArithExpr exN M.Abs n
  => exN
  -> Expr (UnaryArithResHs M.Abs n)
abs :: exN -> Expr (UnaryArithResHs Abs n)
abs = Expr n -> Expr (UnaryArithResHs Abs n)
forall n.
(UnaryArithOpHs Abs n, KnownValue (UnaryArithResHs Abs n)) =>
Expr n -> Expr (UnaryArithResHs Abs n)
Abs (Expr n -> Expr (UnaryArithResHs Abs n))
-> (exN -> Expr n) -> exN -> Expr (UnaryArithResHs Abs n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exN -> Expr n
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

neg
  :: IsUnaryArithExpr exN M.Neg n
  => exN
  -> Expr (UnaryArithResHs M.Neg n)
neg :: exN -> Expr (UnaryArithResHs Neg n)
neg = Expr n -> Expr (UnaryArithResHs Neg n)
forall n.
(UnaryArithOpHs Neg n, KnownValue (UnaryArithResHs Neg n)) =>
Expr n -> Expr (UnaryArithResHs Neg n)
Neg (Expr n -> Expr (UnaryArithResHs Neg n))
-> (exN -> Expr n) -> exN -> Expr (UnaryArithResHs Neg n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exN -> Expr n
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Comparison
----------------------------------------------------------------------------

infix 4 ==
eq, (==)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
eq :: c -> c1 -> Expr Bool
eq a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Eq' (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
== :: c -> c1 -> Expr Bool
(==) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
eq

infix 4 /=
neq, (/=)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
neq :: c -> c1 -> Expr Bool
neq a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Neq (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
/= :: c -> c1 -> Expr Bool
(/=) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
neq

infix 4 <
lt, (<)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
lt :: c -> c1 -> Expr Bool
lt a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Lt (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
< :: c -> c1 -> Expr Bool
(<) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
lt

infix 4 >
gt, (>)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
gt :: c -> c1 -> Expr Bool
gt a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Gt (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
> :: c -> c1 -> Expr Bool
(>) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
gt

infix 4 <=
le, (<=)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
le :: c -> c1 -> Expr Bool
le a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Le (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
<= :: c -> c1 -> Expr Bool
(<=) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
le

infix 4 >=
ge, (>=)
  :: (NiceComparable n, c :~> n, c1 :~> n)
  => c -> c1
  -> Expr Bool
ge :: c -> c1 -> Expr Bool
ge a :: c
a b :: c1
b = Expr n -> Expr n -> Expr Bool
forall m. NiceComparable m => Expr m -> Expr m -> Expr Bool
Ge (c -> Expr (ExprType c)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c
a) (c1 -> Expr (ExprType c1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr c1
b)
>= :: c -> c1 -> Expr Bool
(>=) = c -> c1 -> Expr Bool
forall n c c1.
(NiceComparable n, c :~> n, c1 :~> n) =>
c -> c1 -> Expr Bool
ge

----------------------------------------------------------------------------
-- Conversion
----------------------------------------------------------------------------

isNat :: (ex :~> Integer) => ex -> Expr (Maybe Natural)
isNat :: ex -> Expr (Maybe Natural)
isNat = Expr Integer -> Expr (Maybe Natural)
IsNat (Expr Integer -> Expr (Maybe Natural))
-> (ex -> Expr Integer) -> ex -> Expr (Maybe Natural)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr Integer
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

toInt :: (ex :~> Natural) => ex -> Expr Integer
toInt :: ex -> Expr Integer
toInt = Expr Natural -> Expr Integer
Int' (Expr Natural -> Expr Integer)
-> (ex -> Expr Natural) -> ex -> Expr Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr Natural
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

nonZero :: (ex :~> n, NonZero n, KnownValue (Maybe n)) => ex -> Expr (Maybe n)
nonZero :: ex -> Expr (Maybe n)
nonZero = Expr n -> Expr (Maybe n)
forall n.
(NonZero n, KnownValue (Maybe n)) =>
Expr n -> Expr (Maybe n)
NonZero (Expr n -> Expr (Maybe n))
-> (ex -> Expr n) -> ex -> Expr (Maybe n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr n
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

-- | Convert between types that have the same Michelson representation and an
-- explicit permission for that in the face of 'CanCastTo' constraint.
coerce :: forall b a ex. (Castable_ a b, KnownValue b, ex :~> a) => ex -> Expr b
coerce :: ex -> Expr b
coerce = Expr a -> Expr b
forall a b. (Castable_ a b, KnownValue b) => Expr a -> Expr b
Coerce (Expr a -> Expr b) -> (ex -> Expr a) -> ex -> Expr b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr a
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

-- | Convert between expressions of types that have the same Michelson
-- representation.
forcedCoerce
  :: forall b a ex. (MichelsonCoercible a b, KnownValue b, ex :~> a)
  => ex -> Expr b
forcedCoerce :: ex -> Expr b
forcedCoerce = Expr a -> Expr b
forall a b.
(MichelsonCoercible a b, KnownValue b) =>
Expr a -> Expr b
ForcedCoerce (Expr a -> Expr b) -> (ex -> Expr a) -> ex -> Expr b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr a
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Bits and boolean
----------------------------------------------------------------------------

infixl 8 <<<
lsl, (<<<)
  :: IsArithExpr exN exM M.Lsl n m
  => exN -> exM
  -> Expr (ArithResHs M.Lsl n m)
lsl :: exN -> exM -> Expr (ArithResHs Lsl n m)
lsl a :: exN
a b :: exM
b = Expr n -> Expr m -> Expr (ArithResHs Lsl n m)
forall n n.
(ArithOpHs Lsl n n, KnownValue (ArithResHs Lsl n n)) =>
Expr n -> Expr n -> Expr (ArithResHs Lsl n n)
Lsl (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
a) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
b)
<<< :: exN -> exM -> Expr (ArithResHs Lsl n m)
(<<<) = exN -> exM -> Expr (ArithResHs Lsl n m)
forall exN exM n m.
IsArithExpr exN exM Lsl n m =>
exN -> exM -> Expr (ArithResHs Lsl n m)
lsl

infixl 8 >>>
lsr, (>>>)
  :: IsArithExpr exN exM M.Lsr n m
  => exN -> exM
  -> Expr (ArithResHs M.Lsr n m)
lsr :: exN -> exM -> Expr (ArithResHs Lsr n m)
lsr a :: exN
a b :: exM
b = Expr n -> Expr m -> Expr (ArithResHs Lsr n m)
forall n m.
(ArithOpHs Lsr n m, KnownValue (ArithResHs Lsr n m)) =>
Expr n -> Expr m -> Expr (ArithResHs Lsr n m)
Lsr (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
a) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
b)
>>> :: exN -> exM -> Expr (ArithResHs Lsr n m)
(>>>) = exN -> exM -> Expr (ArithResHs Lsr n m)
forall exN exM n m.
IsArithExpr exN exM Lsr n m =>
exN -> exM -> Expr (ArithResHs Lsr n m)
lsr

infixr 2 ||
or, (||)
  :: IsArithExpr exN exM M.Or n m
  => exN -> exM
  -> Expr (ArithResHs M.Or n m)
or :: exN -> exM -> Expr (ArithResHs Or n m)
or a :: exN
a b :: exM
b = Expr n -> Expr m -> Expr (ArithResHs Or n m)
forall n n.
(ArithOpHs Or n n, KnownValue (ArithResHs Or n n)) =>
Expr n -> Expr n -> Expr (ArithResHs Or n n)
Or (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
a) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
b)
|| :: exN -> exM -> Expr (ArithResHs Or n m)
(||) = exN -> exM -> Expr (ArithResHs Or n m)
forall exN exM n m.
IsArithExpr exN exM Or n m =>
exN -> exM -> Expr (ArithResHs Or n m)
or

infixr 3 &&
and, (&&)
  :: IsArithExpr exN exM M.And n m
  => exN -> exM
  -> Expr (ArithResHs M.And n m)
and :: exN -> exM -> Expr (ArithResHs And n m)
and a :: exN
a b :: exM
b = Expr n -> Expr m -> Expr (ArithResHs And n m)
forall m n.
(ArithOpHs And m n, KnownValue (ArithResHs And m n)) =>
Expr m -> Expr n -> Expr (ArithResHs And m n)
And (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
a) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
b)
&& :: exN -> exM -> Expr (ArithResHs And n m)
(&&) = exN -> exM -> Expr (ArithResHs And n m)
forall exN exM n m.
IsArithExpr exN exM And n m =>
exN -> exM -> Expr (ArithResHs And n m)
and

infixr 2 ^
xor, (^)
  :: IsArithExpr exN exM M.Xor n m
  => exN -> exM
  -> Expr (ArithResHs M.Xor n m)
xor :: exN -> exM -> Expr (ArithResHs Xor n m)
xor a :: exN
a b :: exM
b = Expr n -> Expr m -> Expr (ArithResHs Xor n m)
forall n m.
(ArithOpHs Xor n m, KnownValue (ArithResHs Xor n m)) =>
Expr n -> Expr m -> Expr (ArithResHs Xor n m)
Xor (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
a) (exM -> Expr (ExprType exM)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exM
b)
^ :: exN -> exM -> Expr (ArithResHs Xor n m)
(^) = exN -> exM -> Expr (ArithResHs Xor n m)
forall exN exM n m.
IsArithExpr exN exM Xor n m =>
exN -> exM -> Expr (ArithResHs Xor n m)
xor

not
  :: IsUnaryArithExpr exN M.Not n
  => exN
  -> Expr (UnaryArithResHs M.Not n)
not :: exN -> Expr (UnaryArithResHs Not n)
not = Expr n -> Expr (UnaryArithResHs Not n)
forall n.
(UnaryArithOpHs Not n, KnownValue (UnaryArithResHs Not n)) =>
Expr n -> Expr (UnaryArithResHs Not n)
Not (Expr n -> Expr (UnaryArithResHs Not n))
-> (exN -> Expr n) -> exN -> Expr (UnaryArithResHs Not n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exN -> Expr n
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Serialization
----------------------------------------------------------------------------

pack :: (ex :~> a, NicePackedValue a) => ex -> Expr ByteString
pack :: ex -> Expr ByteString
pack = Expr a -> Expr ByteString
forall key. NicePackedValue key => Expr key -> Expr ByteString
Pack (Expr a -> Expr ByteString)
-> (ex -> Expr a) -> ex -> Expr ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr a
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

unpack :: (NiceUnpackedValue a, exb :~> ByteString) => exb -> Expr (Maybe a)
unpack :: exb -> Expr (Maybe a)
unpack = Expr ByteString -> Expr (Maybe a)
forall a. NiceUnpackedValue a => Expr ByteString -> Expr (Maybe a)
Unpack (Expr ByteString -> Expr (Maybe a))
-> (exb -> Expr ByteString) -> exb -> Expr (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exb -> Expr ByteString
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Pairs
----------------------------------------------------------------------------

pair :: (ex1 :~> n, ex2 :~> m, KnownValue (n, m)) => ex1 -> ex2 -> Expr (n, m)
pair :: ex1 -> ex2 -> Expr (n, m)
pair a :: ex1
a b :: ex2
b = Expr n -> Expr m -> Expr (n, m)
forall n t. KnownValue (n, t) => Expr n -> Expr t -> Expr (n, t)
Pair (ex1 -> Expr (ExprType ex1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex1
a) (ex2 -> Expr (ExprType ex2)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex2
b)

car, fst :: (op :~> (n, m), KnownValue n) => op -> Expr n
car :: op -> Expr n
car = op -> Expr n
forall op n m. (op :~> (n, m), KnownValue n) => op -> Expr n
fst
fst :: op -> Expr n
fst = Expr (n, m) -> Expr n
forall n m. KnownValue n => Expr (n, m) -> Expr n
Fst (Expr (n, m) -> Expr n) -> (op -> Expr (n, m)) -> op -> Expr n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. op -> Expr (n, m)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

cdr, snd :: (op :~> (n, m), KnownValue m) => op -> Expr m
cdr :: op -> Expr m
cdr = op -> Expr m
forall op n m. (op :~> (n, m), KnownValue m) => op -> Expr m
snd
snd :: op -> Expr m
snd = Expr (n, m) -> Expr m
forall m n. KnownValue m => Expr (n, m) -> Expr m
Snd (Expr (n, m) -> Expr m) -> (op -> Expr (n, m)) -> op -> Expr m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. op -> Expr (n, m)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Maybe
----------------------------------------------------------------------------

some :: (ex :~> t, KnownValue (Maybe t)) => ex -> Expr (Maybe t)
some :: ex -> Expr (Maybe t)
some = Expr t -> Expr (Maybe t)
forall t. KnownValue (Maybe t) => Expr t -> Expr (Maybe t)
Some (Expr t -> Expr (Maybe t))
-> (ex -> Expr t) -> ex -> Expr (Maybe t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr t
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

none :: KnownValue t => Expr (Maybe t)
none :: Expr (Maybe t)
none = Expr (Maybe t)
forall t. KnownValue t => Expr (Maybe t)
None

----------------------------------------------------------------------------
-- Either
----------------------------------------------------------------------------

right :: (ex :~> x, KnownValue y, KnownValue (Either y x)) => ex -> Expr (Either y x)
right :: ex -> Expr (Either y x)
right = Expr x -> Expr (Either y x)
forall y x.
(KnownValue y, KnownValue (Either y x)) =>
Expr x -> Expr (Either y x)
Right' (Expr x -> Expr (Either y x))
-> (ex -> Expr x) -> ex -> Expr (Either y x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr x
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

left :: (ex :~> y, KnownValue x, KnownValue (Either y x)) => ex -> Expr (Either y x)
left :: ex -> Expr (Either y x)
left = Expr y -> Expr (Either y x)
forall x c.
(KnownValue x, KnownValue (Either c x)) =>
Expr c -> Expr (Either c x)
Left' (Expr y -> Expr (Either y x))
-> (ex -> Expr y) -> ex -> Expr (Either y x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr y
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- Bytes and string
----------------------------------------------------------------------------

slice
  :: ( an :~> Natural
     , bn :~> Natural
     , IsSliceExpr ex c
     )
  => (an, bn) -> ex
  -> Expr (Maybe c)
slice :: (an, bn) -> ex -> Expr (Maybe c)
slice (a :: an
a, b :: bn
b) ex :: ex
ex = Expr Natural -> Expr Natural -> Expr c -> Expr (Maybe c)
forall c.
(SliceOpHs c, KnownValue c) =>
Expr Natural -> Expr Natural -> Expr c -> Expr (Maybe c)
Slice (an -> Expr (ExprType an)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr an
a) (bn -> Expr (ExprType bn)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr bn
b) (ex -> Expr (ExprType ex)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex
ex)

infixr 6 <>
concat, (<>)
  :: IsConcatExpr exN1 exN2 n
  => exN1 -> exN2
  -> Expr n
concat :: exN1 -> exN2 -> Expr n
concat a :: exN1
a b :: exN2
b = Expr n -> Expr n -> Expr n
forall c.
(ConcatOpHs c, KnownValue c) =>
Expr c -> Expr c -> Expr c
Concat (exN1 -> Expr (ExprType exN1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN1
a) (exN2 -> Expr (ExprType exN2)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN2
b)
<> :: exN1 -> exN2 -> Expr n
(<>) = exN1 -> exN2 -> Expr n
forall exN1 exN2 n.
IsConcatExpr exN1 exN2 n =>
exN1 -> exN2 -> Expr n
concat

----------------------------------------------------------------------------
-- List
----------------------------------------------------------------------------

infixr 5 .:
cons, (.:) :: (ex1 :~> a, ex2 :~> List a) => ex1 -> ex2 -> Expr (List a)
cons :: ex1 -> ex2 -> Expr (List a)
cons el :: ex1
el lst :: ex2
lst = Expr a -> Expr (List a) -> Expr (List a)
forall a.
KnownValue (List a) =>
Expr a -> Expr (List a) -> Expr (List a)
Cons (ex1 -> Expr (ExprType ex1)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex1
el) (ex2 -> Expr (ExprType ex2)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr ex2
lst)
.: :: ex1 -> ex2 -> Expr (List a)
(.:) = ex1 -> ex2 -> Expr (List a)
forall ex1 a ex2.
(ex1 :~> a, ex2 :~> List a) =>
ex1 -> ex2 -> Expr (List a)
cons

concatAll :: IsConcatListExpr exN n => exN -> Expr n
concatAll :: exN -> Expr n
concatAll = Expr (List n) -> Expr n
forall c. (ConcatOpHs c, KnownValue c) => Expr (List c) -> Expr c
Concat' (Expr (List n) -> Expr n)
-> (exN -> Expr (List n)) -> exN -> Expr n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exN -> Expr (List n)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

nil :: KnownValue a => Expr (List a)
nil :: Expr (List a)
nil = Expr (List a)
forall a. KnownValue a => Expr (List a)
Nil

----------------------------------------------------------------------------
-- Containers
----------------------------------------------------------------------------

class ExprMagma c where
  empty :: (NiceComparable (UpdOpKeyHs c), KnownValue c) => Expr c

instance KnownValue v => ExprMagma (BigMap k v) where
  empty :: Expr (BigMap k v)
empty = Expr (BigMap k v)
forall key key.
(KnownValue key, NiceComparable key,
 KnownValue (BigMap key key)) =>
Expr (BigMap key key)
EmptyBigMap

instance KnownValue v => ExprMagma (Map k v) where
  empty :: Expr (Map k v)
empty = Expr (Map k v)
forall value key.
(KnownValue value, NiceComparable key,
 KnownValue (Map key value)) =>
Expr (Map key value)
EmptyMap

instance ExprMagma (Set k) where
  empty :: Expr (Set k)
empty = Expr (Set k)
forall key.
(NiceComparable key, KnownValue (Set key)) =>
Expr (Set key)
EmptySet

-- | Expression class to insert an element into a data structure.
--
-- Note that while this is based on 'update' and 'UpdOpHs', it is necessary to
-- have different instances to allow for different 'update' parameter types,
-- ('Set' uses a 'Bool' instead of a 'Maybe'), just like 'ExprRemovable'.
--
-- Moreover, this class is parameterized with an @insParam@ as well in order to
-- have both key-value pairs ('Map' and 'BigMap') as well as key only ('Set').
class UpdOpHs c => ExprInsertable c insParam where
  insert :: ex :~> c => insParam -> ex -> Expr c

instance (NiceComparable k, exKey :~> k, exValue :~> v)
    => ExprInsertable (BigMap k v) (exKey, exValue) where
  insert :: (exKey, exValue) -> ex -> Expr (BigMap k v)
insert (k :: exKey
k, v :: exValue
v) c :: ex
c = (exKey, Expr (Maybe v)) -> ex -> Expr (BigMap k v)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, exValue -> Expr (Maybe v)
forall ex t.
(ex :~> t, KnownValue (Maybe t)) =>
ex -> Expr (Maybe t)
some exValue
v) ex
c

instance (NiceComparable k, exKey :~> k, exValue :~> v)
    => ExprInsertable (Map k v) (exKey, exValue) where
  insert :: (exKey, exValue) -> ex -> Expr (Map k v)
insert (k :: exKey
k, v :: exValue
v) c :: ex
c = (exKey, Expr (Maybe v)) -> ex -> Expr (Map k v)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, exValue -> Expr (Maybe v)
forall ex t.
(ex :~> t, KnownValue (Maybe t)) =>
ex -> Expr (Maybe t)
some exValue
v) ex
c

instance (NiceComparable a, exKey :~> a) => ExprInsertable (Set a) exKey where
  insert :: exKey -> ex -> Expr (Set a)
insert k :: exKey
k c :: ex
c = (exKey, Bool) -> ex -> Expr (Set a)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, Bool
True) ex
c

-- | Expression class to remove an element from a data structure.
--
-- Note that while this is based on 'update' and 'UpdOpHs', it is necessary to
-- have different instances to allow for different 'update' parameter types,
-- ('Set' uses a 'Bool' instead of a 'Maybe').
class UpdOpHs c => ExprRemovable c where
  remove
    :: (exStruct :~> c, exKey :~> UpdOpKeyHs c)
    => exKey -> exStruct -> Expr c

instance (NiceComparable k, KnownValue v) => ExprRemovable (BigMap k v) where
  remove :: exKey -> exStruct -> Expr (BigMap k v)
remove k :: exKey
k c :: exStruct
c = (exKey, Expr (Maybe v)) -> exStruct -> Expr (BigMap k v)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, Expr (Maybe v)
forall t. KnownValue t => Expr (Maybe t)
none) exStruct
c

instance (NiceComparable k, KnownValue v) => ExprRemovable (Map k v) where
  remove :: exKey -> exStruct -> Expr (Map k v)
remove k :: exKey
k c :: exStruct
c = (exKey, Expr (Maybe v)) -> exStruct -> Expr (Map k v)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, Expr (Maybe v)
forall t. KnownValue t => Expr (Maybe t)
none) exStruct
c

instance NiceComparable a => ExprRemovable (Set a) where
  remove :: exKey -> exStruct -> Expr (Set a)
remove k :: exKey
k c :: exStruct
c = (exKey, Bool) -> exStruct -> Expr (Set a)
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update (exKey
k, Bool
False) exStruct
c

get
  :: IsGetExpr exKey exMap map
  => exKey -> exMap
  -> Expr (Maybe (GetOpValHs map))
get :: exKey -> exMap -> Expr (Maybe (GetOpValHs map))
get k :: exKey
k m :: exMap
m = Expr (GetOpKeyHs map) -> Expr map -> Expr (Maybe (GetOpValHs map))
forall c.
(GetOpHs c, KnownValue (Maybe (GetOpValHs c)),
 KnownValue (GetOpValHs c)) =>
Expr (GetOpKeyHs c) -> Expr c -> Expr (Maybe (GetOpValHs c))
Get (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
k) (exMap -> Expr (ExprType exMap)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exMap
m)

update
  :: IsUpdExpr exKey exVal exMap map
  => (exKey, exVal) -> exMap
  -> Expr map
update :: (exKey, exVal) -> exMap -> Expr map
update (k :: exKey
k, v :: exVal
v) s :: exMap
s = Expr map
-> Expr (UpdOpKeyHs map) -> Expr (UpdOpParamsHs map) -> Expr map
forall c.
(UpdOpHs c, KnownValue c) =>
Expr c -> Expr (UpdOpKeyHs c) -> Expr (UpdOpParamsHs c) -> Expr c
Update (exMap -> Expr (ExprType exMap)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exMap
s) (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
k) (exVal -> Expr (ExprType exVal)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exVal
v)

mem
  :: IsMemExpr exKey exN n
  => exKey -> exN
  -> Expr Bool
mem :: exKey -> exN -> Expr Bool
mem key :: exKey
key n :: exN
n = Expr (MemOpKeyHs n) -> Expr n -> Expr Bool
forall c. MemOpHs c => Expr (MemOpKeyHs c) -> Expr c -> Expr Bool
Mem (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exN -> Expr (ExprType exN)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exN
n)

size
  :: IsSizeExpr exN n
  => exN -> Expr Natural
size :: exN -> Expr Natural
size = Expr n -> Expr Natural
forall c. SizeOpHs c => Expr c -> Expr Natural
Size (Expr n -> Expr Natural) -> (exN -> Expr n) -> exN -> Expr Natural
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exN -> Expr n
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

infixl 8 #:
(#:)
  :: IsGetExpr exKey exMap map
  => exMap -> exKey
  -> Expr (Maybe (GetOpValHs map))
#: :: exMap -> exKey -> Expr (Maybe (GetOpValHs map))
(#:) = (exKey -> exMap -> Expr (Maybe (GetOpValHs map)))
-> exMap -> exKey -> Expr (Maybe (GetOpValHs map))
forall a b c. (a -> b -> c) -> b -> a -> c
flip exKey -> exMap -> Expr (Maybe (GetOpValHs map))
forall exKey exMap map.
IsGetExpr exKey exMap map =>
exKey -> exMap -> Expr (Maybe (GetOpValHs map))
get

infixl 8 !:
(!:)
  :: IsUpdExpr exKey exVal exMap map
  => exMap -> (exKey, exVal)
  -> Expr map
!: :: exMap -> (exKey, exVal) -> Expr map
(!:) = ((exKey, exVal) -> exMap -> Expr map)
-> exMap -> (exKey, exVal) -> Expr map
forall a b c. (a -> b -> c) -> b -> a -> c
flip (exKey, exVal) -> exMap -> Expr map
forall exKey exVal exMap map.
IsUpdExpr exKey exVal exMap map =>
(exKey, exVal) -> exMap -> Expr map
update

infixl 8 +:
(+:)
  :: ( ExprInsertable c exParam
     , exStructure :~> c
     )
     => exStructure -> exParam
     -> Expr c
+: :: exStructure -> exParam -> Expr c
(+:) = (exParam -> exStructure -> Expr c)
-> exStructure -> exParam -> Expr c
forall a b c. (a -> b -> c) -> b -> a -> c
flip exParam -> exStructure -> Expr c
forall c insParam ex.
(ExprInsertable c insParam, ex :~> c) =>
insParam -> ex -> Expr c
insert

infixl 8 -:
(-:)
  :: ( ExprRemovable c
     , exStruct :~> c
     , exKey :~> UpdOpKeyHs c
     )
  => exStruct -> exKey
  -> Expr c
-: :: exStruct -> exKey -> Expr c
(-:) = (exKey -> exStruct -> Expr c) -> exStruct -> exKey -> Expr c
forall a b c. (a -> b -> c) -> b -> a -> c
flip exKey -> exStruct -> Expr c
forall c exStruct exKey.
(ExprRemovable c, exStruct :~> c, exKey :~> UpdOpKeyHs c) =>
exKey -> exStruct -> Expr c
remove

infixl 8 ?:
(?:)
  :: IsMemExpr exKey exN n
  => exN -> exKey
  -> Expr Bool
?: :: exN -> exKey -> Expr Bool
(?:) = (exKey -> exN -> Expr Bool) -> exN -> exKey -> Expr Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip exKey -> exN -> Expr Bool
forall exKey exN n.
IsMemExpr exKey exN n =>
exKey -> exN -> Expr Bool
mem

emptyBigMap
  :: (KnownValue value, NiceComparable key, KnownValue (BigMap key value))
  => Expr (BigMap key value)
emptyBigMap :: Expr (BigMap key value)
emptyBigMap = Expr (BigMap key value)
forall c.
(ExprMagma c, NiceComparable (UpdOpKeyHs c), KnownValue c) =>
Expr c
empty

emptyMap
  :: (KnownValue value, NiceComparable key, KnownValue (Map key value))
  => Expr (Map key value)
emptyMap :: Expr (Map key value)
emptyMap = Expr (Map key value)
forall c.
(ExprMagma c, NiceComparable (UpdOpKeyHs c), KnownValue c) =>
Expr c
empty

emptySet
  :: (NiceComparable key, KnownValue (Set key))
  => Expr (Set key)
emptySet :: Expr (Set key)
emptySet = Expr (Set key)
forall c.
(ExprMagma c, NiceComparable (UpdOpKeyHs c), KnownValue c) =>
Expr c
empty

----------------------------------------------------------------------------
-- UStore
----------------------------------------------------------------------------

infixr 8 #@
uGet, (#@)
  :: ( HasUStore name key value store
     , exKey   :~> key
     , exStore :~> (UStore store)
     )
  => exStore -> (Label name, exKey)
  -> Expr (Maybe value)
uGet :: exStore -> (Label name, exKey) -> Expr (Maybe value)
uGet store :: exStore
store (uName :: Label name
uName, key :: exKey
key) = Label name -> Expr key -> Expr (UStore store) -> Expr (Maybe value)
forall (name :: Symbol) key name key.
(HasUStore name key name key, KnownValue name) =>
Label name -> Expr key -> Expr (UStore key) -> Expr (Maybe name)
UGet Label name
uName (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
#@ :: exStore -> (Label name, exKey) -> Expr (Maybe value)
(#@) = exStore -> (Label name, exKey) -> Expr (Maybe value)
forall (name :: Symbol) key value store exKey exStore.
(HasUStore name key value store, exKey :~> key,
 exStore :~> UStore store) =>
exStore -> (Label name, exKey) -> Expr (Maybe value)
uGet

infixl 8 !@
uUpdate, (!@)
  :: ( HasUStore name key value store
     , exKey   :~> key
     , exVal   :~> Maybe value
     , exStore :~> UStore store
     )
  => exStore -> (Label name, exKey, exVal)
  -> Expr (UStore store)
uUpdate :: exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
uUpdate store :: exStore
store (uName :: Label name
uName, key :: exKey
key, val :: exVal
val) =
  Label name
-> Expr key
-> Expr (Maybe value)
-> Expr (UStore store)
-> Expr (UStore store)
forall (val :: Symbol) store name key.
(HasUStore val store name key, KnownValue (UStore key)) =>
Label val
-> Expr store
-> Expr (Maybe name)
-> Expr (UStore key)
-> Expr (UStore key)
UUpdate Label name
uName (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exVal -> Expr (ExprType exVal)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exVal
val) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
!@ :: exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
(!@) = exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
forall (name :: Symbol) key value store exKey exVal exStore.
(HasUStore name key value store, exKey :~> key,
 exVal :~> Maybe value, exStore :~> UStore store) =>
exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
uUpdate

infixr 8 +@
uInsert, (+@)
  :: ( HasUStore name key value store
     , exKey   :~> key
     , exVal   :~> value
     , exStore :~> UStore store
     )
  => exStore -> (Label name, exKey, exVal)
  -> Expr (UStore store)
uInsert :: exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
uInsert store :: exStore
store (uName :: Label name
uName, key :: exKey
key, val :: exVal
val) =
  Label name
-> Expr key
-> Expr value
-> Expr (UStore store)
-> Expr (UStore store)
forall (name :: Symbol) key name key.
(HasUStore name key name key, KnownValue (UStore key)) =>
Label name
-> Expr key -> Expr name -> Expr (UStore key) -> Expr (UStore key)
UInsert Label name
uName (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exVal -> Expr (ExprType exVal)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exVal
val) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
+@ :: exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
(+@) = exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
forall (name :: Symbol) key value store exKey exVal exStore.
(HasUStore name key value store, exKey :~> key, exVal :~> value,
 exStore :~> UStore store) =>
exStore -> (Label name, exKey, exVal) -> Expr (UStore store)
uInsert

infixr 8 ++@
uInsertNew, (++@)
  :: ( HasUStore name key value store
     , IsError err
     , exKey   :~> key
     , exVal   :~> value
     , exStore :~> UStore store
     )
  => exStore
  -> (Label name, err, exKey, exVal)
  -> Expr (UStore store)
uInsertNew :: exStore -> (Label name, err, exKey, exVal) -> Expr (UStore store)
uInsertNew store :: exStore
store (uName :: Label name
uName, err :: err
err, key :: exKey
key, val :: exVal
val) =
  Label name
-> err
-> Expr key
-> Expr value
-> Expr (UStore store)
-> Expr (UStore store)
forall (name :: Symbol) key value store err.
(HasUStore name key value store, IsError err,
 KnownValue (UStore store)) =>
Label name
-> err
-> Expr key
-> Expr value
-> Expr (UStore store)
-> Expr (UStore store)
UInsertNew Label name
uName err
err (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exVal -> Expr (ExprType exVal)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exVal
val) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
++@ :: exStore -> (Label name, err, exKey, exVal) -> Expr (UStore store)
(++@) = exStore -> (Label name, err, exKey, exVal) -> Expr (UStore store)
forall (name :: Symbol) key value store err exKey exVal exStore.
(HasUStore name key value store, IsError err, exKey :~> key,
 exVal :~> value, exStore :~> UStore store) =>
exStore -> (Label name, err, exKey, exVal) -> Expr (UStore store)
uInsertNew

infixl 8 -@
uDelete, (-@)
  :: ( HasUStore name key value store
     , exKey   :~> key
     , exStore :~> (UStore store)
     )
  => exStore -> (Label name, exKey)
  -> Expr (UStore store)
uDelete :: exStore -> (Label name, exKey) -> Expr (UStore store)
uDelete store :: exStore
store (uName :: Label name
uName, key :: exKey
key) = Label name
-> Expr key -> Expr (UStore store) -> Expr (UStore store)
forall (name :: Symbol) key val dt.
(HasUStore name key val dt, KnownValue (UStore dt)) =>
Label name -> Expr key -> Expr (UStore dt) -> Expr (UStore dt)
UDelete Label name
uName (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
-@ :: exStore -> (Label name, exKey) -> Expr (UStore store)
(-@) = exStore -> (Label name, exKey) -> Expr (UStore store)
forall (name :: Symbol) key value store exKey exStore.
(HasUStore name key value store, exKey :~> key,
 exStore :~> UStore store) =>
exStore -> (Label name, exKey) -> Expr (UStore store)
uDelete

infixl 8 ?@
uMem, (?@)
  :: ( HasUStore name key value store
     , exKey   :~> key
     , exStore :~> (UStore store)
     )
  => exStore -> (Label name, exKey)
  -> Expr Bool
uMem :: exStore -> (Label name, exKey) -> Expr Bool
uMem store :: exStore
store (uName :: Label name
uName, key :: exKey
key) = Label name -> Expr key -> Expr (UStore store) -> Expr Bool
forall (name :: Symbol) key val store.
(HasUStore name key val store, KnownValue val) =>
Label name -> Expr key -> Expr (UStore store) -> Expr Bool
UMem Label name
uName (exKey -> Expr (ExprType exKey)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exKey
key) (exStore -> Expr (ExprType exStore)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exStore
store)
?@ :: exStore -> (Label name, exKey) -> Expr Bool
(?@) = exStore -> (Label name, exKey) -> Expr Bool
forall (name :: Symbol) key value store exKey exStore.
(HasUStore name key value store, exKey :~> key,
 exStore :~> UStore store) =>
exStore -> (Label name, exKey) -> Expr Bool
uMem

----------------------------------------------------------------------------
-- Sum types
----------------------------------------------------------------------------

wrap
  :: ( InstrWrapOneC dt name
     , exField :~> CtorOnlyField name dt
     , KnownValue dt
     )
  => Label name
  -> exField
  -> Expr dt
wrap :: Label name -> exField -> Expr dt
wrap l :: Label name
l = Label name
-> Expr
     (RequireOneField
        name
        (LnrFieldType
           (LNRequireFound name dt (GLookupNamed name (Rep dt)))))
-> Expr dt
forall dt (name :: Symbol).
(InstrWrapOneC dt name, KnownValue dt) =>
Label name -> Expr (CtorOnlyField name dt) -> Expr dt
Wrap Label name
l (Expr
   (RequireOneField
      name
      (LnrFieldType
         (LNRequireFound name dt (GLookupNamed name (Rep dt)))))
 -> Expr dt)
-> (exField
    -> Expr
         (RequireOneField
            name
            (LnrFieldType
               (LNRequireFound name dt (GLookupNamed name (Rep dt))))))
-> exField
-> Expr dt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exField
-> Expr
     (RequireOneField
        name
        (LnrFieldType
           (LNRequireFound name dt (GLookupNamed name (Rep dt)))))
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

unwrap
  :: ( InstrUnwrapC dt name
     , exDt :~> dt
     , KnownValue (CtorOnlyField name dt)
     )
  => Label name
  -> exDt
  -> Expr (CtorOnlyField name dt)
unwrap :: Label name -> exDt -> Expr (CtorOnlyField name dt)
unwrap l :: Label name
l = Label name -> Expr dt -> Expr (CtorOnlyField name dt)
forall dt (name :: Symbol).
(InstrUnwrapC dt name, KnownValue (CtorOnlyField name dt)) =>
Label name -> Expr dt -> Expr (CtorOnlyField name dt)
Unwrap Label name
l (Expr dt -> Expr (CtorOnlyField name dt))
-> (exDt -> Expr dt) -> exDt -> Expr (CtorOnlyField name dt)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exDt -> Expr dt
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

----------------------------------------------------------------------------
-- HasField
----------------------------------------------------------------------------

infixl 8 #!
(#!)
  :: (HasField dt name ftype, exDt :~> dt)
  => exDt
  -> Label name
  -> Expr ftype
#! :: exDt -> Label name -> Expr ftype
(#!) (exDt -> Expr (ExprType exDt)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr -> (ObjMan fa :: ObjectManipulation (ExprType exDt)
fa)) fName :: Label name
fName = ObjectManipulation ftype -> Expr ftype
forall a. ObjectManipulation a -> Expr a
ObjMan (ObjectManipulation dt -> Label name -> ObjectManipulation ftype
forall dt (fname :: Symbol) ftype.
HasField dt fname ftype =>
ObjectManipulation dt -> Label fname -> ObjectManipulation ftype
ToField ObjectManipulation dt
ObjectManipulation (ExprType exDt)
fa Label name
fName)
(#!) exDt :: exDt
exDt fName :: Label name
fName = ObjectManipulation ftype -> Expr ftype
forall a. ObjectManipulation a -> Expr a
ObjMan (ObjectManipulation dt -> Label name -> ObjectManipulation ftype
forall dt (fname :: Symbol) ftype.
HasField dt fname ftype =>
ObjectManipulation dt -> Label fname -> ObjectManipulation ftype
ToField (Expr dt -> ObjectManipulation dt
forall a. Expr a -> ObjectManipulation a
Object (Expr dt -> ObjectManipulation dt)
-> Expr dt -> ObjectManipulation dt
forall a b. (a -> b) -> a -> b
$ exDt -> Expr (ExprType exDt)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exDt
exDt) Label name
fName)

infixl 8 !!
(!!)
  :: ( HasField dt name ftype
     , exDt :~> dt
     , exFld :~> ftype
     )
  => exDt
  -> (Label name, exFld)
  -> Expr dt
!! :: exDt -> (Label name, exFld) -> Expr dt
(!!) (exDt -> Expr (ExprType exDt)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr -> (ObjMan fa :: ObjectManipulation (ExprType exDt)
fa)) (fName :: Label name
fName, eFld :: exFld
eFld) = ObjectManipulation dt -> Expr dt
forall a. ObjectManipulation a -> Expr a
ObjMan (ObjectManipulation dt
-> Label name -> Expr ftype -> ObjectManipulation dt
forall dt (fname :: Symbol) ftype.
HasField dt fname ftype =>
ObjectManipulation dt
-> Label fname -> Expr ftype -> ObjectManipulation dt
SetField ObjectManipulation dt
ObjectManipulation (ExprType exDt)
fa Label name
fName (exFld -> Expr (ExprType exFld)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exFld
eFld))
dt :: exDt
dt !! (fName :: Label name
fName, eFld :: exFld
eFld) = ObjectManipulation dt -> Expr dt
forall a. ObjectManipulation a -> Expr a
ObjMan (ObjectManipulation dt
-> Label name -> Expr ftype -> ObjectManipulation dt
forall dt (fname :: Symbol) ftype.
HasField dt fname ftype =>
ObjectManipulation dt
-> Label fname -> Expr ftype -> ObjectManipulation dt
SetField (Expr dt -> ObjectManipulation dt
forall a. Expr a -> ObjectManipulation a
Object (Expr dt -> ObjectManipulation dt)
-> Expr dt -> ObjectManipulation dt
forall a b. (a -> b) -> a -> b
$ exDt -> Expr (ExprType exDt)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exDt
dt) Label name
fName (exFld -> Expr (ExprType exFld)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exFld
eFld))

----------------------------------------------------------------------------
-- Record and Named
----------------------------------------------------------------------------

name :: (ex :~> t, KnownValue (name :! t)) => Label name -> ex -> Expr (name :! t)
name :: Label name -> ex -> Expr (name :! t)
name lName :: Label name
lName = Label name -> Expr t -> Expr (name :! t)
forall (name :: Symbol) t.
KnownValue (name :! t) =>
Label name -> Expr t -> Expr (name :! t)
Name Label name
lName (Expr t -> Expr (name :! t))
-> (ex -> Expr t) -> ex -> Expr (name :! t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr t
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

unName :: (ex :~> (name :! t), KnownValue t) => Label name -> ex -> Expr t
unName :: Label name -> ex -> Expr t
unName lName :: Label name
lName = Label name -> Expr (name :! t) -> Expr t
forall t (name :: Symbol).
KnownValue t =>
Label name -> Expr (name :! t) -> Expr t
UnName Label name
lName (Expr (name :! t) -> Expr t)
-> (ex -> Expr (name :! t)) -> ex -> Expr t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ex -> Expr (name :! t)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

infixl 8 !~
(!~)
  :: (ex :~> t, KnownValue (name :! t))
  => ex -> Label name
  -> Expr (name :! t)
!~ :: ex -> Label name -> Expr (name :! t)
(!~) = (Label name -> ex -> Expr (name :! t))
-> ex -> Label name -> Expr (name :! t)
forall a b c. (a -> b -> c) -> b -> a -> c
flip Label name -> ex -> Expr (name :! t)
forall ex t (name :: Symbol).
(ex :~> t, KnownValue (name :! t)) =>
Label name -> ex -> Expr (name :! t)
name

infixl 8 #~
(#~)
  :: (ex :~> (name :! t), KnownValue t)
  => ex -> Label name
  -> Expr t
#~ :: ex -> Label name -> Expr t
(#~) = (Label name -> ex -> Expr t) -> ex -> Label name -> Expr t
forall a b c. (a -> b -> c) -> b -> a -> c
flip Label name -> ex -> Expr t
forall ex (name :: Symbol) t.
(ex :~> (name :! t), KnownValue t) =>
Label name -> ex -> Expr t
unName

-- TODO: we should try to make this have a set of 'IsExpr' as input instead of 'Expr'
construct
  :: ( InstrConstructC dt, KnownValue dt
     , RMap (ConstructorFieldTypes dt)
     , fields ~ Rec Expr (ConstructorFieldTypes dt)
     , RecFromTuple fields
     )
  => IsoRecTuple fields -> Expr dt
construct :: IsoRecTuple fields -> Expr dt
construct = Rec Expr (GFieldTypes (Rep dt)) -> Expr dt
forall dt.
(InstrConstructC dt, RMap (ConstructorFieldTypes dt),
 KnownValue dt) =>
Rec Expr (ConstructorFieldTypes dt) -> Expr dt
Construct (Rec Expr (GFieldTypes (Rep dt)) -> Expr dt)
-> (IsoRecTuple (Rec Expr (GFieldTypes (Rep dt)))
    -> Rec Expr (GFieldTypes (Rep dt)))
-> IsoRecTuple (Rec Expr (GFieldTypes (Rep dt)))
-> Expr dt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsoRecTuple (Rec Expr (GFieldTypes (Rep dt)))
-> Rec Expr (GFieldTypes (Rep dt))
forall r. RecFromTuple r => IsoRecTuple r -> r
recFromTuple

constructRec
  :: ( InstrConstructC dt
     , RMap (ConstructorFieldTypes dt)
     , KnownValue dt
     )
  => Rec Expr (ConstructorFieldTypes dt)
  -> Expr dt
constructRec :: Rec Expr (ConstructorFieldTypes dt) -> Expr dt
constructRec = Rec Expr (ConstructorFieldTypes dt) -> Expr dt
forall dt.
(InstrConstructC dt, RMap (ConstructorFieldTypes dt),
 KnownValue dt) =>
Rec Expr (ConstructorFieldTypes dt) -> Expr dt
Construct

----------------------------------------------------------------------------
-- Contract
----------------------------------------------------------------------------

contract
  :: ( NiceParameterFull p
     , NoExplicitDefaultEntrypoint p
     , ToTAddress p addr
     , ToT addr ~ ToT Address
     , exAddr :~> addr
     )
  => exAddr -> Expr (Maybe (ContractRef p))
contract :: exAddr -> Expr (Maybe (ContractRef p))
contract = Expr addr -> Expr (Maybe (ContractRef p))
forall p p.
(NiceParameterFull p, NoExplicitDefaultEntrypoint p,
 ToTAddress p p, ToT p ~ ToT Address) =>
Expr p -> Expr (Maybe (ContractRef p))
Contract (Expr addr -> Expr (Maybe (ContractRef p)))
-> (exAddr -> Expr addr) -> exAddr -> Expr (Maybe (ContractRef p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exAddr -> Expr addr
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

self
  :: ( NiceParameterFull p
     , NoExplicitDefaultEntrypoint p
     )
  => Expr (ContractRef p)
self :: Expr (ContractRef p)
self = Expr (ContractRef p)
forall p.
(NiceParameterFull p, NoExplicitDefaultEntrypoint p) =>
Expr (ContractRef p)
Self

contractAddress :: (exc :~> ContractRef p) => exc -> Expr Address
contractAddress :: exc -> Expr Address
contractAddress = Expr (ContractRef p) -> Expr Address
forall p. Expr (ContractRef p) -> Expr Address
ContractAddress (Expr (ContractRef p) -> Expr Address)
-> (exc -> Expr (ContractRef p)) -> exc -> Expr Address
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exc -> Expr (ContractRef p)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

contractCallingUnsafe
  :: ( NiceParameter arg
     , exAddr :~> Address
     )
  => EpName -> exAddr -> Expr (Maybe (ContractRef arg))
contractCallingUnsafe :: EpName -> exAddr -> Expr (Maybe (ContractRef arg))
contractCallingUnsafe epName :: EpName
epName = EpName -> Expr Address -> Expr (Maybe (ContractRef arg))
forall arg.
NiceParameter arg =>
EpName -> Expr Address -> Expr (Maybe (ContractRef arg))
ContractCallingUnsafe EpName
epName (Expr Address -> Expr (Maybe (ContractRef arg)))
-> (exAddr -> Expr Address)
-> exAddr
-> Expr (Maybe (ContractRef arg))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exAddr -> Expr Address
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

contractCallingString
  :: ( NiceParameter arg
     , exAddr :~> Address
     )
  => MText -> exAddr -> Expr (Maybe (ContractRef arg))
contractCallingString :: MText -> exAddr -> Expr (Maybe (ContractRef arg))
contractCallingString =
    EpName -> exAddr -> Expr (Maybe (ContractRef arg))
forall arg exAddr.
(NiceParameter arg, exAddr :~> Address) =>
EpName -> exAddr -> Expr (Maybe (ContractRef arg))
contractCallingUnsafe
  (EpName -> exAddr -> Expr (Maybe (ContractRef arg)))
-> (MText -> EpName)
-> MText
-> exAddr
-> Expr (Maybe (ContractRef arg))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => Text -> EpName
Text -> EpName
unsafeBuildEpName
  (Text -> EpName) -> (MText -> Text) -> MText -> EpName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MText -> Text
unMText

runFutureContract
  :: ( NiceParameter p
     , conExpr :~> FutureContract p
     )
  => conExpr -> Expr (Maybe (ContractRef p))
runFutureContract :: conExpr -> Expr (Maybe (ContractRef p))
runFutureContract = Expr (FutureContract p) -> Expr (Maybe (ContractRef p))
forall p.
NiceParameter p =>
Expr (FutureContract p) -> Expr (Maybe (ContractRef p))
RunFutureContract (Expr (FutureContract p) -> Expr (Maybe (ContractRef p)))
-> (conExpr -> Expr (FutureContract p))
-> conExpr
-> Expr (Maybe (ContractRef p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. conExpr -> Expr (FutureContract p)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

implicitAccount
  :: (exkh :~> KeyHash)
  => exkh
  -> Expr (ContractRef ())
implicitAccount :: exkh -> Expr (ContractRef ())
implicitAccount = Expr KeyHash -> Expr (ContractRef ())
ImplicitAccount (Expr KeyHash -> Expr (ContractRef ()))
-> (exkh -> Expr KeyHash) -> exkh -> Expr (ContractRef ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. exkh -> Expr KeyHash
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

convertEpAddressToContract
  :: ( NiceParameter p
     , epExpr :~> EpAddress
     )
  => epExpr -> Expr (Maybe (ContractRef p))
convertEpAddressToContract :: epExpr -> Expr (Maybe (ContractRef p))
convertEpAddressToContract = Expr EpAddress -> Expr (Maybe (ContractRef p))
forall p.
NiceParameter p =>
Expr EpAddress -> Expr (Maybe (ContractRef p))
ConvertEpAddressToContract (Expr EpAddress -> Expr (Maybe (ContractRef p)))
-> (epExpr -> Expr EpAddress)
-> epExpr
-> Expr (Maybe (ContractRef p))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. epExpr -> Expr EpAddress
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

makeView
  :: ( KnownValue (View a r)
     , exa :~> a
     , exCRef :~> ContractRef r
     )
  => exa -> exCRef -> Expr (View a r)
makeView :: exa -> exCRef -> Expr (View a r)
makeView a :: exa
a cRef :: exCRef
cRef = Expr a -> Expr (ContractRef r) -> Expr (View a r)
forall a a.
KnownValue (View a a) =>
Expr a -> Expr (ContractRef a) -> Expr (View a a)
MakeView (exa -> Expr (ExprType exa)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exa
a) (exCRef -> Expr (ExprType exCRef)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exCRef
cRef)

makeVoid
  :: ( KnownValue (Void_ a b)
     , exa :~> a
     , exCRef :~> Lambda b b
     )
  => exa -> exCRef -> Expr (Void_ a b)
makeVoid :: exa -> exCRef -> Expr (Void_ a b)
makeVoid a :: exa
a cRef :: exCRef
cRef = Expr a -> Expr (Lambda b b) -> Expr (Void_ a b)
forall a b.
KnownValue (Void_ a b) =>
Expr a -> Expr (Lambda b b) -> Expr (Void_ a b)
MakeVoid (exa -> Expr (ExprType exa)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exa
a) (exCRef -> Expr (ExprType exCRef)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr exCRef
cRef)

----------------------------------------------------------------------------
-- Auxiliary
----------------------------------------------------------------------------

now :: Expr Timestamp
now :: Expr Timestamp
now = Expr Timestamp
Now

amount :: Expr Mutez
amount :: Expr Mutez
amount = Expr Mutez
Amount

sender :: Expr Address
sender :: Expr Address
sender = Expr Address
Sender

checkSignature
  :: ( pkExpr :~> PublicKey
     , sigExpr :~> Signature
     , hashExpr :~> ByteString
     )
  => pkExpr -> sigExpr -> hashExpr
  -> Expr Bool
checkSignature :: pkExpr -> sigExpr -> hashExpr -> Expr Bool
checkSignature pk :: pkExpr
pk sig :: sigExpr
sig hash :: hashExpr
hash = Expr PublicKey -> Expr Signature -> Expr ByteString -> Expr Bool
CheckSignature (pkExpr -> Expr (ExprType pkExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr pkExpr
pk) (sigExpr -> Expr (ExprType sigExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr sigExpr
sig) (hashExpr -> Expr (ExprType hashExpr)
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr hashExpr
hash)

sha256 :: (hashExpr :~> ByteString) => hashExpr -> Expr ByteString
sha256 :: hashExpr -> Expr ByteString
sha256 = Expr ByteString -> Expr ByteString
Sha256 (Expr ByteString -> Expr ByteString)
-> (hashExpr -> Expr ByteString) -> hashExpr -> Expr ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. hashExpr -> Expr ByteString
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

sha512 :: (hashExpr :~> ByteString) => hashExpr -> Expr ByteString
sha512 :: hashExpr -> Expr ByteString
sha512 = Expr ByteString -> Expr ByteString
Sha512 (Expr ByteString -> Expr ByteString)
-> (hashExpr -> Expr ByteString) -> hashExpr -> Expr ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. hashExpr -> Expr ByteString
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

blake2b :: (hashExpr :~> ByteString) => hashExpr -> Expr ByteString
blake2b :: hashExpr -> Expr ByteString
blake2b = Expr ByteString -> Expr ByteString
Blake2b (Expr ByteString -> Expr ByteString)
-> (hashExpr -> Expr ByteString) -> hashExpr -> Expr ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. hashExpr -> Expr ByteString
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

hashKey :: (keyExpr :~> PublicKey) => keyExpr -> Expr KeyHash
hashKey :: keyExpr -> Expr KeyHash
hashKey = Expr PublicKey -> Expr KeyHash
HashKey (Expr PublicKey -> Expr KeyHash)
-> (keyExpr -> Expr PublicKey) -> keyExpr -> Expr KeyHash
forall b c a. (b -> c) -> (a -> b) -> a -> c
. keyExpr -> Expr PublicKey
forall a. ToExpr a => a -> Expr (ExprType a)
toExpr

chainId :: Expr ChainId
chainId :: Expr ChainId
chainId = Expr ChainId
ChainId

balance :: Expr Mutez
balance :: Expr Mutez
balance = Expr Mutez
Balance