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

Morley.Michelson.Printer.Util

Description

Utilities for rendering Michelson code in a format compatible with Tezos software (e.g tezos-client)

Synopsis

Documentation

class RenderDoc a where Source #

Generalize converting a type into a Text.PrettyPrint.Leijen.Text.Doc. Used to pretty print Michelson code and define Fmt.Buildable instances.

Minimal complete definition

renderDoc

Methods

renderDoc :: RenderContext -> a -> Doc Source #

isRenderable :: a -> Bool Source #

Whether a value can be represented in Michelson code. Normally either all values of some type are renderable or not renderable. However, in case of instructions we have extra instructions which should not be rendered. Note: it's not sufficient to just return mempty for such instructions, because sometimes we want to print lists of instructions and we need to ignore them complete (to avoid putting redundant separators).

Instances

Instances details
RenderDoc AnnotationSet Source # 
Instance details

Defined in Morley.Michelson.Untyped.Annotation

RenderDoc InstrCallStack Source # 
Instance details

Defined in Morley.Michelson.ErrorPos

RenderDoc CryptoParseError Source # 
Instance details

Defined in Morley.Tezos.Crypto.Util

RenderDoc T Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc ParameterType Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc Ty Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc T Source # 
Instance details

Defined in Morley.Michelson.Typed.T

RenderDoc BadTypeForScope Source # 
Instance details

Defined in Morley.Michelson.Typed.Scope

RenderDoc EpNameFromRefAnnError Source # 
Instance details

Defined in Morley.Michelson.Untyped.Entrypoints

RenderDoc DeserializationError Source # 
Instance details

Defined in Morley.Tezos.Crypto.BLS12381

RenderDoc ParseContractAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

RenderDoc ParseAddressRawError Source # 
Instance details

Defined in Morley.Tezos.Address

RenderDoc ParseAddressError Source # 
Instance details

Defined in Morley.Tezos.Address

RenderDoc ViewName Source # 
Instance details

Defined in Morley.Michelson.Untyped.View

RenderDoc ExpandedOp Source # 
Instance details

Defined in Morley.Michelson.Untyped.Instr

RenderDoc ParamEpError Source # 
Instance details

Defined in Morley.Michelson.Typed.Entrypoints

RenderDoc ArmCoord Source # 
Instance details

Defined in Morley.Michelson.Typed.Entrypoints

RenderDoc ParseEpAddressError Source # 
Instance details

Defined in Morley.Michelson.Typed.Entrypoints

RenderDoc TypeCheckedOp Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.TypeCheckedOp

RenderDoc TCError Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.Error

RenderDoc TCTypeError Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.Error

RenderDoc TopLevelType Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.Error

RenderDoc TypeContext Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.Error

RenderDoc ParsedOp Source # 
Instance details

Defined in Morley.Michelson.Macro

RenderDoc (Prettier ParameterType) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc (Prettier Ty) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc (Prettier T) Source # 
Instance details

Defined in Morley.Michelson.Typed.T

RenderDoc (MismatchError [T]) Source # 
Instance details

Defined in Morley.Michelson.Typed.T

RenderDoc a => RenderDoc (MismatchError a) Source # 
Instance details

Defined in Morley.Util.MismatchError

RenderDoc (MismatchError Ty) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Type

RenderDoc (MismatchError T) Source # 
Instance details

Defined in Morley.Michelson.Typed.T

RenderDoc op => RenderDoc (ExtInstrAbstract op) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Ext

RenderDoc (PeanoNatural n) Source # 
Instance details

Defined in Morley.Util.PeanoNatural

RenderDoc op => RenderDoc (Contract' op) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Contract

RenderDoc op => RenderDoc (Elt op) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Value

RenderDoc op => RenderDoc (Value' op) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Value

RenderDoc op => RenderDoc (InstrAbstract op) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Instr

RenderDoc (Notes t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Annotation

(forall (t :: T). cs t => HasNoOp t) => RenderDoc (SomeConstrainedValue cs) Source # 
Instance details

Defined in Morley.Michelson.Typed.Existential

RenderDoc (HST ts) Source # 
Instance details

Defined in Morley.Michelson.TypeCheck.Types

KnownAnnTag tag => RenderDoc (Annotation tag) Source # 
Instance details

Defined in Morley.Michelson.Untyped.Annotation

HasNoOp t => RenderDoc (Value' Instr t) Source # 
Instance details

Defined in Morley.Michelson.Typed.Convert

RenderDoc (Instr inp out) Source # 
Instance details

Defined in Morley.Michelson.Typed.Convert

Methods

renderDoc :: RenderContext -> Instr inp out -> Doc Source #

isRenderable :: Instr inp out -> Bool Source #

newtype Prettier a Source #

A new type that can wrap values so that the RenderDoc instances of the combined value can have a different behavior for the pretty printer.

Constructors

Prettier a 

printDoc :: Bool -> Doc -> Text Source #

Convert Doc to Text with a line width of 80.

printDocB :: Bool -> Doc -> Builder Source #

Convert Doc to Builder in the same manner as printDoc.

printDocS :: Bool -> Doc -> String Source #

Convert Doc to String in the same manner as printDoc.

renderOps :: RenderDoc op => Bool -> NonEmpty op -> Doc Source #

Generic way to render the different op types that get passed to a contract.

renderOpsList :: RenderDoc op => Bool -> [op] -> Doc Source #

Render a comma-separated list of items in braces

renderOpsListNoBraces :: RenderDoc op => Bool -> [op] -> Doc Source #

Render a comma-separated list of items without braces

spaces :: Int -> Doc Source #

Create a specific number of spaces.

wrapInParens :: RenderContext -> NonEmpty Doc -> Doc Source #

Wrap documents in parentheses if there are two or more in the list.

buildRenderDoc :: RenderDoc a => a -> Builder Source #

Turn something that is instance of RenderDoc into a Builder. It's formatted the same way as printDoc formats docs.

buildRenderDocExtended :: RenderDoc a => a -> Builder Source #

Works as buildRenderDoc above, but doesn't force the doc to be printed in one line

renderDocList :: RenderDoc a => RenderContext -> [a] -> Doc Source #

Renders a list of RenderDoc elements surrounded with square brackets, separated by a comma and a space.

Smart parentheses

data RenderContext Source #

Environment carried during recursive rendering.

addParens :: RenderContext -> Doc -> Doc Source #

Add parentheses if needed.

assertParensNotNeeded :: RenderContext -> a -> a Source #

Ensure parentheses are not required, for case when you cannot sensibly wrap your expression into them.