diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2016-07-17 00:13:45 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-07-17 00:13:46 +0200 |
commit | 89a8be71a3715c948cebcb19ac81f84da0e6270e (patch) | |
tree | 1ceaa32b9abd26b4cabda5e72ea2dab8fe5583f7 /compiler/utils | |
parent | 1ba79fa4d0e13e61a805fa458bcf2e690710d88b (diff) | |
download | haskell-89a8be71a3715c948cebcb19ac81f84da0e6270e.tar.gz |
Pretty: remove a harmful $! (#12227)
This is backport of [1] for GHC's copy of Pretty. See Note [Differences
between libraries/pretty and compiler/utils/Pretty.hs].
[1] http://git.haskell.org/packages/pretty.git/commit/bbe9270c5f849a5bb74c9166a5f4202cfb0dba22
https://github.com/haskell/pretty/issues/32
https://github.com/haskell/pretty/pull/35
Reviewers: bgamari, austin
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D2397
GHC Trac Issues: #12227
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Pretty.hs | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs index ab7db59a6a..98490322c5 100644 --- a/compiler/utils/Pretty.hs +++ b/compiler/utils/Pretty.hs @@ -20,6 +20,49 @@ -- ----------------------------------------------------------------------------- +{- +Note [Differences between libraries/pretty and compiler/utils/Pretty.hs] + +For historical reasons, there are two different copies of `Pretty` in the GHC +source tree: + * `libraries/pretty` is a submodule containing + https://github.com/haskell/pretty. This is the `pretty` library as released + on hackage. It is used by several other libraries in the GHC source tree + (e.g. template-haskell and Cabal). + * `compiler/utils/Pretty.hs` (this module). It is used by GHC only. + +There is an ongoing effort in https://github.com/haskell/pretty/issues/1 and +https://ghc.haskell.org/trac/ghc/ticket/10735 to try to get rid of GHC's copy +of Pretty. + +Currently, GHC's copy of Pretty resembles pretty-1.1.2.0, with the following +major differences: + * GHC's copy uses `Faststring` for performance reasons. + * GHC's copy has received a backported bugfix for #12227, which was + released as pretty-1.1.3.4 ("Remove harmful $! forcing in beside", + https://github.com/haskell/pretty/pull/35). + +Other differences are minor. Both copies define some extra functions and +instances not defined in the other copy. To see all differences, do this in a +ghc git tree: + + $ cd libraries/pretty + $ git checkout v1.1.2.0 + $ cd - + $ vimdiff compiler/utils/Pretty.hs \ + libraries/pretty/src/Text/PrettyPrint/HughesPJ.hs + +For parity with `pretty-1.1.2.1`, the following two `pretty` commits would +have to be backported: + * "Resolve foldr-strictness stack overflow bug" + (307b8173f41cd776eae8f547267df6d72bff2d68) + * "Special-case reduce for horiz/vert" + (c57c7a9dfc49617ba8d6e4fcdb019a3f29f1044c) +This has not been done sofar, because these commits seem to cause more +allocation in the compiler (see thomie's comments in +https://github.com/haskell/pretty/pull/9). +-} + module Pretty ( -- * The document type @@ -590,7 +633,7 @@ beside p@(Beside p1 g1 q1) g2 q2 | otherwise = beside (reduceDoc p) g2 q2 beside p@(Above{}) g q = let !d = reduceDoc p in beside d g q beside (NilAbove p) g q = nilAbove_ $! beside p g q -beside (TextBeside s sl p) g q = textBeside_ s sl $! rest +beside (TextBeside s sl p) g q = textBeside_ s sl rest where rest = case p of Empty -> nilBeside g q |