morley-1.20.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Michelson.Typed.Value

Description

Module, containing data types for Michelson value.

Synopsis

Documentation

data CreateContract instr cp st Source #

Constructors

(forall i o. Show (instr i o), forall i o. Eq (instr i o)) => CreateContract 

Instances

Instances details
Show (CreateContract instr cp st) Source # 
Instance details

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 # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: CreateContract instr cp st -> () #

Eq (CreateContract instr cp st) Source # 
Instance details

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 # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

build :: CreateContract instr cp st -> Doc

buildList :: [CreateContract instr cp st] -> Doc

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

Instances details
HasRPCRepr Operation Source # 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC Operation Source #

TypeHasDoc Operation Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

IsoValue Operation Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT Operation :: T Source #

Show (Operation' instr) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

showsPrec :: Int -> Operation' instr -> ShowS #

show :: Operation' instr -> String #

showList :: [Operation' instr] -> ShowS #

NFData (Operation' instr) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: Operation' instr -> () #

Eq (Operation' instr) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

(==) :: Operation' instr -> Operation' instr -> Bool #

(/=) :: Operation' instr -> Operation' instr -> Bool #

(forall (t :: T). Buildable (Value' instr t)) => Buildable (Operation' instr) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

build :: Operation' instr -> Doc

buildList :: [Operation' instr] -> Doc

type AsRPC Operation Source # 
Instance details

Defined in Morley.AsRPC

type TypeDocFieldDescriptions Operation Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Doc

type ToT Operation Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

data SetDelegate Source #

Instances

Instances details
Generic SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Associated Types

type Rep SetDelegate :: Type -> Type #

Show SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

NFData SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: SetDelegate -> () #

Eq SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Buildable SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

build :: SetDelegate -> Doc

buildList :: [SetDelegate] -> Doc

type Rep SetDelegate Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Rep SetDelegate = D1 ('MetaData "SetDelegate" "Morley.Michelson.Typed.Value" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "SetDelegate" 'PrefixI 'True) (S1 ('MetaSel ('Just "sdMbKeyHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe KeyHash)) :*: S1 ('MetaSel ('Just "sdCounter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 GlobalCounter)))

data TransferTokens instr p Source #

Instances

Instances details
Generic (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Associated Types

type Rep (TransferTokens instr p) :: Type -> Type #

Methods

from :: TransferTokens instr p -> Rep (TransferTokens instr p) x #

to :: Rep (TransferTokens instr p) x -> TransferTokens instr p #

Show (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

showsPrec :: Int -> TransferTokens instr p -> ShowS #

show :: TransferTokens instr p -> String #

showList :: [TransferTokens instr p] -> ShowS #

NFData (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: TransferTokens instr p -> () #

Eq (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

(==) :: TransferTokens instr p -> TransferTokens instr p -> Bool #

(/=) :: TransferTokens instr p -> TransferTokens instr p -> Bool #

Buildable (Value' instr p) => Buildable (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

build :: TransferTokens instr p -> Doc

buildList :: [TransferTokens instr p] -> Doc

type Rep (TransferTokens instr p) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Rep (TransferTokens instr p) = D1 ('MetaData "TransferTokens" "Morley.Michelson.Typed.Value" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "TransferTokens" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ttTransferArgument") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Value' instr p)) :*: S1 ('MetaSel ('Just "ttAmount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Mutez)) :*: (S1 ('MetaSel ('Just "ttContract") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Value' instr ('TContract p))) :*: S1 ('MetaSel ('Just "ttCounter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 GlobalCounter))))

data Emit instr t Source #

Constructors

PackedValScope t => Emit 

Fields

Instances

Instances details
Show (Emit instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

showsPrec :: Int -> Emit instr t -> ShowS #

show :: Emit instr t -> String #

showList :: [Emit instr t] -> ShowS #

NFData (Emit instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: Emit instr t -> () #

Eq (Emit instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

(==) :: Emit instr t -> Emit instr t -> Bool #

(/=) :: Emit instr t -> Emit instr t -> Bool #

Buildable (Value' instr t) => Buildable (Emit instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

build :: Emit instr t -> Doc

buildList :: [Emit instr t] -> Doc

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

Instances details
(FromExp x Value, SingI t) => FromExp x (Value t) Source # 
Instance details

Defined in Morley.Micheline.Class

Methods

fromExp :: Exp x -> Either (FromExpError x) (Value t) Source #

GEq (Value' instr :: T -> Type) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

geq :: forall (a :: k) (b :: k). Value' instr a -> Value' instr b -> Maybe (a :~: b) #

HasRPCRepr (Value t) Source # 
Instance details

Defined in Morley.AsRPC

Associated Types

type AsRPC (Value t) Source #

ForbidOp t => ToExpression (Value t) Source # 
Instance details

Defined in Morley.Micheline.Class

(forall (t :: T). cs t => ForbidOp t) => RenderDoc (SomeConstrainedValue cs) Source # 
Instance details

Defined in Morley.Michelson.Typed.Existential

WellTyped t => IsoValue (Value t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

Associated Types

type ToT (Value t) :: T Source #

Methods

toVal :: Value t -> Value (ToT (Value t)) Source #

fromVal :: Value (ToT (Value t)) -> Value t Source #

Show (Value' instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

showsPrec :: Int -> Value' instr t -> ShowS #

show :: Value' instr t -> String #

showList :: [Value' instr t] -> ShowS #

NFData (Value' instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: Value' instr t -> () #

Eq (Value' instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

(==) :: Value' instr t -> Value' instr t -> Bool #

(/=) :: Value' instr t -> Value' instr t -> Bool #

Comparable t => Ord (Value' instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

compare :: Value' instr t -> Value' instr t -> Ordering #

(<) :: Value' instr t -> Value' instr t -> Bool #

(<=) :: Value' instr t -> Value' instr t -> Bool #

(>) :: Value' instr t -> Value' instr t -> Bool #

(>=) :: Value' instr t -> Value' instr t -> Bool #

max :: Value' instr t -> Value' instr t -> Value' instr t #

min :: Value' instr t -> Value' instr t -> Value' instr t #

At (Value' instr ('TBigMap k v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

at :: Index (Value' instr ('TBigMap k v)) -> Lens' (Value' instr ('TBigMap k v)) (Maybe (IxValue (Value' instr ('TBigMap k v)))) #

At (Value' instr ('TMap k v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

at :: Index (Value' instr ('TMap k v)) -> Lens' (Value' instr ('TMap k v)) (Maybe (IxValue (Value' instr ('TMap k v)))) #

At (Value' instr ('TSet a)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

at :: Index (Value' instr ('TSet a)) -> Lens' (Value' instr ('TSet a)) (Maybe (IxValue (Value' instr ('TSet a)))) #

Ixed (Value' instr ('TBigMap k v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

ix :: Index (Value' instr ('TBigMap k v)) -> Traversal' (Value' instr ('TBigMap k v)) (IxValue (Value' instr ('TBigMap k v))) #

Ixed (Value' instr ('TList elem)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

ix :: Index (Value' instr ('TList elem)) -> Traversal' (Value' instr ('TList elem)) (IxValue (Value' instr ('TList elem))) #

Ixed (Value' instr ('TMap k v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

ix :: Index (Value' instr ('TMap k v)) -> Traversal' (Value' instr ('TMap k v)) (IxValue (Value' instr ('TMap k v))) #

Ixed (Value' instr ('TSet a)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

ix :: Index (Value' instr ('TSet a)) -> Traversal' (Value' instr ('TSet a)) (IxValue (Value' instr ('TSet a))) #

ForbidOp t => RenderDoc (Value' Instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Convert

Buildable (Value' Instr t) 
Instance details

Defined in Morley.Michelson.Typed.Convert

Methods

build :: Value' Instr t -> Doc

buildList :: [Value' Instr t] -> Doc

type AsRPC (Value t) Source # 
Instance details

Defined in Morley.AsRPC

type AsRPC (Value t) = Value (TAsRPC t)
type ToT (Value t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Haskell.Value

type ToT (Value t) = t
type Index (Value' _1 ('TList _2)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Index (Value' _1 ('TList _2)) = Int
type Index (Value' instr ('TBigMap k _1)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Index (Value' instr ('TBigMap k _1)) = Value' instr k
type Index (Value' instr ('TMap k _1)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Index (Value' instr ('TMap k _1)) = Value' instr k
type Index (Value' instr ('TSet a)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type Index (Value' instr ('TSet a)) = Value' instr a
type IxValue (Value' _1 ('TSet _2)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type IxValue (Value' _1 ('TSet _2)) = ()
type IxValue (Value' instr ('TBigMap _1 v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type IxValue (Value' instr ('TBigMap _1 v)) = Value' instr v
type IxValue (Value' instr ('TList elem)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type IxValue (Value' instr ('TList elem)) = Value' instr elem
type IxValue (Value' instr ('TMap _1 v)) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

type IxValue (Value' instr ('TMap _1 v)) = Value' instr v

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

Instances details
(forall (o' :: k). Show (instr i o')) => Show (RemFail instr i o) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

showsPrec :: Int -> RemFail instr i o -> ShowS #

show :: RemFail instr i o -> String #

showList :: [RemFail instr i o] -> ShowS #

(forall (o' :: k). NFData (instr i o')) => NFData (RemFail instr i o) Source # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: RemFail instr i o -> () #

Eq (instr i o) => Eq (RemFail instr i o) Source #

Ignoring distinction between constructors here, comparing only semantics.

Instance details

Defined in Morley.Michelson.Typed.Value

Methods

(==) :: RemFail instr i o -> RemFail instr i o -> Bool #

(/=) :: RemFail instr i o -> RemFail instr i o -> Bool #

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

Instances details
Show (LambdaCode' instr inp out) Source # 
Instance details

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 # 
Instance details

Defined in Morley.Michelson.Typed.Value

Methods

rnf :: LambdaCode' instr inp out -> () #

Eq (LambdaCode' instr inp out) Source # 
Instance details

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 Values.

liftCallArg :: EntrypointCallT param arg -> Value' instr arg -> Value' instr param Source #

Lift entrypoint argument to full parameter.

valueTypeSanity :: Value' instr t -> Dict (SingI t) Source #

Get a witness of that value's type is known.

Note that we cannot pick such witness out of nowhere as not all types of kind T have Typeable and SingI instances; example:

type family Any :: T where
  -- nothing here

withValueTypeSanity :: Value' instr t -> (SingI t => a) -> a Source #

Provide a witness of that value's type is known.

eqValueExt :: Value' instr t1 -> Value' instr t2 -> Bool Source #

Extended values comparison - it does not require Values to be of the same type, only their content to match.