| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Cleveland.Lorentz.Import
Description
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)
- embedContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> Code Q (Contract cp st vd)
- embedContractM :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => IO FilePath -> Code Q (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 -> Code Q a
- embedValueM :: forall a. IsoValue a => IO FilePath -> Code Q 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.
embedContract :: forall cp st vd. (NiceParameter cp, NiceStorage st, NiceViewsDescriptor vd, DemoteViewsDescriptor vd) => FilePath -> Code Q (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 -> Code Q (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 #
Constructors
| CREParse MichelsonSource ParserException | |
| CRETypeCheck MichelsonSource TcError |
Instances
| Exception ContractReadError | |
Defined in Morley.Michelson.Runtime.Import Methods toException :: ContractReadError -> SomeException # | |
| Show ContractReadError | |
Defined in Morley.Michelson.Runtime.Import Methods showsPrec :: Int -> ContractReadError -> ShowS # show :: ContractReadError -> String # showList :: [ContractReadError] -> ShowS # | |
| Eq ContractReadError | |
Defined in Morley.Michelson.Runtime.Import Methods (==) :: ContractReadError -> ContractReadError -> Bool # (/=) :: ContractReadError -> ContractReadError -> Bool # | |
| Buildable ContractReadError | |
Defined in Morley.Michelson.Runtime.Import | |
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 -> Code Q 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 -> Code Q 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 #
Constructors
| VREParse MichelsonSource ParserException | |
| VRETypeCheck MichelsonSource TcError |
Instances
| Exception ValueReadError | |
Defined in Morley.Michelson.Runtime.Import Methods toException :: ValueReadError -> SomeException # | |
| Show ValueReadError | |
Defined in Morley.Michelson.Runtime.Import Methods showsPrec :: Int -> ValueReadError -> ShowS # show :: ValueReadError -> String # showList :: [ValueReadError] -> ShowS # | |
| Eq ValueReadError | |
Defined in Morley.Michelson.Runtime.Import Methods (==) :: ValueReadError -> ValueReadError -> Bool # (/=) :: ValueReadError -> ValueReadError -> Bool # | |
| Buildable ValueReadError | |
Defined in Morley.Michelson.Runtime.Import | |
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.