[Git][ghc/ghc][wip/js-hline] Apply suggestions

Josh Meredith (@JoshMeredith) gitlab at gitlab.haskell.org
Thu May 25 12:54:18 UTC 2023



Josh Meredith pushed to branch wip/js-hline at Glasgow Haskell Compiler / GHC


Commits:
9c42138d by Sylvain Henry at 2023-05-25T12:54:16+00:00
Apply suggestions
- - - - -


4 changed files:

- compiler/GHC/Driver/Flags.hs
- compiler/GHC/JS/Ppr.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- docs/users_guide/debugging.rst


Changes:

=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -315,7 +315,7 @@ data GeneralFlag
    | Opt_WriteHie -- generate .hie files
 
    -- JavaScript opts
-   | Opt_DisableJsMinifier -- render JavaScript using a pretty-printed SDoc rather than compact a HLine
+   | Opt_DisableJsMinifier -- ^ render JavaScript pretty-printed instead of minified (compacted)
 
    -- profiling opts
    | Opt_AutoSccsOnIndividualCafs


=====================================
compiler/GHC/JS/Ppr.hs
=====================================
@@ -332,8 +332,6 @@ encodeJsonChar = \case
             let h = showHex cp ""
             in  text (prefix ++ replicate (pad - length h) '0' ++ h)
 
--- braceNest :: IsLine doc => doc -> doc
--- braceNest x = dualsLine (\Refl -> lbrace $$ nest 2 x $$ rbrace) (\Refl -> braces x)
 
 interSemi :: JsRender doc => [doc] -> doc
 interSemi = foldl ($$$) empty . punctuateFinal semi semi
@@ -346,16 +344,6 @@ addSemi x = x <> semi <> char '\n'
 --  hdr {
 --    body
 --  }
--- hangBrace :: IsLine doc => doc -> doc -> doc
--- hangBrace hdr body = dualsLine
---   (\Refl -> hdr <+> braces (nest 2 $ ppr body))
---   (\Refl -> hdr <> braces body)
-
--- ($$$) :: IsLine doc => doc -> doc -> doc
--- x $$$ y = dualsLine (\Refl -> x $$ y) (\Refl -> x <> y)
-
--- (<+?>) :: IsLine doc => doc -> doc -> doc
--- x <+?> y = dualsLine (\Refl -> x <+> y) (\Refl -> x <> y)
 
 
 class IsLine doc => JsRender doc where


=====================================
compiler/GHC/StgToJS/Linker/Linker.hs
=====================================
@@ -197,10 +197,10 @@ link lc_cfg cfg logger unit_env out _include units objFiles jsFiles isRootFun ex
 
       -- link generated RTS parts into rts.js
       unless (lcNoRts lc_cfg) $ do
-        if csPrettyRender cfg
-          then withFile (out </> "rts.js") WriteMode $ \h ->
-            printSDoc defaultJsContext (Ppr.PageMode True) h (rtsDeclsText $$ rtsText cfg)
-          else withFile (out </> "rts.js") WriteMode $ \h -> do
+        withFile (out </> "rts.js") WriteMode $ \h -> do
+         if csPrettyRender cfg
+          then printSDoc defaultJsContext (Ppr.PageMode True) h (rtsDeclsText $$ rtsText cfg)
+          else do
             bh <- newBufHandle h
             bPutHDoc bh defaultJsContext (line rtsDeclsText $$ line (rtsText cfg))
             bFlush bh


=====================================
docs/users_guide/debugging.rst
=====================================
@@ -727,7 +727,7 @@ JavaScript code generator
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. ghc-flag:: -ddisable-js-minifier
-   :shortdesc: Generate JavaScript code with whitespace
+   :shortdesc: Generate pretty-printed JavaScript code instead of minified (compacted) code.
    :type: dynamic
 
    Include human-readable spacing and indentation when generating JavaScript.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c42138dce426e5090f8bf96839364c9ad008023

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c42138dce426e5090f8bf96839364c9ad008023
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230525/56fb0594/attachment-0001.html>


More information about the ghc-commits mailing list