5 years agoUntabify template-haskell.
Richard Eisenberg [Tue, 4 Nov 2014 18:43:17 +0000 (13:43 -0500)] 
Untabify template-haskell.

5 years agoFix #9066.
Richard Eisenberg [Mon, 3 Nov 2014 16:15:35 +0000 (11:15 -0500)] 
Fix #9066.

When splicing in a fixity declaration, look for both term-level things
and type-level things. This requires some changes elsewhere in the
code to allow for more flexibility when looking up Exact names, which
can be assigned the wrong namespace during fixity declaration

See the ticket for more info.

5 years agoTest #9066 in th/T9066
Richard Eisenberg [Sun, 2 Nov 2014 18:44:27 +0000 (13:44 -0500)] 
Test #9066 in th/T9066

5 years agofix allocLimit3 on Windows
Simon Marlow [Thu, 6 Nov 2014 16:42:49 +0000 (16:42 +0000)] 
fix allocLimit3 on Windows

5 years agoFix build errors on Windows (these tests still don't work though)
Simon Marlow [Wed, 5 Nov 2014 18:05:10 +0000 (18:05 +0000)] 
Fix build errors on Windows (these tests still don't work though)

5 years agoPer-thread allocation counters and limits
Simon Marlow [Tue, 14 Oct 2014 23:03:15 +0000 (00:03 +0100)] 
Per-thread allocation counters and limits

This reverts commit f0fcc41d755876a1b02d1c7c79f57515059f6417.

New changes: now works on 32-bit platforms too.  I added some basic
support for 64-bit subtraction and comparison operations to the x86

5 years agoImplement new integer-gmp2 from scratch (re #9281)
Herbert Valerio Riedel [Sun, 19 Oct 2014 18:37:40 +0000 (20:37 +0200)] 
Implement new integer-gmp2 from scratch (re #9281)

This is done as a separate `integer-gmp2` backend library because it
turned out to become a complete rewrite from scratch.

Due to the different (over)allocation scheme and potentially different
accounting (via the new `{shrink,resize}MutableByteArray#` primitives),
some of the nofib benchmarks actually results in increased allocation
numbers (but not necessarily an increase in runtime!).  I believe the
allocation numbers could improve if `{resize,shrink}MutableByteArray#`
could be optimised to reallocate in-place more efficiently.

Here are the more apparent changes in the latest nofib comparision
between `integer-gmp` and `integer-gmp2`:

          Program     Size    Allocs   Runtime   Elapsed  TotalMem
       bernouilli    +1.6%    +15.3%     0.132     0.132      0.0%
     cryptarithm1    -2.2%      0.0%     -9.7%     -9.7%      0.0%
            fasta    -0.7%     -0.0%    +10.9%    +10.9%      0.0%
            kahan    +0.6%    +38.9%     0.169     0.169      0.0%
             lcss    -0.7%     -0.0%     -6.4%     -6.4%      0.0%
           mandel    +1.6%    +33.6%     0.049     0.049      0.0%
         pidigits    +0.8%     +8.5%     +3.9%     +3.9%      0.0%
            power    +1.4%    -23.8%    -18.6%    -18.6%    -16.7%
        primetest    +1.3%    +50.1%     0.085     0.085      0.0%
              rsa    +1.6%    +53.4%     0.026     0.026      0.0%
              scs    +1.2%     +6.6%     +6.5%     +6.6%    +14.3%
           symalg    +1.0%     +9.5%     0.010     0.010      0.0%
        transform    -0.6%     -0.0%     -5.9%     -5.9%      0.0%
              Min    -2.3%    -23.8%    -18.6%    -18.6%    -16.7%
              Max    +1.6%    +53.4%    +10.9%    +10.9%    +14.3%
   Geometric Mean    -0.3%     +1.9%     -0.8%     -0.8%     +0.0%

(see P35 / for full report)

By default, `INTEGER_LIBRARY=integer-gmp2` is active now, which results
in the package `integer-gmp-` being registered in the package db.
The previous `integer-gmp-` can be restored by setting
`INTEGER_LIBRARY=integer-gmp` (but will probably be removed altogether
for GHC 7.12). In-tree GMP support has been stolen from the old
`integer-gmp` (while unpatching the custom memory-allocators, as well as
forcing `-fPIC`)

A minor hack to `ghc-cabal` was necessary in order to support two different
`integer-gmp` packages (in different folders) with the same package key.

There will be a couple of follow-up commits re-implementing some features
that were dropped to keep D82 minimal, as well as further

More information can be found via #9281 and

Reviewed By: austin, rwbarton, simonmar

Differential Revision:

5 years agoDisable T4801/peak_megabytes_allocated
Herbert Valerio Riedel [Sun, 9 Nov 2014 20:54:43 +0000 (21:54 +0100)] 
Disable T4801/peak_megabytes_allocated

This test seems too close to a tipping point (and thus too sensitive to the
build-env used) and T4801's `max_bytes_used` was disabled as well some time
ago for a similiar reason.

5 years agoAdd stderr for T9662
Simon Peyton Jones [Tue, 11 Nov 2014 15:14:20 +0000 (15:14 +0000)] 
Add stderr for T9662

5 years agoTest Trac #7862
Simon Peyton Jones [Tue, 11 Nov 2014 13:06:21 +0000 (13:06 +0000)] 
Test Trac #7862

5 years agoTest Trac #9077
Simon Peyton Jones [Tue, 11 Nov 2014 11:46:52 +0000 (11:46 +0000)] 
Test Trac #9077

5 years agoImprove documentation of -ticky a little
Simon Peyton Jones [Tue, 11 Nov 2014 11:36:57 +0000 (11:36 +0000)] 
Improve documentation of -ticky a little

5 years agoComments only
Simon Peyton Jones [Tue, 11 Nov 2014 11:36:16 +0000 (11:36 +0000)] 
Comments only

5 years agoTest Trac #9662
Simon Peyton Jones [Tue, 11 Nov 2014 11:35:48 +0000 (11:35 +0000)] 
Test Trac #9662

5 years agoComments only (on recursive dictionaries)
Simon Peyton Jones [Tue, 11 Nov 2014 10:27:51 +0000 (10:27 +0000)] 
Comments only (on recursive dictionaries)

5 years agoDe-bias Data.Foldable and improve docstrings
David Feuer [Tue, 11 Nov 2014 07:35:37 +0000 (08:35 +0100)] 
De-bias Data.Foldable and improve docstrings

Use fewer left/right-biased folds for defaults and
functions in `Data.Foldable`, to better support things
that don't look like cons lists.

This also extends the Haddock docstrings in `Data.Foldable`.

Reviewed By: hvr, ekmett

Differential Revision:

5 years agoDefine list monad operations using comprehensions
David Feuer [Tue, 11 Nov 2014 06:59:34 +0000 (07:59 +0100)] 
Define list monad operations using comprehensions

Define list monad operations using list comprehensions. Code using monad
operations with lists did not fuse fully. Writing list code with `do`
notation or `(>>=)` and `(>>)` operations could allocate more than
equivalent code using list comprehensions.

Define `mapM` directly, instead of using `sequence` and `map`. This
leads to substantially less allocation in `cryptarithm2`.

Addresses #9781

Reviewed By: ekmett, nomeata

Differential Revision:

5 years agoTypo fix; Trac #9787
Austin Seipp [Mon, 10 Nov 2014 21:13:26 +0000 (15:13 -0600)] 
Typo fix; Trac #9787

Also, reword :print description.

Signed-off-by: Austin Seipp <>
5 years agoMove Data.Functor.Identity from transformers to base
Herbert Valerio Riedel [Sun, 5 Oct 2014 13:18:49 +0000 (15:18 +0200)] 
Move Data.Functor.Identity from transformers to base

This also updates the `transformers` submodule to the just
released `transformers-` package version.

See #9664 for more details

Reviewed By: austin, ekmett

Differential Revision:

5 years agoUse (.) and id from Base in Control.Applicative
David Feuer [Sat, 8 Nov 2014 20:43:27 +0000 (21:43 +0100)] 
Use (.) and id from Base in Control.Applicative

Control.Applicative previously imported `(.)` and `id` from `Control.Arrow`,
but then only applied them to functions.

Reviewed By: ekmett, hvr

Differential Revision:

5 years agoUnlit overlooked GHC/Conc/Sync.lhs
Herbert Valerio Riedel [Sat, 8 Nov 2014 14:13:59 +0000 (15:13 +0100)] 
Unlit overlooked GHC/Conc/Sync.lhs

This is a follow-up commit to df3b1d43cc862fe03f0724a9c0ac9e7cecdf4605

5 years agoGroup PatSyn req/prov arguments together so that they're not all over the place
Dr. ERDI Gergo [Thu, 6 Nov 2014 11:01:38 +0000 (19:01 +0800)] 
Group PatSyn req/prov arguments together so that they're not all over the place

5 years agoIn pattern synonym matchers, support unboxed continuation results (fixes #9783).
Dr. ERDI Gergo [Sat, 8 Nov 2014 04:24:55 +0000 (12:24 +0800)] 
In pattern synonym matchers, support unboxed continuation results (fixes #9783).

This requires ensuring the continuations have arguments by adding a dummy
Void# argument when needed. This is so that matching on a pattern synonym
is lazy even when the result is unboxed, e.g.

    pattern P = ()
    f P = 0#

In this case, without dummy arguments, the generated matcher's type would be

   $mP :: forall (r :: ?). () -> r -> r -> r

which is called in `f` at type `() -> Int# -> Int# -> Int#`,
so it would be strict, in particular, in the failure continuation
of `patError`.

We work around this by making sure both continuations have arguments:

  $mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r

Of course, if `P` (and thus, the success continuation) has any arguments,
we are only adding the extra dummy argument to the failure continuation.

5 years agoTop-level comment for keepPackageImports.
Edward Z. Yang [Tue, 4 Nov 2014 21:05:13 +0000 (13:05 -0800)] 
Top-level comment for keepPackageImports.

Signed-off-by: Edward Z. Yang <>
5 years agoMiscellaneous documentation for the Finder.
Edward Z. Yang [Tue, 4 Nov 2014 10:07:01 +0000 (02:07 -0800)] 
Miscellaneous documentation for the Finder.

Signed-off-by: Edward Z. Yang <>
5 years agoTypofix.
Edward Z. Yang [Thu, 6 Nov 2014 23:04:03 +0000 (15:04 -0800)] 

Signed-off-by: Edward Z. Yang <>
5 years agoPreserve argument order to (==)/eq in nub and nubBy
Thomas Miedema [Fri, 7 Nov 2014 16:38:59 +0000 (17:38 +0100)] 
Preserve argument order to (==)/eq in nub and nubBy

This makes nub and nubBy behave as specified in the Haskell 98 Report.

This reverts 0ad9def53842e86fb292eccb810190711c42d7c5, and
fixes #3280, #7913 and #2528 (properly).

Before this change, the output of `T2528` was (4x wrong):

Reviewed By: dfeuer, ekmett, austin, hvr

Differential Revision:

5 years agobase: Manually unlit .lhs into .hs modules
Herbert Valerio Riedel [Fri, 7 Nov 2014 15:26:59 +0000 (16:26 +0100)] 
base: Manually unlit .lhs into .hs modules

This commit mostly converts literate comments into ordinary
Haskell comments or sometimes even Haddock comments, while also
removing literate comments in a few cases where they don't make
much sense anymore.

Moreover, in a few cases trailing whitespaces were removed as well.

Reviewed By: austin

Differential Revision:

5 years agoHave validate take into account stat test failures too.
Gintautas Miliauskas [Fri, 7 Nov 2014 16:17:03 +0000 (10:17 -0600)] 
Have validate take into account stat test failures too.

This should have gone in with the update in to split
off stat test failures into a separate category in the summary.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter

Differential Revision:

5 years agoUse bracket in `withCurrentDirectory`
Konstantin Zudov [Fri, 7 Nov 2014 13:32:48 +0000 (07:32 -0600)] 
Use bracket in `withCurrentDirectory`

Summary: There was a comment about that. Seems like a better behaviour.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision:

5 years ago[Docs] Fixed several broken urls in user's guide
Konstantin Zudov [Fri, 7 Nov 2014 13:32:35 +0000 (07:32 -0600)] 
[Docs] Fixed several broken urls in user's guide

Summary: Some of the links in user's guide were broken, I've found the files they used to link and updated urls.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision:

5 years agosmall parser/lexer cleanup
Yuri de Wit [Fri, 7 Nov 2014 13:32:26 +0000 (07:32 -0600)] 
small parser/lexer cleanup

The last three '#define ...' macros were removed from Parser.y.pp and this file was renamed to Parser.y.
This basically got rid of a CPP step in the build.

Also converted two modules in compiler/parser/ from .lhs to .hs.

Test Plan: Does it build? Yes, I performed a full build here and things are looking good.

Reviewers: austin

Reviewed By: austin

Subscribers: adamse, thomie, carter, simonmar

Differential Revision:

5 years ago*Really*, really fix RTS crash due to bad coercion.
Merijn Verstraaten [Fri, 7 Nov 2014 13:32:18 +0000 (07:32 -0600)] 
*Really*, really fix RTS crash due to bad coercion.

My previous attempt to fix the new coercion bug introduced by my fix actually
just reverted back to the *old* bug. This time it should properly handle all
three size scenarios.

Signed-off-by: Merijn Verstraaten <>
Test Plan: validate

Reviewers: dfeuer, austin, hvr

Reviewed By: austin, hvr

Subscribers: thomie, carter, simonmar

Differential Revision:

GHC Trac Issues: #8089

5 years agoUpdate .gitignore to properly ignore emacs temp files
Austin Seipp [Fri, 7 Nov 2014 13:30:53 +0000 (07:30 -0600)] 
Update .gitignore to properly ignore emacs temp files

Signed-off-by: Austin Seipp <>
5 years agoMake getTag use a bang pattern instead of seq
David Feuer [Fri, 7 Nov 2014 13:19:18 +0000 (14:19 +0100)] 
Make getTag use a bang pattern instead of seq

It's prettier that way, and there's less risk of anything
going sideways.

Reviewed By: hvr, simonpj

Differential Revision:

5 years agoImprove Applicative definitions
David Feuer [Fri, 7 Nov 2014 07:12:21 +0000 (08:12 +0100)] 
Improve Applicative definitions

Generally clean up things relating to Applicative and Monad in `GHC.Base`
and `Control.Applicative` to make `Applicative` feel like a bit more of a
first-class citizen rather than just playing second fiddle to `Monad`. Use
`coerce` and GND to improve performance and clarity.

Change the default definition of `(*>)` to use `(<$)`, in case the
`Functor` instance optimizes that.

Moreover, some manually written instances are made into compiler-derived

Finally, this also adds a few AMP-related laws to the `Applicative` docstring.

NOTE: These changes result in a 13% decrease in allocation for T9020

Reviewed By: ekmett, hvr

Differential Revision:

5 years agoWarn for Safe Haskell when -XOverlappingInstances or
David Terei [Mon, 4 Aug 2014 21:43:09 +0000 (17:43 -0400)] 
Warn for Safe Haskell when -XOverlappingInstances or
-XIncoherentInstances turned on.

5 years agoAdd in Incoherent Instances test for Safe Haskell.
David Terei [Mon, 4 Aug 2014 21:41:54 +0000 (17:41 -0400)] 
Add in Incoherent Instances test for Safe Haskell.

5 years agoBetter error messages for new per-instance overlap flags and Safe
David Terei [Mon, 4 Aug 2014 16:49:07 +0000 (12:49 -0400)] 
Better error messages for new per-instance overlap flags and Safe

5 years agoRe-enable T3064, which works now
Simon Peyton Jones [Thu, 6 Nov 2014 15:46:11 +0000 (15:46 +0000)] 
Re-enable T3064, which works now

5 years agoRefactor the code that prevents recursion among Coercible constraints
Simon Peyton Jones [Thu, 6 Nov 2014 15:41:50 +0000 (15:41 +0000)] 
Refactor the code that prevents recursion among Coercible constraints

The main description is in Note [Preventing recursive dictionaries]
in TcRnTypes, which applies only to Coercible dictionaries.

But it was a bit of a mess:
 - It wasn't applied consistently
 - It was being applied to non-Coercible dictionaries in some places

This patch tidies it up.

This hack will largely go away when Richard starts treating Coercible
constraints more like equalities than like dictionaries.

5 years agoWibbles to notes
Simon Peyton Jones [Thu, 6 Nov 2014 13:55:05 +0000 (13:55 +0000)] 
Wibbles to notes

5 years agoAllow the solved dictionaries to propagate from outside in
Simon Peyton Jones [Thu, 6 Nov 2014 13:54:20 +0000 (13:54 +0000)] 
Allow the solved dictionaries to propagate from outside in

See Note [Propagate solved dictionaries] in TcSMonad.  This
can signficantly reduce the number of solver steps.

5 years agoMinor refacoring and trace-message printing
Simon Peyton Jones [Thu, 6 Nov 2014 13:48:48 +0000 (13:48 +0000)] 
Minor refacoring and trace-message printing

5 years agoSwitch off lazy flattening (fix Trac #3064)
Simon Peyton Jones [Thu, 6 Nov 2014 13:46:47 +0000 (13:46 +0000)] 
Switch off lazy flattening (fix Trac #3064)

See Note [Lazy flattening] in TcFlatten.

Lazy flattening was an apparently good idea which actually made
the type inference engine go a LOTS slower in T3064.  So I switched
it off again.

5 years agoGive T3064 the right module name (just tidying up)
Simon Peyton Jones [Thu, 6 Nov 2014 13:35:09 +0000 (13:35 +0000)] 
Give T3064 the right module name (just tidying up)

5 years agoComments and white space only
Simon Peyton Jones [Thu, 6 Nov 2014 13:34:25 +0000 (13:34 +0000)] 
Comments and white space only

5 years agoMake tyConsOfType return a (NameEnv TyCon) rather than [TyCon]
Simon Peyton Jones [Thu, 6 Nov 2014 13:18:16 +0000 (13:18 +0000)] 
Make tyConsOfType return a (NameEnv TyCon) rather than [TyCon]

A little refactoring

5 years agoRemove unused tyConsOfDataCon
Simon Peyton Jones [Thu, 6 Nov 2014 13:16:20 +0000 (13:16 +0000)] 
Remove unused tyConsOfDataCon

5 years agoMove expansion of 'assert' from renamer to typechecker
Simon Peyton Jones [Thu, 6 Nov 2014 13:59:42 +0000 (13:59 +0000)] 
Move expansion of 'assert' from renamer to typechecker

This improves error messages when there is a type error,
fixing Trac #9774

5 years agoUpdate User's Guide, cleanup DynFlags
Jan Stolarek [Wed, 5 Nov 2014 12:44:32 +0000 (13:44 +0100)] 
Update User's Guide, cleanup DynFlags

5 years agoRemove -ddump-core-pipeline flag
Jan Stolarek [Wed, 5 Nov 2014 12:43:48 +0000 (13:43 +0100)] 
Remove -ddump-core-pipeline flag

5 years agoRemove -ddump-simpl-phases flag
Jan Stolarek [Wed, 5 Nov 2014 12:37:25 +0000 (13:37 +0100)] 
Remove -ddump-simpl-phases flag

5 years agoClarify confusing notice from `make maintainer-clean`
Jan Stolarek [Wed, 5 Nov 2014 08:39:50 +0000 (09:39 +0100)] 
Clarify confusing notice from `make maintainer-clean`

5 years agoAdd doctest examples for Data.Either
Michael Orlitzky [Thu, 6 Nov 2014 07:29:26 +0000 (08:29 +0100)] 
Add doctest examples for Data.Either

Add doctest examples for every data type and function in `Data.Either`

Differential Revision:

5 years agoAdd a comment about stack checks
Simon Marlow [Tue, 4 Nov 2014 21:32:26 +0000 (21:32 +0000)] 
Add a comment about stack checks

5 years agoDisable an assertion; see comment
Simon Marlow [Tue, 4 Nov 2014 21:32:12 +0000 (21:32 +0000)] 
Disable an assertion; see comment

5 years agoFix a couple of inaccurate stack checks
Simon Marlow [Tue, 4 Nov 2014 21:31:00 +0000 (21:31 +0000)] 
Fix a couple of inaccurate stack checks

5 years agoFix bugs in debug printing
Simon Marlow [Tue, 4 Nov 2014 15:52:23 +0000 (15:52 +0000)] 
Fix bugs in debug printing

5 years agoFix a couple of bugs in the way info tables are generated for 64-bit platforms
Simon Marlow [Tue, 4 Nov 2014 15:51:56 +0000 (15:51 +0000)] 
Fix a couple of bugs in the way info tables are generated for 64-bit platforms

1. The offset was a full word, but it should actually be a 32-bit
offset on 64-bit platforms.
2. The con_desc string was allocated separately, which meant that it
might be out of range for a 32-bit offset.

These bugs meant that +RTS -Di (interpreter debugging) would sometimes
crash on 64-bit.

5 years agoFix typo in testsuite Makefile
Herbert Valerio Riedel [Wed, 5 Nov 2014 13:05:48 +0000 (14:05 +0100)] 
Fix typo in testsuite Makefile

This is introduced in aa4799534225e3fc6bbde0d5e5eeab8868cc3111
and would cause indeterministic testsuite failures in `sigof02dmt`

5 years agoAdd `isSubsequenceOf` to Data.List (#9767)
Alexander Berntsen [Wed, 5 Nov 2014 11:32:06 +0000 (12:32 +0100)] 
Add `isSubsequenceOf` to Data.List (#9767)

Niklas Hamb├╝chen suggested that we add the dual of `subsequences`,
isSubsequenceOf (like `isPrefixOf` to `inits` & `isSuffixOf` to `tails`).
It was a simple and noncontroversial proposal which passed unanimously.

For more details see the original proposal discussion at

Differential Revision:

Signed-off-by: Alexander Berntsen <>
5 years agoClean-up Haddock in `Data.Functor`
Herbert Valerio Riedel [Wed, 5 Nov 2014 11:19:13 +0000 (12:19 +0100)] 
Clean-up Haddock in `Data.Functor`

This mostly cleans up irregularities introduced in
68255588f89462e542c502f6f92548712808032f (re D352) as well as making
sure Haddock is able to resolve all references.

5 years agoRemove redundant contexts from Foldable methods
David Feuer [Wed, 5 Nov 2014 07:42:59 +0000 (08:42 +0100)] 
Remove redundant contexts from Foldable methods

New `Foldable` methods accidentally had `Foldable` contexts, which led
to type roles being assigned incorrectly and preventing GND from
deriving `Foldable` instances. Removing those fixes #9761.

Moreover, this patch takes advantage of this fix by deriving
`Foldable` (and `Eq`) for `UniqFM`.

Differential Revision:

5 years agoTemporarily disable T3064 (see #9771)
Herbert Valerio Riedel [Wed, 5 Nov 2014 07:39:10 +0000 (08:39 +0100)] 
Temporarily disable T3064 (see #9771)

This disables T3064 temporarily as it puts a strain on buildbots
during validation exhausting all available memory.

5 years agoA little refactoring of HsSplice and friends
Simon Peyton Jones [Tue, 4 Nov 2014 14:58:13 +0000 (14:58 +0000)] 
A little refactoring of HsSplice and friends

Plus adding comments.

The most substantive change is that PendingTcSplice becomes a proper
data type rather than a pair; and PendingRnSplice uses it

5 years agoRe-center perf-numbers for T5631
Herbert Valerio Riedel [Tue, 4 Nov 2014 14:27:17 +0000 (15:27 +0100)] 
Re-center perf-numbers for T5631

5 years agoRemove redundant "Minimal complete definition"-comments
Herbert Valerio Riedel [Tue, 4 Nov 2014 10:43:29 +0000 (11:43 +0100)] 
Remove redundant "Minimal complete definition"-comments

Those manual descriptions in Haddock strings have become redundant since
Haddock gained the ability to print the minimal complete definition as
specified via `{-# MINIMAL #-}` annotation (or otherwise inferred by

Moreover, this commit moves all `{-# MINIMAL #-}` annotations in `base`
to the start of the respective `class` definitions, as this is more
readable and matches more closely the way Haddock renders that

5 years agoTest Trac #9750
Simon Peyton Jones [Tue, 4 Nov 2014 10:37:38 +0000 (10:37 +0000)] 
Test Trac #9750

5 years agoTest Trac #9081
Simon Peyton Jones [Tue, 4 Nov 2014 10:35:05 +0000 (10:35 +0000)] 
Test Trac #9081

5 years agoUpdates to safePkg01 under Edward's guidance
Simon Peyton Jones [Tue, 4 Nov 2014 08:36:17 +0000 (08:36 +0000)] 
Updates to safePkg01 under Edward's guidance

5 years agoSimon's major commit to re-engineer the constraint solver
Simon Peyton Jones [Mon, 3 Nov 2014 17:23:11 +0000 (17:23 +0000)] 
Simon's major commit to re-engineer the constraint solver

The driving change is this:

* The canonical CFunEqCan constraints now have the form
       [G] F xis ~ fsk
       [W] F xis ~ fmv
  where fsk is a flatten-skolem, and fmv is a flatten-meta-variable
  Think of them as the name of the type-function application

See Note [The flattening story] in TcFlatten.  A flatten-meta-variable
is distinguishable by its MetaInfo of FlatMetaTv

This in turn led to an enormous cascade of other changes, which simplify
and modularise the constraint solver.  In particular:

* Basic data types
    * I got rid of inert_solved_funeqs altogether. It serves no useful
      role that inert_flat_cache does not solve.

    * I added wl_implics to the WorkList, as a convenient place to
      accumulate newly-emitted implications; see Note [Residual
      implications] in TcSMonad.

    * I eliminated tcs_ty_binds altogether. These were the bindings
      for unification variables that we have now solved by
      unification.  We kept them in a finite map and did the
      side-effecting unification later.  But in cannonicalisation we
      had to look up in the side-effected mutable tyvars anyway, so
      nothing was being gained.

      Our original idea was that the solver would be pure, and would
      be a no-op if you discarded its results, but this was already
      not-true for implications since we update their evidence
      bindings in an imperative way.  So rather than the uneasy
      compromise, it's now clearly imperative!

* I split out the flatten/unflatten code into a new module, TcFlatten

* I simplified and articulated explicitly the (rather hazy) invariants
  for the inert substitution inert_eqs.  See Note [eqCanRewrite] and
  See Note [Applying the inert substitution] in TcFlatten

* Unflattening is now done (by TcFlatten.unflatten) after solveFlats,
  before solving nested implications.  This turned out to simplify a
  lot of code. Previously, unflattening was done as part of zonking, at
  the very very end.

    * Eager unflattening allowed me to remove the unpleasant ic_fsks
      field of an Implication (hurrah)

    * Eager unflattening made the TcSimplify.floatEqualities function
      much simpler (just float equalities looking like a ~ ty, where a
      is an untouchable meta-tyvar).

    * Likewise the idea of "pushing wanteds in as givens" could be
      completely eliminated.

* I radically simplified the code that determines when there are
  'given' equalities, and hence whether we can float 'wanted' equalies
  out.  See TcSMonad.getNoGivenEqs, and Note [When does an implication
  have given equalities?].

  This allowed me to get rid of the unpleasant inert_no_eqs flag in InertCans.

* As part of this given-equality stuff, I fixed Trac #9211. See Note
  [Let-bound skolems] in TcSMonad

* Orientation of tyvar/tyvar equalities (a ~ b) was partly done during
  canonicalisation, but then repeated in the spontaneous-solve stage
  (trySpontaneousSolveTwoWay). Now it is done exclusively during
  canonicalisation, which keeps all the code in one place.  See
  Note [Canonical orientation for tyvar/tyvar equality constraints]
  in TcCanonical

5 years agoCompiler performance is much worse in for loopy givens
Simon Peyton Jones [Mon, 3 Nov 2014 10:37:59 +0000 (10:37 +0000)] 
Compiler performance is much worse in for loopy givens

This is a deliberate choice, to simplify code, invariants, and I think
performance in typical cases.  The "loopy givens" case is situations like

   [G]  a ~ TF (a, Int)

where TF is a type function with TF (a,b) = (TF a, TF b).

See Note [An alternative story for the inert substitution] in TcFlatten.

5 years agoMake this test a bit simpler
Simon Peyton Jones [Fri, 31 Oct 2014 12:28:42 +0000 (12:28 +0000)] 
Make this test a bit simpler

There were two unrelated functions, and the `-ddump-rule-firings` output
was coming in a non-deterministic order as a result. So now there is just
one function.

5 years agoAdd flattening-notes
Simon Peyton Jones [Thu, 30 Oct 2014 12:11:27 +0000 (12:11 +0000)] 
Add flattening-notes

5 years agoTestsuite error message changes
Simon Peyton Jones [Thu, 30 Oct 2014 11:41:17 +0000 (11:41 +0000)] 
Testsuite error message changes

5 years agoComments only
Simon Peyton Jones [Fri, 31 Oct 2014 12:32:36 +0000 (12:32 +0000)] 
Comments only

5 years agoFix the superclass-cycle detection code (Trac #9739)
Simon Peyton Jones [Fri, 31 Oct 2014 12:31:59 +0000 (12:31 +0000)] 
Fix the superclass-cycle detection code (Trac #9739)

We were falling into an infinite loop when doing the ambiguity
check on a class method, even though we had previously detected
a superclass cycle.  There was code to deal with this, but it
wasn't right.

5 years agoTest Trac #9739
Simon Peyton Jones [Fri, 31 Oct 2014 11:11:50 +0000 (11:11 +0000)] 
Test Trac #9739

5 years agoAdd comments explaining ProbOneShot
Simon Peyton Jones [Fri, 31 Oct 2014 11:13:37 +0000 (11:13 +0000)] 
Add comments explaining ProbOneShot

5 years agoTest Trac #9747
Simon Peyton Jones [Fri, 31 Oct 2014 08:53:52 +0000 (08:53 +0000)] 
Test Trac #9747

5 years agoImprove error message for a handwritten Typeable instance
Simon Peyton Jones [Thu, 30 Oct 2014 16:33:34 +0000 (16:33 +0000)] 
Improve error message for a handwritten Typeable instance

5 years agoTest Trac #9708
Simon Peyton Jones [Thu, 30 Oct 2014 11:39:39 +0000 (11:39 +0000)] 
Test Trac #9708

5 years agoTest Trac #9211
Simon Peyton Jones [Thu, 30 Oct 2014 11:37:39 +0000 (11:37 +0000)] 
Test Trac #9211

5 years agoDefine ctEvLoc and ctEvCoercion, and use them
Simon Peyton Jones [Thu, 30 Oct 2014 09:08:23 +0000 (09:08 +0000)] 
Define ctEvLoc and ctEvCoercion, and use them

5 years agoMinor refactoring (no change in functionality)
Simon Peyton Jones [Wed, 29 Oct 2014 17:51:41 +0000 (17:51 +0000)] 
Minor refactoring (no change in functionality)

5 years agoDon't filter out allegedly-irrelevant bindings with -dppr-debug
Simon Peyton Jones [Wed, 29 Oct 2014 17:50:44 +0000 (17:50 +0000)] 
Don't filter out allegedly-irrelevant bindings with -dppr-debug

5 years agoOnly report "could not deduce s~t from ..." for givens that include equalities
Simon Peyton Jones [Wed, 29 Oct 2014 17:49:34 +0000 (17:49 +0000)] 
Only report "could not deduce s~t from ..." for givens that include equalities

This just simplifies the error message in cases where there are no useful
equalities in the context

5 years agoWhen reporting the context of given constraints, stop when you find one
Simon Peyton Jones [Wed, 29 Oct 2014 17:45:34 +0000 (17:45 +0000)] 
When reporting the context of given constraints, stop when you find one
that binds a variable mentioned in the wanted

There is really no point in reporting ones further out; they can't be useful

5 years agoTypechecker debug tracing only
Simon Peyton Jones [Wed, 29 Oct 2014 17:22:57 +0000 (17:22 +0000)] 
Typechecker debug tracing only

5 years agoNormalise the type of an inferred let-binding
Simon Peyton Jones [Wed, 29 Oct 2014 17:21:05 +0000 (17:21 +0000)] 
Normalise the type of an inferred let-binding

With the new constraint solver, we don't guarantee to fully-normalise
all constraints (if doing so is not necessary to solve them). So we
may end up with an inferred type like
      f :: [F Int] -> Bool
which could be simplifed to
      f :: [Char] -> Bool
if there is a suitable family instance declaration.  This patch
does this normalisation, in TcBinds.mkExport

5 years agoGet the Untouchables level right in simplifyInfer
Simon Peyton Jones [Wed, 29 Oct 2014 17:18:33 +0000 (17:18 +0000)] 
Get the Untouchables level right in simplifyInfer

Previously we could get constraints in which the untouchables-level did not
strictly increase, which is one of the main invariants!

This patch also simplifies and modularises the tricky case of generalising
an inferred let-binding

5 years agoRefactor the treatment of lexically-scoped type variables for instance declarations
Simon Peyton Jones [Wed, 29 Oct 2014 16:54:47 +0000 (16:54 +0000)] 
Refactor the treatment of lexically-scoped type variables for instance declarations

Previously the univerally-quantified variables of the DFun were also (bizarrely)
used as the lexically-scoped variables of the instance declaration.  So, for example,
the DFun's type could not be alpha-renamed.  This was an odd restriction, which has
bitten me several times.

This patch does the Right Thing, by adding an ib_tyvars field to the
InstBindings record, which captures the lexically scoped variables.
Easy, robust, nice.  (I think this record probably didn't exist originally,
hence the hack.)

5 years agoRefactor skolemising, and newClsInst
Simon Peyton Jones [Wed, 29 Oct 2014 16:26:53 +0000 (16:26 +0000)] 
Refactor skolemising, and newClsInst

This makes newClsInst (was mkInstance) look more like newFamInst, and simplifies
the plumbing of the overlap flag, and ensures that freshening (required by
the InstEnv stuff) happens in one place.

On the way I also tided up the rather ragged family of tcInstSkolTyVars and
friends.  The result at least has more uniform naming.

5 years agoRename setRole_maybe to downgradeRole_maybe
Simon Peyton Jones [Wed, 29 Oct 2014 16:35:19 +0000 (16:35 +0000)] 
Rename setRole_maybe to downgradeRole_maybe

This change is just for naming uniformity with the existing downgradeRole

5 years agoSimplify the API for tcInstTyVars, and make it more consistent with other similar...
Simon Peyton Jones [Wed, 29 Oct 2014 16:34:05 +0000 (16:34 +0000)] 
Simplify the API for tcInstTyVars, and make it more consistent with other similar functions

5 years agoFix reduceTyFamApp_maybe
Simon Peyton Jones [Wed, 29 Oct 2014 16:30:05 +0000 (16:30 +0000)] 
Fix reduceTyFamApp_maybe

This function previously would expand *data* families even when it was asked
for a *Nominal* coercion.  This patch fixes it, and adds comments.

5 years agoWhite space only
Simon Peyton Jones [Wed, 29 Oct 2014 16:27:50 +0000 (16:27 +0000)] 
White space only

5 years agoAdd the unfolding and inline-pragma for DFuns in DsBinds, not TcInstDcls
Simon Peyton Jones [Wed, 29 Oct 2014 15:36:28 +0000 (15:36 +0000)] 
Add the unfolding and inline-pragma for DFuns in DsBinds, not TcInstDcls

This is a straight refactoring that puts the generation of unfolding
info in one place, which is a lot tidier

5 years agoSimplify the generation of superclass constraints in tcInstDecl2
Simon Peyton Jones [Wed, 29 Oct 2014 15:34:14 +0000 (15:34 +0000)] 
Simplify the generation of superclass constraints in tcInstDecl2

The simplified function is tcSuperClasses;
no need for an implication constraint here