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

Michelson.Optimizer

Description

Optimizer for typed instructions.

It's quite experimental and incomplete. List of possible improvements: 1. pushDrop, dupDrop, unitDrop rules are essentially the same. It would be good to generalize them into one rule. The same applies to pushDip. It probably can be done more efficiently.

Synopsis

Documentation

optimize :: Instr inp out -> Instr inp out Source #

Optimize a typed instruction by replacing some sequences of instructions with smaller equivalent sequences. Applies default set of rewrite rules.

optimizeWithConf :: OptimizerConf -> Instr inp out -> Instr inp out Source #

Optimize a typed instruction using a custom set of rules.

defaultOptimizerConf :: OptimizerConf Source #

Default config - all commonly useful rules will be applied to all the code.

defaultRulesAndPushPack :: Rule -> Rule Source #

We do not enable pushPack rule by default because it is potentially dangerous. There are various code processing functions that may depend on constants, e. g. string transformations.

orRule :: (Rule -> Rule) -> (Rule -> Rule) -> Rule -> Rule Source #

Combine two rule fixpoints.

orSimpleRule :: (Rule -> Rule) -> Rule -> Rule -> Rule Source #

Combine a rule fixpoint and a simple rule.

type Rule = forall inp out. Instr inp out -> Maybe (Instr inp out) Source #

data OptimizerConf Source #

Constructors

OptimizerConf 

Fields

Instances

Instances details
Default OptimizerConf Source # 
Instance details

Defined in Michelson.Optimizer

Methods

def :: OptimizerConf #