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

Michelson.Typed.Haskell.LooseSum

Description

Representation of Haskell sum types via loosy typed Michelson values, useful for e.g. errors and enums.

In particular, ADT sum can be represented as constructor name + data it carries. Such expression does not have particular type because different constructors may carry different data, and we avoid lifting this data to a union in order to keep only the significant parts (and thus not to confuse the client).

Synopsis

Documentation

data ComposeResult a Source #

Possible outcomes of an attempt to construct a Haskell ADT value from constructor name and relevant data.

Constructors

ComposeOk a

Composed fine.

ComposeCtorNotFound

No constructor with such name.

ComposeFieldTypeMismatch TypeRep TypeRep

Found required constructor, but type of data does not correspond to provided one.

toTaggedVal :: LooseSumC dt => dt -> (Text, SomeValue) Source #

Decompose Haskell type into constructor name and data it carries, converting the latter into Michelson Value.

type LooseSumC dt = (Generic dt, GLooseSum (Rep dt)) Source #

Constraint for hsDecompose and hsCompose.