morley-1.16.1: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Morley.Michelson.Runtime.Import

Synopsis

Read, parse, typecheck contract

readContract :: forall cp st. Each '[SingI] [cp, st] => MichelsonSource -> Text -> Either ContractReadError (Contract cp st) Source #

Purely read a typed contract from Michelson textual representation, failing if parameter or storage types mismatch with the expected ones.

readSomeContract :: MichelsonSource -> Text -> Either ContractReadError SomeContract Source #

Purely read a typed contract from Michelson textual representation.

readUntypedContract :: MichelsonSource -> Text -> Either ContractReadError Contract Source #

Purely read an untyped contract from Michelson textual representation.

FilePath is accepted solely as a hint for error messages.

importContract :: forall cp st. Each '[SingI] [cp, st] => FilePath -> IO (Contract cp st) Source #

Import contract from a given file path.

This function reads file, parses and type checks a contract. Within the typechecking we assume that no contracts are originated, otherwise a type checking error will be caused.

This function may throw IOException and ContractReadError.

importSomeContract :: FilePath -> IO SomeContract Source #

Version of importContract that doesn't require you to know contract's parameter and storage types.

importUntypedContract :: FilePath -> IO Contract Source #

Import untyped contract from a given file path.

This function reads file, and parses a contract.

This function may throw IOException and ContractReadError.

Read, parse, typecheck value

readValue :: forall t. SingI t => MichelsonSource -> Text -> Either ValueReadError (Value t) Source #

Purely read a typed Michelson value from textual representation.

importValue :: forall t. SingI t => FilePath -> IO (Value t) Source #

Import a typed value from a given file path.

importSomeValue :: Ty -> FilePath -> IO SomeValue Source #

Import a typed value from a given file path.

Expected type is provided explicitly.

importUntypedValue :: FilePath -> IO Value Source #

Import an untyped value from a given file path.

Generic helpers

data MichelsonSource Source #

Where a contract or value in Michelson comes from.

Constructors

MSFile FilePath

From given file.

MSName Text

Only source name is known.

MSCode SrcLoc

Defined in Haskell code.

MSUnspecified

Some unknown source.

Bundled Patterns

pattern MSStdin :: MichelsonSource

Designates stdin source.

pattern MSCli :: MichelsonSource

Designates command line input source.

importUsing :: Exception e => (MichelsonSource -> Text -> Either e a) -> FilePath -> IO a Source #

Read a thing from a file, using the provided parsing function.