| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The 'return () >>' hack was added in commit
commit ac88f113abdec1edbffb6d2f97323e81f82908e7
Date: Tue Jul 26 12:14:03 2005 +0000
Nowadays it has no effect on generated Core on -O1/-O2
and slightly bloats Core on -O0.
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
This changelog is very incomplete, and basically useless. I'm removing
it, because it made it harder to compare this copy of `Pretty.hs` with
the copy in `libraries/pretty` (from which a similar changelog was
deleted some time ago).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
After the changes, the three functions used to print type families
were identical, so they are refactored into one.
Original RHSs of data instance declarations are recreated and
printed in user error messages.
RHSs containing representation TyCons are printed in the
Coercion Axioms section in a typechecker dump.
Add vbar to the list of SDocs exported by Outputable.
Replace all text "|" docs with it.
Fixes #10839
Reviewers: goldfire, jstolarek, austin, bgamari
Reviewed By: jstolarek
Subscribers: jstolarek, thomie
Differential Revision: https://phabricator.haskell.org/D1441
GHC Trac Issues: #10839
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
After 5d57087e314bd484dbe14958f9b422be3ac6641a ("Pretty: fix a broken
invariant"), T3294 showed 50% more max_bytes_used (#3294). After this
commit, max_bytes_used is back to what it was before, and the test
passes again.
This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.
From https://mail.haskell.org/pipermail/libraries/2008-June/009991.html:
vcat (hsep,cat) is implemented in an unneccessarily strict way.
We only get some output after all of vcat's arguments are evaluated
and checked against being Empty.
This can be improved by only checking the right argument of foldr
against being Empty, and
then applying an Empty-filter on the resulting Doc. Space improvement
is obvious.
The microbenchmark (code.haskell.org/~bhuber/Text/PrettyPrint/
HughesPJPerfCheck.hs) suggests that
the improvements in time are remarkable too.
|
|
|
|
|
|
|
|
|
|
| |
Following libraries/pretty. I'm not sure why it converted to Double
before.
This function isn't used by GHC itself. It is exported from these two
places:
* compiler/utils/Outputable
* libraries/template-haskell/Language/Haskell/TH/PprLib.hs
|
|
|
|
|
|
|
|
|
| |
This is a backport of a bug fix from
6cfbd0444981c074bae10a3cf72733bcb8597bef in libraries/pretty:
Fix a broken invariant
Patch from #694, for the problem "empty is an identity for <> and $$" is
currently broken by eg. isEmpty (empty<>empty)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a backport of a bug fix by Benedikt Huber for the same problem
in the pretty library (#1337), from commit
8d8866a8379c2fe8108ef034893c59e06d5e752f. The original explanation for
the fix is attached below.
Ticket #1776 originally reported an infinite loop when printing error
message. This promptly got fixed in:
commit 2d52ee06786e5caf0c2d65a4b4bb7c45c6493190
Author: simonpj@microsoft.com <unknown>
Date: Thu Mar 1 11:45:13 2007 +0000
Do not go into an infinite loop when pretty-printer finds a
negative indent (Trac #1176)
SPJ reports in the ticket: "So infinite loop is fixed, but the bad
formatting remains. I've added a test, tcfail177."
tcfail177 however hasn't triggered the formatting problem for years (as
Ian reported in c9e0e6067a47c574d9ff3721afe58e30ca1be3e4).
This patch updates the test to a version that at least still failed with
ghc-7.0 (from #1776#comment:7).
-------------------
From https://mail.haskell.org/pipermail/libraries/2008-June/010013.html,
by Benedikt Huber:
Concerning ticket #1337, we have to change the formal specification of
fill (it doesn't match the implementation):
-- Current Specification:
-- fill [] = empty
-- fill [p] = p
-- fill (p1:p2:ps) = oneLiner p1 <#> nest (length p1)
-- (fill (oneLiner p2 : ps))
-- `union`
-- p1 $$ fill ps
Problem 1: We want to `unnest' the second argument of (p1 $$ fill ps),
but not the first one
In the definition above we have e.g.
> getSecondLayout $
> fillDef False [text "a", text "b", text "a"]
>> text "ab"; nilabove; nest -1; text "a"; empty
>> |ab|
>> |.a|
Problem 2: The overlapping $$ should only be used for those layouts of
p1 which aren't one liners (otherwise violating the invariant "Left
union arg has shorter first line").
I suggest the following specification (i believe it almost matches the
current implementation, modulo [fillNB: fix bug #1337] (see below):
-- Revised Specification:
-- fill g docs = fill' 0 docs
-- gap g = if g then 1 else 0
-- fill' n [] = []
-- fill' n [p] = [p]
-- fill' n (p1:p2:ps) =
-- oneLiner p1 <g> (fill' (n+length p1+gap g) (oneLiner p2 : ps))
-- `union`
-- (p1 $*$ nest (-n) (fill' g ps))
--
-- $*$ is defined for layouts (One-Layout Documents) as
--
-- layout1 $*$ layout2 | isOneLiner layout1 = layout1 $+$ layout2
-- | otherwise = layout1 $$ layout2
I've also implemented the specification in HughesPJQuickCheck.hs,
and checked them against the patched pretty printer.
Concerning Bug #1337:
~~~~~~~~~~~~~~~~~~~~~
If the above formal specification is fine, it is easy to fix:
elide the nests of (oneLiner p2) [see attached patch, record bug #1337].
> PrettyPrint(0) $ ./Bug1337
> ....ab
> ...c
The (long) explanation follows below.
<snip/>
===========================================================
Explanation of Bug #1337:
Consider
> fcat [ nest 1 $ text "a", nest 2 $ text "b", text "c"]
--> expected: (nest 1; text "a"; text "b"; nest -3; "c")
--> actual : (nest 1; text "a"; text "b"; nest -5; "c")
Reduction:
=== (nest 1; text a) <> (fill (-2) (p2:ps))
==> (nest 2 (text "b") $+$ text "c")
==> (nest 2 (text "b")) `nilabove`
(nest (-3) (text "c"))
==> (nest 1; text a; text b; nest -5 c)
The problem is that if we decide to layout (p1:p2:ps) as
| p1 p2
| ps
(call it layout A), then we want to have
> (p1 <> p2) $+$ ps.
But following law <n6> this means that
> fcat_A [p1:nest k p2:ps]
is equivalent to
> fcat_A [p1,p2,ps]
so the nest of p2 has to be removed.
This is somewhat similar to bug #667, but easier to fix
from a semantic point of view:
p1,p2 and ps are distinct layouts - we only have to preserve the
individual layouts, and no combinations of them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.
From https://mail.haskell.org/pipermail/libraries/2008-June/009991.html:
Law <l1> states that
> sep (ps++[empty]++qs) = sep (ps ++ qs)
> ...ditto hsep, hcat, vcat, fill...
In the current implementation, this fails for the paragraph fill
variants.
> render' $ fsep [ text "c", text "c",empty, text "c", text "b"]
> where render' = renderStyle (Style PageMode 7 1.4)
>> c c c
>> b
|
|
|
|
|
| |
Similar changes were made to pretty in commit
7575ab16430c876eaa1451b02465b6b103b3a519.
|
|
|
|
| |
Refactoring only. Nothing much to see here.
|
|
|
|
|
|
|
| |
Follow same style as libraries/pretty, although some of it is pretty
archaic, and could be improved with BangPatterns:
* `get w _ | w == 0 && False = undefined`
* `mkNest k _ | k `seq` False = undefined`
|
|
|
|
| |
Just following libraries/pretty.
|
| |
|
| |
|
|
|
|
| |
Again, following libraries/pretty.
|
| |
|
|
|
|
|
|
|
|
|
| |
This commit copies the code structure (what goes where), whitespace layout
and comments from libraries/pretty/src/Text/PrettyPrint/HughesPJ.hs,
with the intention to be able to later more easily compare the two
files, and port bug fixes.
I'm sorry this messes up git blame history, but there's no other way.
|
| |
|
|
Signed-off-by: Austin Seipp <austin@well-typed.com>
|