Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions to import contracts to be used in tests.
Synopsis
- importContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd)
- importContractExt :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd)
- embedContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> TExpQ (Contract cp st vd)
- embedContractM :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => IO FilePath -> TExpQ (Contract cp st vd)
- data ContractReadError
- = CREParse MichelsonSource ParserException
- | CRETypeCheck MichelsonSource TCError
- importValue :: forall a. IsoValue a => FilePath -> IO a
- embedValue :: forall a. IsoValue a => FilePath -> TExpQ a
- embedValueM :: forall a. IsoValue a => IO FilePath -> TExpQ a
- data ValueReadError
- = VREParse MichelsonSource ParserException
- | VRETypeCheck MichelsonSource TCError
Read, parse, typecheck contracts
importContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd) Source #
Import contract from a given FilePath
.
In this and similar functions, parameter and storage types must exactly match
the ones in the contract, while for views this is not necessary. Only
make sure that all views beyond vd
type are present in the contract; ()
always works as views descriptor of the contract.
importContractExt :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> IO (Contract cp st vd) Source #
Deprecated: Morley extensions are deprecated
Import contract from a given FilePath
, with deprecated Morley extensions.
In this and similar functions, parameter and storage types must exactly match
the ones in the contract, while for views this is not necessary. Only
make sure that all views beyond vd
type are present in the contract; ()
always works as views descriptor of the contract.
embedContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> TExpQ (Contract cp st vd) Source #
Import a contract at compile time assuming its expected type is known.
Use it like:
myContract :: Contract Parameter Storage myContract = $$(embedContract "my_contract.tz")
or
let myContract = $$(embedContract @Parameter @Storage "my_contract.tz")
See also the note in Test.Cleveland.Lorentz.Import
embedContractM :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => IO FilePath -> TExpQ (Contract cp st vd) Source #
Version of embedContract
that accepts a filepath constructor in IO.
Useful when the path should depend on environmental variables or other user input.
See also the note in Test.Cleveland.Lorentz.Import
data ContractReadError #
CREParse MichelsonSource ParserException | |
CRETypeCheck MichelsonSource TCError |
Instances
Eq ContractReadError | |
Defined in Morley.Michelson.Runtime.Import (==) :: ContractReadError -> ContractReadError -> Bool # (/=) :: ContractReadError -> ContractReadError -> Bool # | |
Show ContractReadError | |
Defined in Morley.Michelson.Runtime.Import showsPrec :: Int -> ContractReadError -> ShowS # show :: ContractReadError -> String # showList :: [ContractReadError] -> ShowS # | |
Exception ContractReadError | |
Buildable ContractReadError | |
Defined in Morley.Michelson.Runtime.Import build :: ContractReadError -> Builder # |
Read, parse, typecheck values
importValue :: forall a. IsoValue a => FilePath -> IO a Source #
Import a value from a given FilePath
embedValue :: forall a. IsoValue a => FilePath -> TExpQ a Source #
Import a value from a given FilePath
at compile time
and embed it as a value using Template Haskell, f. ex.
let someAddress = $$(embedValue @Address "/path/to/addressFile.tz")
See also the note in Test.Cleveland.Lorentz.Import
embedValueM :: forall a. IsoValue a => IO FilePath -> TExpQ a Source #
A variant of embedValue
that accepts FilePath
in IO
.
Can be useful when FilePath
depends on the environment.
See also the note in Test.Cleveland.Lorentz.Import
data ValueReadError #
VREParse MichelsonSource ParserException | |
VRETypeCheck MichelsonSource TCError |
Instances
Eq ValueReadError | |
Defined in Morley.Michelson.Runtime.Import (==) :: ValueReadError -> ValueReadError -> Bool # (/=) :: ValueReadError -> ValueReadError -> Bool # | |
Show ValueReadError | |
Defined in Morley.Michelson.Runtime.Import showsPrec :: Int -> ValueReadError -> ShowS # show :: ValueReadError -> String # showList :: [ValueReadError] -> ShowS # | |
Exception ValueReadError | |
Defined in Morley.Michelson.Runtime.Import | |
Buildable ValueReadError | |
Defined in Morley.Michelson.Runtime.Import build :: ValueReadError -> Builder # |
Notes
On FilePath
argument with embedContract
, embedValue
and variants
The FilePath
argument is specified relative to the project root (if
using cabal-install or stack, the directory containing the Cabal file and/or package.yaml
).
As an additional caveat, any files embedded this way are essentially compile-time dependencies. However,
build systems can't track these automatically. In general, it's advisable to add the files used
with embedContract
, embedValue
and variants to the extra-source-files
section of the Cabal
file or package.yaml
, if possible.