Safe Haskell | None |
---|---|
Language | Haskell2010 |
General-purpose utility functions for typed types.
Synopsis
- data DfsSettings x = DfsSettings {}
- data CtorEffectsApp x = CtorEffectsApp {}
- ceaBottomToTop :: CtorEffectsApp x
- dfsInstr :: forall x inp out. Semigroup x => DfsSettings x -> (forall i o. Instr i o -> (Instr i o, x)) -> Instr inp out -> (Instr inp out, x)
- dfsFoldInstr :: forall x inp out. Semigroup x => DfsSettings x -> (forall i o. Instr i o -> x) -> Instr inp out -> x
- dfsModifyInstr :: DfsSettings () -> (forall i o. Instr i o -> Instr i o) -> Instr inp out -> Instr inp out
- linearizeLeft :: Instr inp out -> Instr inp out
- linearizeLeftDeep :: Instr inp out -> Instr inp out
- dfsValue :: forall t x. Monoid x => (forall t'. Value t' -> (Value t', x)) -> Value t -> (Value t, x)
- dfsFoldValue :: Monoid x => (forall t'. Value t' -> x) -> Value t -> x
- dfsModifyValue :: (forall t'. Value t' -> Value t') -> Value t -> Value t
- isStringValue :: Value t -> Maybe MText
- isBytesValue :: Value t -> Maybe ByteString
- allAtomicValues :: forall t a. (forall t'. Value t' -> Maybe a) -> Value t -> [a]
Documentation
data DfsSettings x Source #
Options for dfsInstr
.
DfsSettings | |
|
Instances
Show (DfsSettings x) Source # | |
Defined in Michelson.Typed.Util showsPrec :: Int -> DfsSettings x -> ShowS # show :: DfsSettings x -> String # showList :: [DfsSettings x] -> ShowS # | |
Default (DfsSettings x) Source # | |
Defined in Michelson.Typed.Util def :: DfsSettings x # |
data CtorEffectsApp x Source #
Describes how intermediate nodes in instruction tree are accounted.
CtorEffectsApp | |
|
Instances
Show (CtorEffectsApp x) Source # | |
Defined in Michelson.Typed.Util showsPrec :: Int -> CtorEffectsApp x -> ShowS # show :: CtorEffectsApp x -> String # showList :: [CtorEffectsApp x] -> ShowS # |
ceaBottomToTop :: CtorEffectsApp x Source #
Gather effects first for children nodes, then for their parents.
dfsInstr :: forall x inp out. Semigroup x => DfsSettings x -> (forall i o. Instr i o -> (Instr i o, x)) -> Instr inp out -> (Instr inp out, x) Source #
Traverse a typed instruction in depth-first order.
<>
is used to concatenate intermediate results.
Each instructions can be changed using the supplied step
function.
It does not consider extra instructions (not present in Michelson).
dfsFoldInstr :: forall x inp out. Semigroup x => DfsSettings x -> (forall i o. Instr i o -> x) -> Instr inp out -> x Source #
Specialization of dfsInstr
for case when changing the instruction is
not required.
dfsModifyInstr :: DfsSettings () -> (forall i o. Instr i o -> Instr i o) -> Instr inp out -> Instr inp out Source #
Specialization of dfsInstr
which only modifies given instruction.
Changing instruction tree structure
linearizeLeft :: Instr inp out -> Instr inp out Source #
There are many ways to represent a sequence of more than 2 instructions.
E. g. for i1; i2; i3
it can be Seq i1 $ Seq i2 i3
or Seq (Seq i1 i2) i3
.
This function enforces a particular structure. Specifically, it makes each
Seq
have a single instruction (i. e. not Seq
) in its second argument.
This function also erases redundant Nop
s.
Please note that this function is not recursive, it does not
linearize contents of IF
and similar instructions.
linearizeLeftDeep :: Instr inp out -> Instr inp out Source #
Deep version of linearizeLeft
. It recursively linearizes
instructions stored in other instructions.
Value analysis
dfsValue :: forall t x. Monoid x => (forall t'. Value t' -> (Value t', x)) -> Value t -> (Value t, x) Source #
Traverse a value in depth-first order.
dfsFoldValue :: Monoid x => (forall t'. Value t' -> x) -> Value t -> x Source #
Specialization of dfsValue
for case when changing the value is
not required.
dfsModifyValue :: (forall t'. Value t' -> Value t') -> Value t -> Value t Source #
Specialization of dfsValue
which only modifies given value.
isBytesValue :: Value t -> Maybe ByteString Source #
If value is a bytestring, return the stored bytestring.