Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module, providing Notes t
data type, which holds annotations for a
given type t
.
Annotation type Notes t
is a tree, each leaf is either a star (*
) or a
constructor holding some annotation data for a given type t
.
Star corresponds to the case when given Michelson type contains no
annotations.
This module also provides type class Converge
along with some
utility functions which are used to combine two annotations trees
a
and b
into a new one c
in such a way that c
can be obtained from
both a
and b
by replacing some *
leafs with type or/and field
annotations.
Synopsis
- data Notes t
- data Notes' t where
- NTc :: TypeAnn -> Notes' (Tc ct)
- NTKey :: TypeAnn -> Notes' TKey
- NTUnit :: TypeAnn -> Notes' TUnit
- NTSignature :: TypeAnn -> Notes' TSignature
- NTOption :: TypeAnn -> FieldAnn -> Notes t -> Notes' (TOption t)
- NTList :: TypeAnn -> Notes t -> Notes' (TList t)
- NTSet :: TypeAnn -> TypeAnn -> Notes' (TSet ct)
- NTOperation :: TypeAnn -> Notes' TOperation
- NTContract :: TypeAnn -> Notes t -> Notes' (TContract t)
- NTPair :: TypeAnn -> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes' (TPair p q)
- NTOr :: TypeAnn -> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes' (TOr p q)
- NTLambda :: TypeAnn -> Notes p -> Notes q -> Notes' (TLambda p q)
- NTMap :: TypeAnn -> TypeAnn -> Notes v -> Notes' (TMap k v)
- NTBigMap :: TypeAnn -> TypeAnn -> Notes v -> Notes' (TBigMap k v)
- data AnnConvergeError where
- AnnConvergeError :: forall (tag :: Type). (Buildable (Annotation tag), Show (Annotation tag), Typeable tag) => Annotation tag -> Annotation tag -> AnnConvergeError
- converge :: Notes t -> Notes t -> Either AnnConvergeError (Notes t)
- convergeAnns :: forall (tag :: Type). (Buildable (Annotation tag), Show (Annotation tag), Typeable tag) => Annotation tag -> Annotation tag -> Either AnnConvergeError (Annotation tag)
- notesCase :: r -> (Notes' t -> r) -> Notes t -> r
- isStar :: Notes t -> Bool
- mkNotes :: Notes' t -> Notes t
- orAnn :: Annotation t -> Annotation t -> Annotation t
Documentation
Data type, holding annotation data for a given Michelson type t
or *
in case no data is provided for the tree.
There is a little semantical duplication between data type constructors.
Semantics behind NStar
constructor are exactly same as semantics behind
N
constructor with relevant Notes'
constructor be given all default
values (which means all annotations are empty).
Constructor NStar
is given as a tiny optimization to allow handling
no-annotation case completely for free (see converge
and mkNotes
functions).
Data type, holding annotation data for a given Michelson type t
.
Each constructor corresponds to exactly one constructor of T
and holds all type and field annotations that can be attributed to a
Michelson type corrspoding to t
.
NTc :: TypeAnn -> Notes' (Tc ct) | |
NTKey :: TypeAnn -> Notes' TKey | |
NTUnit :: TypeAnn -> Notes' TUnit | |
NTSignature :: TypeAnn -> Notes' TSignature | |
NTOption :: TypeAnn -> FieldAnn -> Notes t -> Notes' (TOption t) | |
NTList :: TypeAnn -> Notes t -> Notes' (TList t) | |
NTSet :: TypeAnn -> TypeAnn -> Notes' (TSet ct) | |
NTOperation :: TypeAnn -> Notes' TOperation | |
NTContract :: TypeAnn -> Notes t -> Notes' (TContract t) | |
NTPair :: TypeAnn -> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes' (TPair p q) | |
NTOr :: TypeAnn -> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes' (TOr p q) | |
NTLambda :: TypeAnn -> Notes p -> Notes q -> Notes' (TLambda p q) | |
NTMap :: TypeAnn -> TypeAnn -> Notes v -> Notes' (TMap k v) | |
NTBigMap :: TypeAnn -> TypeAnn -> Notes v -> Notes' (TBigMap k v) |
data AnnConvergeError where Source #
AnnConvergeError :: forall (tag :: Type). (Buildable (Annotation tag), Show (Annotation tag), Typeable tag) => Annotation tag -> Annotation tag -> AnnConvergeError |
Instances
Eq AnnConvergeError Source # | |
Defined in Michelson.Typed.Annotation (==) :: AnnConvergeError -> AnnConvergeError -> Bool # (/=) :: AnnConvergeError -> AnnConvergeError -> Bool # | |
Show AnnConvergeError Source # | |
Defined in Michelson.Typed.Annotation showsPrec :: Int -> AnnConvergeError -> ShowS # show :: AnnConvergeError -> String # showList :: [AnnConvergeError] -> ShowS # | |
Buildable AnnConvergeError Source # | |
Defined in Michelson.Typed.Annotation build :: AnnConvergeError -> Builder # |
converge :: Notes t -> Notes t -> Either AnnConvergeError (Notes t) Source #
Same as converge'
but works with Notes
data type.
convergeAnns :: forall (tag :: Type). (Buildable (Annotation tag), Show (Annotation tag), Typeable tag) => Annotation tag -> Annotation tag -> Either AnnConvergeError (Annotation tag) Source #
Converge two type or field notes (which may be wildcards).
notesCase :: r -> (Notes' t -> r) -> Notes t -> r Source #
Helper function for work with Notes
data type.
notesCase f g notes
is equivalent to
case notes of NStar -> f N v -> g v
mkNotes :: Notes' t -> Notes t Source #
Checks whether given notes n
can be immediately converted to star
and returns either NStar
or N n
.
Given n :: Notes' t
can be immediately converted to star iff all nested
(sn :: Notes t) == NStar
and for each annotation an
: an == def
.
orAnn :: Annotation t -> Annotation t -> Annotation t Source #