Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class RenderDoc a where
- renderDoc :: RenderContext -> a -> Doc
- isRenderable :: a -> Bool
- newtype Prettier a = Prettier a
- printDoc :: Bool -> Doc -> Text
- printDocB :: Bool -> Doc -> Builder
- printDocS :: Bool -> Doc -> String
- renderOps :: RenderDoc op => Bool -> NonEmpty op -> Doc
- renderOpsList :: RenderDoc op => Bool -> [op] -> Doc
- spaces :: Int -> Doc
- wrapInParens :: RenderContext -> NonEmpty Doc -> Doc
- buildRenderDoc :: RenderDoc a => a -> Builder
- data RenderContext
- needsParens :: RenderContext
- doesntNeedParens :: RenderContext
- addParens :: RenderContext -> Doc -> Doc
- assertParensNotNeeded :: RenderContext -> a -> a
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.
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 suficcient 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
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.
Prettier a |
Instances
RenderDoc (Prettier ParameterType) Source # | |
Defined in Michelson.Untyped.Type renderDoc :: RenderContext -> Prettier ParameterType -> Doc Source # isRenderable :: Prettier ParameterType -> Bool Source # | |
RenderDoc (Prettier Type) Source # | |
Defined in Michelson.Untyped.Type |
renderOps :: RenderDoc op => Bool -> NonEmpty op -> Doc Source #
Generic way to render the different op types that get passed to a contract.
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 #
Smart parentheses
data RenderContext Source #
Environment carried during recursive rendering.
needsParens :: RenderContext Source #
ParensNeeded
constant.
doesntNeedParens :: RenderContext Source #
ParensNeeded
constant.
assertParensNotNeeded :: RenderContext -> a -> a Source #
Ensure parentheses are not required, for case when you cannot sensibly wrap your expression into them.