lorentz-0.4.0: EDSL for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Lorentz.EntryPoints.Impl

Description

Common implementations of entrypoints.

Synopsis

Ways to implement ParameterHasEntryPoints

data EpdPlain Source #

Implementation of ParameterHasEntryPoints which fits for case when your contract exposes multiple entrypoints via having sum type as its parameter.

In particular, each constructor would produce a homonymous entrypoint with argument type equal to type of constructor field (each constructor should have only one field). Constructor called Default will designate the default entrypoint.

data EpdRecursive Source #

Extension of EpdPlain on parameters being defined as several nested datatypes.

In particular, this will traverse sum types recursively, stopping at Michelson primitives (like Natural) and constructors with number of fields different from one.

It does not assign names to intermediate nodes of Or tree, only to the very leaves.

If some entrypoint arguments have custom IsoValue instance, this derivation way will not work. As a workaround, you can wrap your argument into some primitive (e.g. :!).

data EpdDelegate Source #

Extension of EpdPlain on parameters being defined as several nested datatypes.

In particular, it will traverse the immediate sum type, and require another ParameterHasEntryPoints for the inner complex datatypes. Only those inner types are considered which are the only fields in their respective constructors. Inner types should not themselves declare default entrypoint, we enforce this for better modularity. Each top-level constructor will be treated as entrypoint even if it contains a complex datatype within, in such case that would be an entrypoint corresponding to intermediate node in or tree.

Comparing to EpdRecursive this gives you more control over where and how entrypoints will be derived.

Implementation details

type PlainEntryPointsC mode cp = (GenericIsoValue cp, EntryPointsNotes mode (BuildEPTree mode cp) cp, RequireSumType cp) Source #

data EPTree Source #

Entrypoints tree - skeleton on TOr tree later used to distinguish between constructors-entrypoints and constructors which consolidate a whole pack of entrypoints.

Constructors

EPNode EPTree EPTree

We are in the intermediate node and need to go deeper.

EPLeaf

We reached entrypoint argument.

EPDelegate

We reached complex parameter part and will need to ask how to process it.

type BuildEPTree mode a = GBuildEntryPointsTree mode (Rep a) Source #

Build EPTree by parameter type.