morley-1.19.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 Source #

Environment for contract execution.

Constructors

ContractEnv 

Fields

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 => 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.19.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 -> () #

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

Defined in Morley.Michelson.Interpret

Methods

build :: MichelsonFailed ext -> Builder #

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

Defined in Morley.Michelson.Interpret

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 -> () #

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

Defined in Morley.Michelson.Interpret

Eq ext => Eq (MichelsonFailureWithStack ext) 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.19.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 -> () #

Buildable RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Eq RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

Ord RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep RemainingSteps Source # 
Instance details

Defined in Morley.Michelson.Interpret

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

data SomeItStack where Source #

Constructors

SomeItStack :: ExtInstr inp -> Rec StkEl inp -> SomeItStack 

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 -> () #

Buildable MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

build :: MorleyLogs -> Builder #

Eq MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogs Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogs = D1 ('MetaData "MorleyLogs" "Morley.Michelson.Interpret" "morley-1.19.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 #

type Rep MorleyLogsBuilder Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep MorleyLogsBuilder = D1 ('MetaData "MorleyLogsBuilder" "Morley.Michelson.Interpret" "morley-1.19.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 out) Source #

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

Mostly for testing purposes.

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

newtype 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 -> Builder #

type Rep (InterpretError ext) Source # 
Instance details

Defined in Morley.Michelson.Interpret

type Rep (InterpretError ext) = D1 ('MetaData "InterpretError" "Morley.Michelson.Interpret" "morley-1.19.0-inplace" 'True) (C1 ('MetaCons "InterpretError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MichelsonFailureWithStack ext, MorleyLogs))))

data InterpretResult where Source #

Constructors

InterpretResult 

Fields

Instances

Instances details
Show InterpretResult Source # 
Instance details

Defined in Morley.Michelson.Interpret

type EvalM m = EvalM' Void m Source #

class Monad m => InterpreterStateMonad m where Source #

Minimal complete definition

Nothing

Instances

Instances details
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

newtype StkEl t Source #

Constructors

StkEl 

Fields

Instances

Instances details
Show (StkEl t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

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

show :: StkEl t -> String #

showList :: [StkEl t] -> ShowS #

Eq (StkEl t) Source # 
Instance details

Defined in Morley.Michelson.Interpret

Methods

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

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

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

runInstr :: EvalM m => InstrRunner 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.

Internals

runInstrImpl :: forall ext m. EvalM' ext m => InstrRunner m -> InstrRunner 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.

Prisms