ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.JS.Ppr

Contents

- Orphan instances

Description

Pretty-printing JavaScript

Synopsis

- renderJs :: (JsToDoc a, JMacro a) => a -> Doc
- renderJs' :: (JsToDoc a, JMacro a) => RenderJs -> a -> Doc
- renderPrefixJs :: (JsToDoc a, JMacro a) => FastString -> a -> Doc
- renderPrefixJs' :: (JsToDoc a, JMacro a) => RenderJs -> FastString -> a -> Doc
- class JsToDoc a where
  - jsToDocR :: RenderJs -> a -> Doc
- defaultRenderJs :: RenderJs
- data RenderJs = RenderJs {
  - renderJsS :: !(RenderJs -> JStat -> Doc)
  - renderJsE :: !(RenderJs -> JExpr -> Doc)
  - renderJsV :: !(RenderJs -> JVal -> Doc)
  - renderJsI :: !(RenderJs -> Ident -> Doc)
  }
- jsToDoc :: JsToDoc a => a -> Doc
- pprStringLit :: FastString -> Doc
- flattenBlocks :: [JStat] -> [JStat]
- braceNest :: Doc -> Doc
- hangBrace :: Doc -> Doc -> Doc

# Documentation

renderJs :: (JsToDoc a, JMacro a) => a -> Doc Source #

Render a syntax tree as a pretty-printable document (simply showing the resultant doc produces a nice, well formatted String).

renderJs' :: (JsToDoc a, JMacro a) => RenderJs -> a -> Doc Source #

renderPrefixJs :: (JsToDoc a, JMacro a) => FastString -> a -> Doc Source #

Render a syntax tree as a pretty-printable document, using a given prefix to all generated names. Use this with distinct prefixes to ensure distinct generated names between independent calls to render(Prefix)Js.

renderPrefixJs' :: (JsToDoc a, JMacro a) => RenderJs -> FastString -> a -> Doc Source #

class JsToDoc a where Source #

Methods

jsToDocR :: RenderJs -> a -> Doc Source #

#### Instances

Instances details

JsToDoc Ident Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> Ident -> Doc Source #
JsToDoc JExpr Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> JExpr -> Doc Source #
JsToDoc JStat Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> JStat -> Doc Source #
JsToDoc JVal Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> JVal -> Doc Source #
JsToDoc [JExpr] Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> [JExpr] -> Doc Source #
JsToDoc [JStat] Source # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: RenderJs -> [JStat] -> Doc Source #

defaultRenderJs :: RenderJs Source #

data RenderJs Source #

Constructors

RenderJs |

Fields

- renderJsS :: !(RenderJs -> JStat -> Doc)
- renderJsE :: !(RenderJs -> JExpr -> Doc)
- renderJsV :: !(RenderJs -> JVal -> Doc)
- renderJsI :: !(RenderJs -> Ident -> Doc)

jsToDoc :: JsToDoc a => a -> Doc Source #

pprStringLit :: FastString -> Doc Source #

flattenBlocks :: [JStat] -> [JStat] Source #

braceNest :: Doc -> Doc Source #

hangBrace :: Doc -> Doc -> Doc Source #

Hang with braces:

hdr { body }

# Orphan instances

Outputable JExpr Source # |
Instance details Methods ppr :: JExpr -> SDoc Source #
Outputable JVal Source # |
Instance details Methods ppr :: JVal -> SDoc Source #