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

Morley.Michelson.Interpret

Description

Module, containing function to interpret Michelson instructions against given context and input stack.

Synopsis

Documentation

data ContractEnv' m Source #

Environment for contract execution. Parametrized by the execution monad, i.e. EvalOp by default, but downstream consumers may define their own if using low-level runners.

Constructors

ContractEnv 

Fields

Instances

Instances details
Monad m => MonadReader (ContractEnv' (EvalOpT m)) (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

ask :: EvalOpT m (ContractEnv' (EvalOpT m)) #

local :: (ContractEnv' (EvalOpT m) -> ContractEnv' (EvalOpT m)) -> EvalOpT m a -> EvalOpT m a #

reader :: (ContractEnv' (EvalOpT m) -> a) -> EvalOpT m a #

data InterpreterState Source #

Instances

Instances details
Generic InterpreterState Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep InterpreterState :: Type -> Type #

Show InterpreterState Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData InterpreterState Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: InterpreterState -> () #

Monad m => MonadState InterpreterState (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Monad m => InterpreterStateMonad (StateT InterpreterState m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

(Monad m, Monoid w) => InterpreterStateMonad (RWST r w InterpreterState m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep InterpreterState Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep InterpreterState = D1 ('MetaData "InterpreterState" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "InterpreterState" 'PrefixI 'True) (S1 ('MetaSel ('Just "isRemainingSteps") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 RemainingSteps) :*: (S1 ('MetaSel ('Just "isGlobalCounter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 GlobalCounter) :*: S1 ('MetaSel ('Just "isBigMapCounter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BigMapCounter))))

data MichelsonFailed ext where Source #

Errors that can be thrown by the interpreter. The ext type variable allow the downstreams consumer to add additional exceptions.

Constructors

MichelsonFailedWith 

Fields

MichelsonArithError :: (Typeable n, Typeable m) => ArithError (Value n) (Value m) -> MichelsonFailed ext 
MichelsonGasExhaustion :: MichelsonFailed ext 
MichelsonFailedTestAssert :: Text -> MichelsonFailed ext 
MichelsonUnsupported :: Text -> MichelsonFailed ext 
MichelsonExt :: ext -> MichelsonFailed ext 

Instances

Instances details
Show ext => Show (MichelsonFailed ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData ext => NFData (MichelsonFailed ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: MichelsonFailed ext -> () #

Eq ext => Eq (MichelsonFailed ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Buildable ext => Buildable (MichelsonFailed ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: MichelsonFailed ext -> Doc

buildList :: [MichelsonFailed ext] -> Doc

data MichelsonFailureWithStack ext Source #

Carries a MichelsonFailed ext error and the ErrorSrcPos at which it was raised

Instances

Instances details
Generic (MichelsonFailureWithStack ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep (MichelsonFailureWithStack ext) :: Type -> Type #

Show ext => Show (MichelsonFailureWithStack ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData ext => NFData (MichelsonFailureWithStack ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: MichelsonFailureWithStack ext -> () #

Eq ext => Eq (MichelsonFailureWithStack ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Buildable ext => Buildable (MichelsonFailureWithStack ext) Source #

Pretty-printer for MichelsonFailureWithStack.

>>> let pos = ErrorSrcPos $ SrcPos (Pos 123) (Pos 456)
>>> let largeValue = VList $ replicate 10 VUnit
>>> pretty $ MichelsonFailureWithStack @Void MichelsonGasExhaustion pos
Gas limit exceeded on contract execution at line 124 char 457.
>>> pretty $ MichelsonFailureWithStack @Void (MichelsonFailedWith VUnit) pos
Reached FAILWITH instruction with 'Unit' at line 124 char 457.
>>> pretty $ MichelsonFailureWithStack @Void (MichelsonFailedWith largeValue) pos
Reached FAILWITH instruction with
  { Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit }
at line 124 char 457.
>>> pretty $ MichelsonFailureWithStack @Void (MichelsonFailedWith $ VPair (largeValue, largeValue)) pos
Reached FAILWITH instruction with
  Pair
    { Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit }
    { Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit; Unit }
at line 124 char 457.
Instance details

Defined in Morley.Michelson.Interpret

Monad m => MonadError (MichelsonFailureWithStack Void) (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep (MichelsonFailureWithStack ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep (MichelsonFailureWithStack ext) = D1 ('MetaData "MichelsonFailureWithStack" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "MichelsonFailureWithStack" 'PrefixI 'True) (S1 ('MetaSel ('Just "mfwsFailed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MichelsonFailed ext)) :*: S1 ('MetaSel ('Just "mfwsErrorSrcPos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ErrorSrcPos)))

newtype RemainingSteps Source #

Constructors

RemainingSteps Word64 

Instances

Instances details
Generic RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep RemainingSteps :: Type -> Type #

Num RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Show RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: RemainingSteps -> () #

Eq RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Ord RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Buildable RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: RemainingSteps -> Doc

buildList :: [RemainingSteps] -> Doc

type Rep RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep RemainingSteps = D1 ('MetaData "RemainingSteps" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'True) (C1 ('MetaCons "RemainingSteps" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

data SomeItStack meta where Source #

Constructors

SomeItStack :: ExtInstr inp -> Rec (StkEl meta) inp -> SomeItStack meta 

newtype MorleyLogs Source #

Morley logs appearing as interpreter result.

Constructors

MorleyLogs 

Fields

Instances

Instances details
Monoid MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Semigroup MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Generic MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep MorleyLogs :: Type -> Type #

Show MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: MorleyLogs -> () #

Eq MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Buildable MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: MorleyLogs -> Doc

buildList :: [MorleyLogs] -> Doc

type Rep MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogs = D1 ('MetaData "MorleyLogs" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'True) (C1 ('MetaCons "MorleyLogs" 'PrefixI 'True) (S1 ('MetaSel ('Just "unMorleyLogs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))

newtype MorleyLogsBuilder Source #

Morley logs accumulator, for incremental building.

Constructors

MorleyLogsBuilder (Endo [Text]) 

Instances

Instances details
Monoid MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

Semigroup MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

Generic MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep MorleyLogsBuilder :: Type -> Type #

Default MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

One MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type OneItem MorleyLogsBuilder #

Monad m => MonadWriter MorleyLogsBuilder (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogsBuilder = D1 ('MetaData "MorleyLogsBuilder" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'True) (C1 ('MetaCons "MorleyLogsBuilder" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Endo [Text]))))
type OneItem MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

interpretInstr :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec Value out) Source #

Interpret an instruction in vacuum, putting no extra constraints on its execution.

Mostly for testing purposes.

interpretInstrAnnotated :: ContractEnv -> Instr inp out -> Rec Value inp -> Either (MichelsonFailureWithStack Void) (Rec (StkEl NoStkElMeta) out) Source #

Interpret an instruction in vacuum, putting no extra constraints on its execution while preserving its annotations.

Mostly for testing purposes.

type InterpretReturn ty = RunEvalOpReturn (Value ty) Source #

Result of interpretView. A version of RunEvalOpReturn specialized to Value.

type ContractReturn st = InterpretReturn (ContractOut1 st) Source #

Result of interpret. A version of InterpretReturn specialized to ContractOut1.

type RunEvalOpReturn a = ResultStateLogs (Either (MichelsonFailureWithStack Void) a) Source #

Result of runEvalOp. Essentially, return value (possibly failing), state and logs.

data ResultStateLogs res Source #

Instances

Instances details
Foldable ResultStateLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

fold :: Monoid m => ResultStateLogs m -> m #

foldMap :: Monoid m => (a -> m) -> ResultStateLogs a -> m #

foldMap' :: Monoid m => (a -> m) -> ResultStateLogs a -> m #

foldr :: (a -> b -> b) -> b -> ResultStateLogs a -> b #

foldr' :: (a -> b -> b) -> b -> ResultStateLogs a -> b #

foldl :: (b -> a -> b) -> b -> ResultStateLogs a -> b #

foldl' :: (b -> a -> b) -> b -> ResultStateLogs a -> b #

foldr1 :: (a -> a -> a) -> ResultStateLogs a -> a #

foldl1 :: (a -> a -> a) -> ResultStateLogs a -> a #

toList :: ResultStateLogs a -> [a] #

null :: ResultStateLogs a -> Bool #

length :: ResultStateLogs a -> Int #

elem :: Eq a => a -> ResultStateLogs a -> Bool #

maximum :: Ord a => ResultStateLogs a -> a #

minimum :: Ord a => ResultStateLogs a -> a #

sum :: Num a => ResultStateLogs a -> a #

product :: Num a => ResultStateLogs a -> a #

Traversable ResultStateLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

traverse :: Applicative f => (a -> f b) -> ResultStateLogs a -> f (ResultStateLogs b) #

sequenceA :: Applicative f => ResultStateLogs (f a) -> f (ResultStateLogs a) #

mapM :: Monad m => (a -> m b) -> ResultStateLogs a -> m (ResultStateLogs b) #

sequence :: Monad m => ResultStateLogs (m a) -> m (ResultStateLogs a) #

Functor ResultStateLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

fmap :: (a -> b) -> ResultStateLogs a -> ResultStateLogs b #

(<$) :: a -> ResultStateLogs b -> ResultStateLogs a #

Generic (ResultStateLogs res) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep (ResultStateLogs res) :: Type -> Type #

Methods

from :: ResultStateLogs res -> Rep (ResultStateLogs res) x #

to :: Rep (ResultStateLogs res) x -> ResultStateLogs res #

Show res => Show (ResultStateLogs res) Source # 
Instance details

Defined in Morley.Michelson.Interpret

NFData res => NFData (ResultStateLogs res) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

rnf :: ResultStateLogs res -> () #

type Rep (ResultStateLogs res) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep (ResultStateLogs res) = D1 ('MetaData "ResultStateLogs" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "ResultStateLogs" 'PrefixI 'True) (S1 ('MetaSel ('Just "rslResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 res) :*: (S1 ('MetaSel ('Just "rslState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 InterpreterState) :*: S1 ('MetaSel ('Just "rslLogs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 MorleyLogs))))

mkInitStack :: Value param -> Value st -> Rec Value (ContractInp param st) Source #

data InterpretError ext Source #

Instances

Instances details
Generic (InterpretError ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Associated Types

type Rep (InterpretError ext) :: Type -> Type #

Methods

from :: InterpretError ext -> Rep (InterpretError ext) x #

to :: Rep (InterpretError ext) x -> InterpretError ext #

Show ext => Show (InterpretError ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Buildable ext => Buildable (InterpretError ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: InterpretError ext -> Doc

buildList :: [InterpretError ext] -> Doc

type Rep (InterpretError ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep (InterpretError ext) = D1 ('MetaData "InterpretError" "Morley.Michelson.Interpret" "morley-1.20.0-inplace" 'False) (C1 ('MetaCons "InterpretError" 'PrefixI 'True) (S1 ('MetaSel ('Just "ieLogs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 MorleyLogs) :*: S1 ('MetaSel ('Just "ieFailure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (MichelsonFailureWithStack ext))))

type InterpretResult ty = ResultStateLogs (Value ty) Source #

Pure result of an interpretation, i.e. return value, final interpreter state and execution logs.

type ContractResult ty = InterpretResult (ContractOut1 ty) Source #

Pure result of contract interpretation. A specialized version of InterpretResult.

extractValOps :: Value (ContractOut1 st) -> ([Operation], Value st) Source #

Extract list of operations from ContractOut1 Value.

type EvalM m = EvalM' Void m Source #

class Monad m => InterpreterStateMonad m where Source #

Minimal complete definition

Nothing

Instances

Instances details
Monad m => InterpreterStateMonad (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

InterpreterStateMonad m => InterpreterStateMonad (ExceptT e m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

InterpreterStateMonad m => InterpreterStateMonad (ReaderT r m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Monad m => InterpreterStateMonad (StateT InterpreterState m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

InterpreterStateMonad m => InterpreterStateMonad (StateT w m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

(InterpreterStateMonad m, Monoid w) => InterpreterStateMonad (WriterT w m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

(Monad m, Monoid w) => InterpreterStateMonad (RWST r w InterpreterState m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

(InterpreterStateMonad m, Monoid w) => InterpreterStateMonad (RWST r w s m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

data StkEl meta t Source #

Represents a value on the stack. Aside from the value itself, it contains arbitrary user-defined metadata. The metadata in question is defined by StkElMeta type class, the interpreter doesn't know anything about it.

The metadata should not be copied between different stack elements, the only case where it can be copied is when the stack element is copied in its entirety, i.e. when running instructions like DUP.

To create a new StkEl from a value, mkStkEl should always be used. For duplicated stack elements, mkDuplicateStkEl should be used instead, to still give the user an option to override metadata for the duplicated element.

The data constructor should almost never be used by itself.

Constructors

MkStkEl 

Fields

Bundled Patterns

pattern StkEl :: Value t -> StkEl meta t 

Instances

Instances details
(forall (t :: T). Eq (meta t)) => GEq (StkEl meta :: T -> Type) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

geq :: forall (a :: k) (b :: k). StkEl meta a -> StkEl meta b -> Maybe (a :~: b) #

Show (meta t) => Show (StkEl meta t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

showsPrec :: Int -> StkEl meta t -> ShowS #

show :: StkEl meta t -> String #

showList :: [StkEl meta t] -> ShowS #

Eq (meta t) => Eq (StkEl meta t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

(==) :: StkEl meta t -> StkEl meta t -> Bool #

(/=) :: StkEl meta t -> StkEl meta t -> Bool #

data NoStkElMeta t Source #

Default metadata that does nothing.

Constructors

NoStkElMeta 

Instances

Instances details
Applicative m => StkElMeta (NoStkElMeta :: T -> Type) m Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

mkStkElMeta :: forall (t :: T). Maybe (NoStkElMeta t) -> Value t -> m (NoStkElMeta t) Source #

Show (NoStkElMeta t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Eq (NoStkElMeta t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

seValueL :: forall meta t. Lens' (StkEl meta t) (Value t) Source #

seMetaL :: forall meta t meta. Lens (StkEl meta t) (StkEl meta t) (meta t) (meta t) Source #

type InstrRunner meta m = forall inp out. Instr inp out -> Rec (StkEl meta) inp -> m (Rec (StkEl meta) out) Source #

runInstr :: forall ext meta m. (StkElMeta meta m, EvalM' ext m) => InstrRunner meta m Source #

Function to change amount of remaining steps stored in State monad.

runUnpack :: forall t. UnpackedValScope t => ByteString -> Either UnpackError (Value t) Source #

Unpacks given raw data into a typed value.

Views

interpretView :: View arg st ret -> Value st -> Value arg -> ContractEnv -> InterpreterState -> InterpretReturn ret Source #

Interpret a contract's view for given ContractEnv and initial InterpreterState. It is assumed ContractEnv is suitable for the view call, that is, the view is executed exactly in the env that's passed here.

getViewByName :: Contract cp st -> ViewName -> Either ViewLookupError (SomeView st) Source #

Attempt to find a view with a given name in a given contract.

getViewByNameAndType :: forall arg ret cp st. (SingI arg, SingI ret) => Contract cp st -> ViewName -> Either ViewLookupError (View arg st ret) Source #

Attempt to find a view with a given name and given type in a given contract.

Internals

handleReturn :: InterpretReturn res -> Either (InterpretError Void) (ResultStateLogs (Value res)) Source #

On failure, attach logs to failure, but throw away the final state.

runInstrImpl :: forall ext meta m. (EvalM' ext m, StkElMeta meta m) => InstrRunner meta m -> InstrRunner meta m Source #

Function to interpret Michelson instruction(s) against given stack. The ext type variable specifies additional exceptions that can be thrown from the inner runner function (via MichelsonExt). In Morley, it's set to Void, but downstream consumers may use other type here.

assignBigMapIds Source #

Arguments

:: MonadState BigMapCounter m 
=> Bool

If true, assign a new ID even if the bigmap already has one. Otherwise, assign IDs only to bigmaps that don't have one yet.

-> Value t 
-> m (Value t) 

All big_maps stored in a chain have a globally unique ID.

We use this function to assign a new ID whenever a big_map is created.

mapToStkEl :: forall meta inp m. (Applicative m, StkElMeta meta m) => Rec Value inp -> m (Rec (StkEl meta) inp) Source #

Helper function to convert a record of Value to StkEl.

mapToValue :: Rec (StkEl meta) inp -> Rec Value inp Source #

Helper function to convert a record of StkEl to Value.

mkStkEl :: forall meta t m. (Applicative m, StkElMeta meta m) => Value t -> m (StkEl meta t) Source #

Make an entirely new StkEl from a value.

mkDuplicateStkEl :: forall meta t m. (Applicative m, StkElMeta meta m) => StkEl meta t -> m (StkEl meta t) Source #

Make a duplicate StkEl, constructing metadata via mkStkElMeta.

interpret' :: forall cp st arg m. Monad m => Contract cp st -> EntrypointCallT cp arg -> Value arg -> Value st -> ContractEnv' (EvalOpT m) -> InterpreterState -> m (ContractReturn st) Source #

interpretView' :: forall ret st m arg ext meta. (StkElMeta meta m, EvalM' ext m) => (forall inp out. Instr inp out -> Rec (StkEl meta) inp -> m (Rec (StkEl meta) out)) -> (ContractEnv' m -> ContractEnv' m) -> View arg st ret -> Value st -> Value arg -> m (Value ret) Source #

EvalM view interpretation helper.

class (forall t. Eq (meta t), forall t. Show (meta t)) => StkElMeta meta m where Source #

Arbitrary stack element metadata that can be constructed in a particular monad. Interpreter doesn't know anything about metadata, and doesn't try to do anything with it. mkStkElMeta describes how to construct metadata for new stack elements based on its value. When a stack element is duplicated, specifically with instructions like DUP, old metadata is passed to mkStkElMeta to provide an opportunity to modify it. Implementation is free to either copy it verbatim or ignore the old and generate new.

See StkEl documentation for an overview of the motivation and design.

Methods

mkStkElMeta Source #

Arguments

:: Maybe (meta t)

For instructions duplicating the value, this Just meta from the original instruction, Nothing otherwise

-> Value t

The value for the new stack element.

-> m (meta t) 

How to construct new metadata.

Instances

Instances details
Applicative m => StkElMeta (NoStkElMeta :: T -> Type) m Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

mkStkElMeta :: forall (t :: T). Maybe (NoStkElMeta t) -> Value t -> m (NoStkElMeta t) Source #

newtype EvalOpT m a Source #

The main interpreter monad transformer. Provides a more convenient way of enriching the interpreter monad without redefining it entirely.

This is a newtype and not a type synonym due to the reader environment, i.e. ContractEnv, being parameterized by the interpreter monad.

Instances

Instances details
MonadTrans EvalOpT Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

lift :: Monad m => m a -> EvalOpT m a #

Monad m => MonadState InterpreterState (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Monad m => MonadWriter MorleyLogsBuilder (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

MonadIO m => MonadIO (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

liftIO :: IO a -> EvalOpT m a #

Monad m => Applicative (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

pure :: a -> EvalOpT m a #

(<*>) :: EvalOpT m (a -> b) -> EvalOpT m a -> EvalOpT m b #

liftA2 :: (a -> b -> c) -> EvalOpT m a -> EvalOpT m b -> EvalOpT m c #

(*>) :: EvalOpT m a -> EvalOpT m b -> EvalOpT m b #

(<*) :: EvalOpT m a -> EvalOpT m b -> EvalOpT m a #

Functor m => Functor (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

fmap :: (a -> b) -> EvalOpT m a -> EvalOpT m b #

(<$) :: a -> EvalOpT m b -> EvalOpT m a #

Monad m => Monad (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

(>>=) :: EvalOpT m a -> (a -> EvalOpT m b) -> EvalOpT m b #

(>>) :: EvalOpT m a -> EvalOpT m b -> EvalOpT m b #

return :: a -> EvalOpT m a #

Monad m => InterpreterStateMonad (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Monad m => MonadError (MichelsonFailureWithStack Void) (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Monad m => MonadReader (ContractEnv' (EvalOpT m)) (EvalOpT m) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

ask :: EvalOpT m (ContractEnv' (EvalOpT m)) #

local :: (ContractEnv' (EvalOpT m) -> ContractEnv' (EvalOpT m)) -> EvalOpT m a -> EvalOpT m a #

reader :: (ContractEnv' (EvalOpT m) -> a) -> EvalOpT m a #

type EvalOp = EvalOpT Identity Source #

The main interpreter monad, used by the higher-level functions like interpret and interpretView.

Downstream consumers which use runInstrImpl directly may define their own monad similar to this one, or alternatively use EvalOpT with the slightly lower-level functions, e.g. interpret' and interpretView'.

Prisms