Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions to import contracts to be used in tests.
Synopsis
- readContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => MichelsonSource -> Text -> Either ContractReadError (Contract cp st)
- readUntypedContract :: MichelsonSource -> Text -> Either ContractReadError Contract
- readSomeContract :: MichelsonSource -> Text -> Either ContractReadError SomeContract
- importContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => FilePath -> IO (Contract cp st)
- importUntypedContract :: FilePath -> IO Contract
- importSomeContract :: FilePath -> IO SomeContract
- embedContract :: forall cp st. (SingI cp, SingI st) => FilePath -> Code Q (Contract cp st)
- embedContractM :: forall cp st. (SingI cp, SingI st) => IO FilePath -> Code Q (Contract cp st)
- data ContractReadError
- = CREParse MichelsonSource ParserException
- | CRETypeCheck MichelsonSource TcError
- readValue :: forall (t :: T). SingI t => MichelsonSource -> Text -> Either ValueReadError (Value t)
- importValue :: forall (t :: T). SingI t => FilePath -> IO (Value t)
- importSomeValue :: Ty -> FilePath -> IO SomeValue
- importUntypedValue :: FilePath -> IO Value
- data ValueReadError
- = VREParse MichelsonSource ParserException
- | VRETypeCheck MichelsonSource TcError
- testTreesWithContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree]
- testTreesWithTypedContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree]
- testTreesWithUntypedContract :: HasCallStack => FilePath -> (Contract -> IO [TestTree]) -> IO [TestTree]
- concatTestTrees :: [IO [TestTree]] -> IO [TestTree]
- embedTextFile :: FilePath -> Q Text
Read, parse, typecheck
readContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => MichelsonSource -> Text -> Either ContractReadError (Contract cp st) #
readUntypedContract :: MichelsonSource -> Text -> Either ContractReadError Contract #
readSomeContract :: MichelsonSource -> Text -> Either ContractReadError SomeContract #
importContract :: forall (cp :: T) (st :: T). Each '[SingI :: T -> Constraint] '[cp, st] => FilePath -> IO (Contract cp st) #
importUntypedContract :: FilePath -> IO Contract #
importSomeContract :: FilePath -> IO SomeContract #
embedContract :: forall cp st. (SingI cp, SingI st) => FilePath -> Code Q (Contract cp st) Source #
Import a contract at compile time assuming its expected type is known.
Use it like:
myContract :: Contract (ToT Parameter) (ToT Storage) myContract = $$(embedContract "my_contract.tz")
or
let myContract = $$(embedContract @(ToT Parameter) @(ToT Storage) "my_contract.tz")
embedContractM :: forall cp st. (SingI cp, SingI st) => IO FilePath -> Code Q (Contract cp st) Source #
Version of embedContract
that accepts a filepath constructor in IO.
Useful when the path should depend on environmental variables or other user input.
data ContractReadError #
CREParse MichelsonSource ParserException | |
CRETypeCheck MichelsonSource TcError |
Instances
Exception ContractReadError | |
Show ContractReadError | |
Defined in Morley.Michelson.Runtime.Import showsPrec :: Int -> ContractReadError -> ShowS # show :: ContractReadError -> String # showList :: [ContractReadError] -> ShowS # | |
Buildable ContractReadError | |
Defined in Morley.Michelson.Runtime.Import build :: ContractReadError -> Builder # | |
Eq ContractReadError | |
Defined in Morley.Michelson.Runtime.Import (==) :: ContractReadError -> ContractReadError -> Bool # (/=) :: ContractReadError -> ContractReadError -> Bool # |
Read, parse, typecheck value
readValue :: forall (t :: T). SingI t => MichelsonSource -> Text -> Either ValueReadError (Value t) #
importValue :: forall (t :: T). SingI t => FilePath -> IO (Value t) #
importSomeValue :: Ty -> FilePath -> IO SomeValue #
importUntypedValue :: FilePath -> IO Value #
data ValueReadError #
VREParse MichelsonSource ParserException | |
VRETypeCheck MichelsonSource TcError |
Instances
Exception ValueReadError | |
Defined in Morley.Michelson.Runtime.Import | |
Show ValueReadError | |
Defined in Morley.Michelson.Runtime.Import showsPrec :: Int -> ValueReadError -> ShowS # show :: ValueReadError -> String # showList :: [ValueReadError] -> ShowS # | |
Buildable ValueReadError | |
Defined in Morley.Michelson.Runtime.Import build :: ValueReadError -> Builder # | |
Eq ValueReadError | |
Defined in Morley.Michelson.Runtime.Import (==) :: ValueReadError -> ValueReadError -> Bool # (/=) :: ValueReadError -> ValueReadError -> Bool # |
Tasty helpers
testTreesWithContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree] Source #
Import contract and use to create test trees. Both versions of contract are passed to the callback function (untyped and typed).
If contract's import fails, a tree with single failing test will be generated (so test tree will likely be generated unexceptionally, but a failing result will notify about problem).
testTreesWithTypedContract :: (Each '[SingI] [cp, st], HasCallStack) => FilePath -> (Contract cp st -> IO [TestTree]) -> IO [TestTree] Source #
Like testTreesWithContract
but supplies only typed contract.
testTreesWithUntypedContract :: HasCallStack => FilePath -> (Contract -> IO [TestTree]) -> IO [TestTree] Source #
Like testTreesWithContract
but supplies only untyped contract.