Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Morley.Michelson.Typed.Value
Description
Module, containing data types for Michelson value.
Synopsis
- data Comparability t where
- CanBeCompared :: (Comparable t, ComparabilityImplies t) => Comparability t
- CannotBeCompared :: ContainsT 'PSNonComparable t ~ 'True => Comparability t
- data CreateContract instr cp st = (forall i o. Show (instr i o), forall i o. Eq (instr i o)) => CreateContract {
- ccOriginator :: L1Address
- ccDelegate :: Maybe KeyHash
- ccBalance :: Mutez
- ccStorageVal :: Value' instr st
- ccContract :: Contract' instr cp st
- ccCounter :: GlobalCounter
- data Operation' instr where
- OpTransferTokens :: ParameterScope p => TransferTokens instr p -> Operation' instr
- OpSetDelegate :: SetDelegate -> Operation' instr
- OpCreateContract :: (forall i o. Show (instr i o), forall i o. NFData (instr i o), Typeable instr, ParameterScope cp, StorageScope st) => CreateContract instr cp st -> Operation' instr
- OpEmit :: PackedValScope t => Emit instr t -> Operation' instr
- data SetDelegate = SetDelegate {}
- data TransferTokens instr p = TransferTokens {
- ttTransferArgument :: Value' instr p
- ttAmount :: Mutez
- ttContract :: Value' instr ('TContract p)
- ttCounter :: GlobalCounter
- data Emit instr t = PackedValScope t => Emit {}
- data Value' instr t where
- VKey :: PublicKey -> Value' instr 'TKey
- VUnit :: Value' instr 'TUnit
- VSignature :: Signature -> Value' instr 'TSignature
- VChainId :: ChainId -> Value' instr 'TChainId
- VOption :: forall t instr. SingI t => Maybe (Value' instr t) -> Value' instr ('TOption t)
- VList :: forall t instr. SingI t => [Value' instr t] -> Value' instr ('TList t)
- VSet :: forall t instr. Comparable t => Set (Value' instr t) -> Value' instr ('TSet t)
- VOp :: Operation' instr -> Value' instr 'TOperation
- VContract :: forall arg instr. (SingI arg, ForbidOp arg) => Address -> SomeEntrypointCallT arg -> Value' instr ('TContract arg)
- VTicket :: forall arg instr. Comparable arg => Address -> Value' instr arg -> Natural -> Value' instr ('TTicket arg)
- VPair :: forall l r instr. (Value' instr l, Value' instr r) -> Value' instr ('TPair l r)
- VOr :: forall l r instr. (SingI l, SingI r) => Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
- VLam :: forall inp out instr. (SingI inp, SingI out) => LambdaCode' instr inp out -> Value' instr ('TLambda inp out)
- VMap :: forall k v instr. (SingI v, Comparable k) => Map (Value' instr k) (Value' instr v) -> Value' instr ('TMap k v)
- VBigMap :: forall k v instr. (SingI v, Comparable k, ForbidBigMap v) => Maybe Natural -> Map (Value' instr k) (Value' instr v) -> Value' instr ('TBigMap k v)
- VInt :: Integer -> Value' instr 'TInt
- VNat :: Natural -> Value' instr 'TNat
- VString :: MText -> Value' instr 'TString
- VBytes :: ByteString -> Value' instr 'TBytes
- VMutez :: Mutez -> Value' instr 'TMutez
- VBool :: Bool -> Value' instr 'TBool
- VKeyHash :: KeyHash -> Value' instr 'TKeyHash
- VTimestamp :: Timestamp -> Value' instr 'TTimestamp
- VAddress :: EpAddress -> Value' instr 'TAddress
- VBls12381Fr :: Bls12381Fr -> Value' instr 'TBls12381Fr
- VBls12381G1 :: Bls12381G1 -> Value' instr 'TBls12381G1
- VBls12381G2 :: Bls12381G2 -> Value' instr 'TBls12381G2
- VChest :: Chest -> Value' instr 'TChest
- VChestKey :: ChestKey -> Value' instr 'TChestKey
- data RemFail (instr :: k -> k -> Type) (i :: k) (o :: k) where
- RfNormal :: instr i o -> RemFail instr i o
- RfAlwaysFails :: (forall o'. instr i o') -> RemFail instr i o
- data LambdaCode' instr inp out where
- LambdaCode :: (forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => RemFail instr (inp ': '[]) (out ': '[]) -> LambdaCode' instr inp out
- LambdaCodeRec :: (forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => RemFail instr (inp ': ('TLambda inp out ': '[])) (out ': '[]) -> LambdaCode' instr inp out
- mkVLam :: (SingI inp, SingI out, forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => (IsNotInView => RemFail instr '[inp] '[out]) -> Value' instr ('TLambda inp out)
- mkVLamRec :: (SingI inp, SingI out, forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => (IsNotInView => RemFail instr '[inp, 'TLambda inp out] '[out]) -> Value' instr ('TLambda inp out)
- rfMerge :: (forall o'. instr i1 o' -> instr i2 o' -> instr i3 o') -> RemFail instr i1 o -> RemFail instr i2 o -> RemFail instr i3 o
- rfAnyInstr :: RemFail instr i o -> instr i o
- rfMapAnyInstr :: (forall o'. instr i1 o' -> instr i2 o') -> RemFail instr i1 o -> RemFail instr i2 o
- addressToVContract :: forall t instr kind. (ParameterScope t, ForbidOr t) => KindedAddress kind -> Value' instr ('TContract t)
- buildVContract :: Value' instr ('TContract arg) -> Doc
- checkComparability :: Sing t -> Comparability t
- compileEpLiftSequence :: EpLiftSequence arg param -> Value' instr arg -> Value' instr param
- liftCallArg :: EntrypointCallT param arg -> Value' instr arg -> Value' instr param
- valueTypeSanity :: Value' instr t -> Dict (SingI t)
- withValueTypeSanity :: Value' instr t -> (SingI t => a) -> a
- eqValueExt :: Value' instr t1 -> Value' instr t2 -> Bool
Documentation
data Comparability t where Source #
Constructors
CanBeCompared :: (Comparable t, ComparabilityImplies t) => Comparability t | |
CannotBeCompared :: ContainsT 'PSNonComparable t ~ 'True => Comparability t |
Instances
Show (Comparability t) Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.Comparable Methods showsPrec :: Int -> Comparability t -> ShowS # show :: Comparability t -> String # showList :: [Comparability t] -> ShowS # |
data CreateContract instr cp st Source #
Constructors
(forall i o. Show (instr i o), forall i o. Eq (instr i o)) => CreateContract | |
Fields
|
Instances
Show (CreateContract instr cp st) Source # | |
Defined in Morley.Michelson.Typed.Value Methods showsPrec :: Int -> CreateContract instr cp st -> ShowS # show :: CreateContract instr cp st -> String # showList :: [CreateContract instr cp st] -> ShowS # | |
(forall (i :: [T]) (o :: [T]). NFData (instr i o)) => NFData (CreateContract instr cp st) Source # | |
Defined in Morley.Michelson.Typed.Value Methods rnf :: CreateContract instr cp st -> () # | |
Eq (CreateContract instr cp st) Source # | |
Defined in Morley.Michelson.Typed.Value Methods (==) :: CreateContract instr cp st -> CreateContract instr cp st -> Bool # (/=) :: CreateContract instr cp st -> CreateContract instr cp st -> Bool # | |
Buildable (Value' instr st) => Buildable (CreateContract instr cp st) Source # | |
Defined in Morley.Michelson.Typed.Value |
data Operation' instr where Source #
Data type, representing operation, list of which is returned by Michelson contract (according to calling convention).
These operations are to be further executed against system state after the contract execution.
Constructors
OpTransferTokens :: ParameterScope p => TransferTokens instr p -> Operation' instr | |
OpSetDelegate :: SetDelegate -> Operation' instr | |
OpCreateContract :: (forall i o. Show (instr i o), forall i o. NFData (instr i o), Typeable instr, ParameterScope cp, StorageScope st) => CreateContract instr cp st -> Operation' instr | |
OpEmit :: PackedValScope t => Emit instr t -> Operation' instr |
Instances
data SetDelegate Source #
Constructors
SetDelegate | |
Fields |
Instances
data TransferTokens instr p Source #
Constructors
TransferTokens | |
Fields
|
Instances
Constructors
PackedValScope t => Emit | |
data Value' instr t where Source #
Representation of a Michelson value.
Since values (i.e. lambdas, operations) can include instructions, this type
depends on the type used to represent instructions, which is the parameter
instr
. It is itself a polymorphic type, parametrized by the Michelson types of
its input and output stacks.
The primary motivator for polymorphism is breaking cyclic dependencies between
this module and Morley.Michelson.Typed.Instr. In principle instr
can also be
used as an extension point, but at the time of writing it isn't used as such, it
is always eventually unified with Instr
.
t
is the value's Michelson type.
Constructors
VKey :: PublicKey -> Value' instr 'TKey | |
VUnit :: Value' instr 'TUnit | |
VSignature :: Signature -> Value' instr 'TSignature | |
VChainId :: ChainId -> Value' instr 'TChainId | |
VOption :: forall t instr. SingI t => Maybe (Value' instr t) -> Value' instr ('TOption t) | |
VList :: forall t instr. SingI t => [Value' instr t] -> Value' instr ('TList t) | |
VSet :: forall t instr. Comparable t => Set (Value' instr t) -> Value' instr ('TSet t) | |
VOp :: Operation' instr -> Value' instr 'TOperation | |
VContract :: forall arg instr. (SingI arg, ForbidOp arg) => Address -> SomeEntrypointCallT arg -> Value' instr ('TContract arg) | |
VTicket :: forall arg instr. Comparable arg => Address -> Value' instr arg -> Natural -> Value' instr ('TTicket arg) | |
VPair :: forall l r instr. (Value' instr l, Value' instr r) -> Value' instr ('TPair l r) | |
VOr :: forall l r instr. (SingI l, SingI r) => Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r) | |
VLam :: forall inp out instr. (SingI inp, SingI out) => LambdaCode' instr inp out -> Value' instr ('TLambda inp out) | |
VMap :: forall k v instr. (SingI v, Comparable k) => Map (Value' instr k) (Value' instr v) -> Value' instr ('TMap k v) | |
VBigMap | |
Fields
| |
VInt :: Integer -> Value' instr 'TInt | |
VNat :: Natural -> Value' instr 'TNat | |
VString :: MText -> Value' instr 'TString | |
VBytes :: ByteString -> Value' instr 'TBytes | |
VMutez :: Mutez -> Value' instr 'TMutez | |
VBool :: Bool -> Value' instr 'TBool | |
VKeyHash :: KeyHash -> Value' instr 'TKeyHash | |
VTimestamp :: Timestamp -> Value' instr 'TTimestamp | |
VAddress :: EpAddress -> Value' instr 'TAddress | |
VBls12381Fr :: Bls12381Fr -> Value' instr 'TBls12381Fr | |
VBls12381G1 :: Bls12381G1 -> Value' instr 'TBls12381G1 | |
VBls12381G2 :: Bls12381G2 -> Value' instr 'TBls12381G2 | |
VChest :: Chest -> Value' instr 'TChest | |
VChestKey :: ChestKey -> Value' instr 'TChestKey |
Instances
data RemFail (instr :: k -> k -> Type) (i :: k) (o :: k) where Source #
Wrapper over instruction which remembers whether this instruction always fails or not.
Constructors
RfNormal :: instr i o -> RemFail instr i o | |
RfAlwaysFails :: (forall o'. instr i o') -> RemFail instr i o |
Instances
(forall (o' :: k). Show (instr i o')) => Show (RemFail instr i o) Source # | |
(forall (o' :: k). NFData (instr i o')) => NFData (RemFail instr i o) Source # | |
Defined in Morley.Michelson.Typed.Value | |
Eq (instr i o) => Eq (RemFail instr i o) Source # | Ignoring distinction between constructors here, comparing only semantics. |
data LambdaCode' instr inp out where Source #
Code of a lambda value, either recursive or non-recursive.
Note the quantified constraints on the constructors. We opt to carry those here
and not on the respective instances for the sake of simplifying downstream
instance definitions. Constraining each instance with quantified constraints
gets very long-winded very fast, and it wouldn't work with deriveGADTNFData
.
Constructors
LambdaCode :: (forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => RemFail instr (inp ': '[]) (out ': '[]) -> LambdaCode' instr inp out | |
LambdaCodeRec :: (forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => RemFail instr (inp ': ('TLambda inp out ': '[])) (out ': '[]) -> LambdaCode' instr inp out |
Instances
Show (LambdaCode' instr inp out) Source # | |
Defined in Morley.Michelson.Typed.Value Methods showsPrec :: Int -> LambdaCode' instr inp out -> ShowS # show :: LambdaCode' instr inp out -> String # showList :: [LambdaCode' instr inp out] -> ShowS # | |
NFData (LambdaCode' instr inp out) Source # | |
Defined in Morley.Michelson.Typed.Value Methods rnf :: LambdaCode' instr inp out -> () # | |
Eq (LambdaCode' instr inp out) Source # | |
Defined in Morley.Michelson.Typed.Value Methods (==) :: LambdaCode' instr inp out -> LambdaCode' instr inp out -> Bool # (/=) :: LambdaCode' instr inp out -> LambdaCode' instr inp out -> Bool # |
mkVLam :: (SingI inp, SingI out, forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => (IsNotInView => RemFail instr '[inp] '[out]) -> Value' instr ('TLambda inp out) Source #
mkVLamRec :: (SingI inp, SingI out, forall i o. Show (instr i o), forall i o. Eq (instr i o), forall i o. NFData (instr i o)) => (IsNotInView => RemFail instr '[inp, 'TLambda inp out] '[out]) -> Value' instr ('TLambda inp out) Source #
rfMerge :: (forall o'. instr i1 o' -> instr i2 o' -> instr i3 o') -> RemFail instr i1 o -> RemFail instr i2 o -> RemFail instr i3 o Source #
Merge two execution branches.
rfAnyInstr :: RemFail instr i o -> instr i o Source #
Get code disregard whether it always fails or not.
rfMapAnyInstr :: (forall o'. instr i1 o' -> instr i2 o') -> RemFail instr i1 o -> RemFail instr i2 o Source #
Modify inner code.
addressToVContract :: forall t instr kind. (ParameterScope t, ForbidOr t) => KindedAddress kind -> Value' instr ('TContract t) Source #
Make value of contract
type which refers to the given address and
does not call any entrypoint.
buildVContract :: Value' instr ('TContract arg) -> Doc Source #
checkComparability :: Sing t -> Comparability t Source #
Check if type is comparable or not at runtime. This traverses the
singleton, so it has a considerable runtime cost. If you just need to convince
GHC, you may be looking for comparableImplies
, or perhaps
withDeMorganScope
.
>>>
checkComparability STOperation
CannotBeCompared>>>
checkComparability STAddress
CanBeCompared
compileEpLiftSequence :: EpLiftSequence arg param -> Value' instr arg -> Value' instr param Source #
Turn EpLiftSequence
into actual function on Value
s.
liftCallArg :: EntrypointCallT param arg -> Value' instr arg -> Value' instr param Source #
Lift entrypoint argument to full parameter.
withValueTypeSanity :: Value' instr t -> (SingI t => a) -> a Source #
Provide a witness of that value's type is known.