Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data ComposeResult a
- fromTaggedVal :: LooseSumC dt => (Text, SomeValue) -> ComposeResult dt
- toTaggedVal :: LooseSumC dt => dt -> (Text, SomeValue)
- type LooseSumC dt = (Generic dt, GLooseSum (Rep dt))
Documentation
data ComposeResult a Source #
Possible outcomes of an attempt to construct a Haskell ADT value from constructor name and relevant data.
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. |
Instances
Functor ComposeResult Source # | |
Defined in Michelson.Typed.Haskell.LooseSum fmap :: (a -> b) -> ComposeResult a -> ComposeResult b # (<$) :: a -> ComposeResult b -> ComposeResult a # | |
Semigroup (ComposeResult a) Source # | |
Defined in Michelson.Typed.Haskell.LooseSum (<>) :: ComposeResult a -> ComposeResult a -> ComposeResult a # sconcat :: NonEmpty (ComposeResult a) -> ComposeResult a # stimes :: Integral b => b -> ComposeResult a -> ComposeResult a # | |
Monoid (ComposeResult a) Source # | |
Defined in Michelson.Typed.Haskell.LooseSum mempty :: ComposeResult a # mappend :: ComposeResult a -> ComposeResult a -> ComposeResult a # mconcat :: [ComposeResult a] -> ComposeResult a # |
fromTaggedVal :: LooseSumC dt => (Text, SomeValue) -> ComposeResult dt Source #
Inverse to toTaggedVal
.